Remove neg-close as an incoming message

This commit is contained in:
Kgothatso Ngako
2026-05-04 21:58:39 +02:00
parent ee8e544ff6
commit b2bd4c1afc
5 changed files with 1 additions and 27 deletions

View File

@@ -45,10 +45,6 @@ sealed class NostrIncomingMessage {
val negentropyMessage: String,
) : NostrIncomingMessage()
data class NegentropyClose(
val subscriptionId: String
) : NostrIncomingMessage()
data class NegentropyError(
val subscriptionId: String,
val negentropyReason: String,

View File

@@ -7,7 +7,6 @@ fun Flow<NostrIncomingMessage>.filterBySubscriptionId(id: String) =
filter {
// Negentropy...
(it is NostrIncomingMessage.NegentropyMessage && it.subscriptionId == id) ||
(it is NostrIncomingMessage.NegentropyClose && it.subscriptionId == id) ||
(it is NostrIncomingMessage.NegentropyError && it.subscriptionId == id) ||
// Events
(it is NostrIncomingMessage.EventMessage && it.subscriptionId == id) ||

View File

@@ -29,7 +29,6 @@ fun String.parseIncomingMessage(): NostrIncomingMessage? {
NostrVerb.Incoming.COUNT -> jsonArray.takeAsCountIncomingMessage()
NostrVerb.Incoming.EVENTS -> jsonArray.takeAsEventsIncomingMessage()
NostrVerb.Incoming.NEGENTROPY_MESSAGE -> jsonArray.takeAsNegentropyMessageIncomingMessage()
NostrVerb.Incoming.NEGENTROPY_CLOSE -> jsonArray.takeAsNegentropyCloseIncomingMessage()
NostrVerb.Incoming.NEGENTROPY_ERROR -> jsonArray.takeAsNegentropyErrorIncomingMessage()
null -> null
}
@@ -157,19 +156,6 @@ private fun JsonArray.takeAsNegentropyMessageIncomingMessage(): NostrIncomingMes
}
}
private fun JsonArray.takeAsNegentropyCloseIncomingMessage(): NostrIncomingMessage? {
val subscriptionId = elementAtOrNull(1)?.toSubscriptionId()
return if (subscriptionId != null) {
NostrIncomingMessage.NegentropyClose(
subscriptionId = subscriptionId,
)
} else {
null
}
}
private fun JsonArray.takeAsNegentropyErrorIncomingMessage(): NostrIncomingMessage? {
val subscriptionId = elementAtOrNull(1)?.toSubscriptionId()
val negentropyReason = elementAtOrNull(2)?.jsonPrimitive?.content
@@ -194,7 +180,6 @@ private fun JsonElement.toIncomingMessageType(): NostrVerb.Incoming? {
"EVENTS" -> NostrVerb.Incoming.EVENTS
"NOTICE" -> NostrVerb.Incoming.NOTICE
"NEG-MSG" -> NostrVerb.Incoming.NEGENTROPY_MESSAGE
"NEG-CLOSE" -> NostrVerb.Incoming.NEGENTROPY_CLOSE
"NEG-ERR" -> NostrVerb.Incoming.NEGENTROPY_ERROR
else -> {
Logger.d("Unsupported incomingMessageType: ${this.jsonPrimitive.content}")

View File

@@ -49,9 +49,6 @@ internal sealed class NostrVerb {
@SerialName("NEG-MSG")
NEGENTROPY_MESSAGE,
@SerialName("NEG-CLOSE")
NEGENTROPY_CLOSE,
@SerialName("NEG-ERR")
NEGENTROPY_ERROR,
}

View File

@@ -220,8 +220,7 @@ class NavigationViewModel(
scope.launch(Dispatchers.IO) {
nostrRepository.observePendingNegentropySynchronizeRequests().distinctUntilChanged().collect { negentropySynchronizeRequestOrNull ->
negentropySynchronizeRequestOrNull?.let { negentropySynchronizeRequest ->
logger.i("synchronizeNostrEventRequest: $negentropySynchronizeRequest")
// TODO: Negentropy...
logger.i("negentropySynchronizeRequest: $negentropySynchronizeRequest")
val events = nostrRepository.getNostrFeedIds(
arrayOf(
@@ -239,7 +238,6 @@ class NavigationViewModel(
seal()
}
logger.d("Negentropy Storage: $storage")
val negentropy = Negentropy(
storage,
)
@@ -349,7 +347,6 @@ class NavigationViewModel(
broadcastNostrEventRequests
)
}
else -> {
logger.d("Unhandled message ${negentropySynchronizeRequest.relayURL}: $nostrIncomingMessage")
}