Remove neg-close as an incoming message
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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) ||
|
||||
|
||||
@@ -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}")
|
||||
|
||||
@@ -49,9 +49,6 @@ internal sealed class NostrVerb {
|
||||
@SerialName("NEG-MSG")
|
||||
NEGENTROPY_MESSAGE,
|
||||
|
||||
@SerialName("NEG-CLOSE")
|
||||
NEGENTROPY_CLOSE,
|
||||
|
||||
@SerialName("NEG-ERR")
|
||||
NEGENTROPY_ERROR,
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user