Fixes the sending of multiple old events back to the relays that send old events to Amethyst.

This commit is contained in:
Vitor Pamplona
2025-07-08 09:22:33 -04:00
parent 2c90aa4b1e
commit 1b86c3d85b
3 changed files with 7 additions and 3 deletions

View File

@@ -2971,7 +2971,11 @@ object LocalCache : ILocalCache {
getAddressableNoteIfExists(event.address())?.let { note ->
note.event?.let { existingEvent ->
if (existingEvent.createdAt > event.createdAt && !note.hasRelay(relay.url)) {
Log.d("LocalCache", "Updating ${relay.url.url} with a new version of ${event.toJson()} to ${existingEvent.toJson()}")
Log.d("LocalCache", "Updating ${relay.url.url} with a new version of ${event.kind} ${event.id} to ${existingEvent.id}")
// only send once.
note.addRelay(relay.url)
relay.send(existingEvent)
}
}

View File

@@ -464,7 +464,7 @@ open class Note(
}
}
fun hasRelay(relay: NormalizedRelayUrl) = relay !in relays
fun hasRelay(relay: NormalizedRelayUrl) = relay in relays
fun addRelay(relay: NormalizedRelayUrl) {
if (relay !in relays) {

View File

@@ -263,7 +263,7 @@ open class BasicRelayClient(
msg: OkMessage,
onConnected: () -> Unit,
) {
// Log.w(logTag, "OK: ${msg.eventId} ${msg.success} ${msg.message}")
Log.w(logTag, "OK: ${msg.eventId} ${msg.success} ${msg.message}")
// if this is the OK of an auth event, renew all subscriptions and resend all outgoing events.
if (authResponseWatcher.containsKey(msg.eventId)) {