feat(ios): declare publish cancellation to swift, and unshadow Platform

Seven `@Throws` on the publish path now name
`kotlin.coroutines.cancellation.CancellationException` alongside
`NostrPublishException`. Without it a publish cancelled by the screen
navigating away crosses the ObjC boundary as an unexpected throw rather
than as the cancellation it is, and swift has no way to tell the two
apart. Six of the seven already existed; `EventPublishTransport` had
none, so the interface the group-signed path publishes through said less
about itself than the implementation behind it.

`Platform.ios.kt` also imported `kotlin.native.Platform`, which shadows
the app's own `Platform` interface the file is there to implement. It was
unused and nothing on this host compiles iosMain, so the compiler never
said so.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Kgothatso NgakoandClaude Opus 5 committed 2026-10-02 23:51:13 +02:00
1 parent 73b2c8ae9a
commit fc19583225
5 files changed
+7 -7

No files matched your search

@@ -28,5 +28,6 @@ interface EventPublishTransport {
* *
* @see RelayPool.publishEvent * @see RelayPool.publishEvent
*/ */
@Throws(press.mantra.compose.exceptions.NostrPublishException::class, kotlin.coroutines.cancellation.CancellationException::class)
suspend fun publishEvent(nostrEvent: NostrEvent, relays: Set<RelayDTO>): Flow<NostrPublishResult> suspend fun publishEvent(nostrEvent: NostrEvent, relays: Set<RelayDTO>): Flow<NostrPublishResult>
} }
@@ -286,7 +286,7 @@ class RelayPool(
) )
} }
@Throws(press.mantra.compose.exceptions.NostrPublishException::class) @Throws(press.mantra.compose.exceptions.NostrPublishException::class, kotlin.coroutines.cancellation.CancellationException::class)
suspend fun publishEvent(nostrEvent: press.mantra.compose.database.model.NostrEvent, relays: Set<press.mantra.compose.network.dto.RelayDTO> = emptySet()): Flow<NostrPublishResult> { suspend fun publishEvent(nostrEvent: press.mantra.compose.database.model.NostrEvent, relays: Set<press.mantra.compose.network.dto.RelayDTO> = emptySet()): Flow<NostrPublishResult> {
val relayUrls = relays.map { NormalizedRelayUrl(it.url).displayUrl() } val relayUrls = relays.map { NormalizedRelayUrl(it.url).displayUrl() }
@@ -100,7 +100,7 @@ class RelaysSocketManager(
relayPool.closePool() relayPool.closePool()
} }
@Throws(press.mantra.compose.exceptions.NostrPublishException::class) @Throws(press.mantra.compose.exceptions.NostrPublishException::class, kotlin.coroutines.cancellation.CancellationException::class)
suspend fun publishEvent(nostrEvent: press.mantra.compose.database.model.NostrEvent): Flow<NostrPublishResult> { suspend fun publishEvent(nostrEvent: press.mantra.compose.database.model.NostrEvent): Flow<NostrPublishResult> {
return if (userRelays.isNotEmpty()) { return if (userRelays.isNotEmpty()) {
relayPool.publishEvent( relayPool.publishEvent(
@@ -115,7 +115,7 @@ class RelaysSocketManager(
} }
} }
@Throws(press.mantra.compose.exceptions.NostrPublishException::class) @Throws(press.mantra.compose.exceptions.NostrPublishException::class, kotlin.coroutines.cancellation.CancellationException::class)
override suspend fun publishEvent(nostrEvent: press.mantra.compose.database.model.NostrEvent, relays: Set<press.mantra.compose.network.dto.RelayDTO>): Flow<NostrPublishResult> { override suspend fun publishEvent(nostrEvent: press.mantra.compose.database.model.NostrEvent, relays: Set<press.mantra.compose.network.dto.RelayDTO>): Flow<NostrPublishResult> {
logger.d("publishEvent: $nostrEvent") logger.d("publishEvent: $nostrEvent")
return relayPool.publishEvent( return relayPool.publishEvent(
@@ -30,7 +30,7 @@ class NostrPublisherRepository(
} }
} }
@Throws(press.mantra.compose.exceptions.NostrPublishException::class) @Throws(press.mantra.compose.exceptions.NostrPublishException::class, kotlin.coroutines.cancellation.CancellationException::class)
private suspend fun publishAndImportEvent(signedNostrEvent: press.mantra.compose.database.model.NostrEvent, outboxRelays: List<String> = emptyList()) { private suspend fun publishAndImportEvent(signedNostrEvent: press.mantra.compose.database.model.NostrEvent, outboxRelays: List<String> = emptyList()) {
relaysSocketManager.publishEvent(signedNostrEvent) relaysSocketManager.publishEvent(signedNostrEvent)
importEvent(signedNostrEvent) importEvent(signedNostrEvent)
@@ -52,7 +52,7 @@ class NostrPublisherRepository(
} }
} }
@Throws(press.mantra.compose.exceptions.NostrPublishException::class, press.mantra.compose.exceptions.SignatureException::class) @Throws(press.mantra.compose.exceptions.NostrPublishException::class, press.mantra.compose.exceptions.SignatureException::class, kotlin.coroutines.cancellation.CancellationException::class)
suspend fun signPublishImportNostrEvent( suspend fun signPublishImportNostrEvent(
unsignedNostrEvent: press.mantra.compose.database.model.UnsignedNostrEvent, unsignedNostrEvent: press.mantra.compose.database.model.UnsignedNostrEvent,
outboxRelays: List<String>, outboxRelays: List<String>,
@@ -63,7 +63,7 @@ class NostrPublisherRepository(
} }
@Throws(press.mantra.compose.exceptions.NostrPublishException::class, press.mantra.compose.exceptions.SignatureException::class) @Throws(press.mantra.compose.exceptions.NostrPublishException::class, press.mantra.compose.exceptions.SignatureException::class, kotlin.coroutines.cancellation.CancellationException::class)
suspend fun publishRelayList(userId: String, relays: List<press.mantra.compose.network.dto.RelayDTO>): press.mantra.compose.database.model.NostrEvent { suspend fun publishRelayList(userId: String, relays: List<press.mantra.compose.network.dto.RelayDTO>): press.mantra.compose.database.model.NostrEvent {
val signedNostrEvent = nostrNotary.signRelayListMetadata(userId = userId, relays = relays).unwrapOrThrow() val signedNostrEvent = nostrNotary.signRelayListMetadata(userId = userId, relays = relays).unwrapOrThrow()
relaysSocketManager.publishEvent(nostrEvent = signedNostrEvent, relays = relays.toSet()) relaysSocketManager.publishEvent(nostrEvent = signedNostrEvent, relays = relays.toSet())
@@ -1,7 +1,6 @@
package press.mantra.compose package press.mantra.compose
import platform.UIKit.UIDevice import platform.UIKit.UIDevice
import kotlin.native.Platform
class IOSPlatform: Platform { class IOSPlatform: Platform {
override val name: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion override val name: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion