feat(ios): declare publish cancellation and the Room constructor to swift
@Throws(CancellationException) on the publish path so swift sees a cancellation as one, @ConstructedBy so Room can build the database on ios, an unused import out of Platform.ios.kt, and the development TEAM_ID for signing.
This commit is contained in:
1 parent
64b374476b
commit
987df2c8f6
7 files changed
+10
-8
No files matched your search
@@ -2,6 +2,7 @@ package to.curare.compose.database
|
||||
|
||||
import androidx.room3.ColumnTypeConverters
|
||||
import androidx.room3.AutoMigration
|
||||
import androidx.room3.ConstructedBy
|
||||
import androidx.room3.Database
|
||||
import androidx.room3.RoomDatabase
|
||||
import androidx.room3.immediateTransaction
|
||||
@@ -363,6 +364,7 @@ val GENESIS_AT = Instant.fromEpochMilliseconds(1231006505000L)
|
||||
AutoMigration(from = 23, to = 24),
|
||||
]
|
||||
)
|
||||
@ConstructedBy(CurareDatabaseConstructor::class)
|
||||
@ColumnTypeConverters(CurareConverters::class)
|
||||
abstract class CurareDatabase: RoomDatabase() {
|
||||
/**
|
||||
|
||||
+1
@@ -28,5 +28,6 @@ interface EventPublishTransport {
|
||||
*
|
||||
* @see RelayPool.publishEvent
|
||||
*/
|
||||
@Throws(to.curare.compose.exceptions.NostrPublishException::class, kotlin.coroutines.cancellation.CancellationException::class)
|
||||
suspend fun publishEvent(nostrEvent: NostrEvent, relays: Set<RelayDTO>): Flow<NostrPublishResult>
|
||||
}
|
||||
@@ -286,7 +286,7 @@ class RelayPool(
|
||||
)
|
||||
}
|
||||
|
||||
@Throws(to.curare.compose.exceptions.NostrPublishException::class)
|
||||
@Throws(to.curare.compose.exceptions.NostrPublishException::class, kotlin.coroutines.cancellation.CancellationException::class)
|
||||
suspend fun publishEvent(nostrEvent: to.curare.compose.database.model.NostrEvent, relays: Set<to.curare.compose.network.dto.RelayDTO> = emptySet()): Flow<NostrPublishResult> {
|
||||
val relayUrls = relays.map { NormalizedRelayUrl(it.url).displayUrl() }
|
||||
|
||||
|
||||
+2
-2
@@ -100,7 +100,7 @@ class RelaysSocketManager(
|
||||
relayPool.closePool()
|
||||
}
|
||||
|
||||
@Throws(to.curare.compose.exceptions.NostrPublishException::class)
|
||||
@Throws(to.curare.compose.exceptions.NostrPublishException::class, kotlin.coroutines.cancellation.CancellationException::class)
|
||||
suspend fun publishEvent(nostrEvent: to.curare.compose.database.model.NostrEvent): Flow<NostrPublishResult> {
|
||||
return if (userRelays.isNotEmpty()) {
|
||||
relayPool.publishEvent(
|
||||
@@ -115,7 +115,7 @@ class RelaysSocketManager(
|
||||
}
|
||||
}
|
||||
|
||||
@Throws(to.curare.compose.exceptions.NostrPublishException::class)
|
||||
@Throws(to.curare.compose.exceptions.NostrPublishException::class, kotlin.coroutines.cancellation.CancellationException::class)
|
||||
override suspend fun publishEvent(nostrEvent: to.curare.compose.database.model.NostrEvent, relays: Set<to.curare.compose.network.dto.RelayDTO>): Flow<NostrPublishResult> {
|
||||
logger.d("publishEvent: $nostrEvent")
|
||||
return relayPool.publishEvent(
|
||||
|
||||
+3
-3
@@ -30,7 +30,7 @@ class NostrPublisherRepository(
|
||||
}
|
||||
}
|
||||
|
||||
@Throws(to.curare.compose.exceptions.NostrPublishException::class)
|
||||
@Throws(to.curare.compose.exceptions.NostrPublishException::class, kotlin.coroutines.cancellation.CancellationException::class)
|
||||
private suspend fun publishAndImportEvent(signedNostrEvent: to.curare.compose.database.model.NostrEvent, outboxRelays: List<String> = emptyList()) {
|
||||
relaysSocketManager.publishEvent(signedNostrEvent)
|
||||
importEvent(signedNostrEvent)
|
||||
@@ -52,7 +52,7 @@ class NostrPublisherRepository(
|
||||
}
|
||||
}
|
||||
|
||||
@Throws(to.curare.compose.exceptions.NostrPublishException::class, to.curare.compose.exceptions.SignatureException::class)
|
||||
@Throws(to.curare.compose.exceptions.NostrPublishException::class, to.curare.compose.exceptions.SignatureException::class, kotlin.coroutines.cancellation.CancellationException::class)
|
||||
suspend fun signPublishImportNostrEvent(
|
||||
unsignedNostrEvent: to.curare.compose.database.model.UnsignedNostrEvent,
|
||||
outboxRelays: List<String>,
|
||||
@@ -63,7 +63,7 @@ class NostrPublisherRepository(
|
||||
}
|
||||
|
||||
|
||||
@Throws(to.curare.compose.exceptions.NostrPublishException::class, to.curare.compose.exceptions.SignatureException::class)
|
||||
@Throws(to.curare.compose.exceptions.NostrPublishException::class, to.curare.compose.exceptions.SignatureException::class, kotlin.coroutines.cancellation.CancellationException::class)
|
||||
suspend fun publishRelayList(userId: String, relays: List<to.curare.compose.network.dto.RelayDTO>): to.curare.compose.database.model.NostrEvent {
|
||||
val signedNostrEvent = nostrNotary.signRelayListMetadata(userId = userId, relays = relays).unwrapOrThrow()
|
||||
relaysSocketManager.publishEvent(nostrEvent = signedNostrEvent, relays = relays.toSet())
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package to.curare.compose
|
||||
|
||||
import platform.UIKit.UIDevice
|
||||
import kotlin.native.Platform
|
||||
|
||||
class IOSPlatform: Platform {
|
||||
override val name: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
TEAM_ID=
|
||||
TEAM_ID=ZK3TQ662GB
|
||||
|
||||
PRODUCT_NAME=Curare
|
||||
PRODUCT_BUNDLE_IDENTIFIER=to.curare.ios$(TEAM_ID)
|
||||
|
||||
Reference in new issue
Block a user