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 -> getAddressableNoteIfExists(event.address())?.let { note ->
note.event?.let { existingEvent -> note.event?.let { existingEvent ->
if (existingEvent.createdAt > event.createdAt && !note.hasRelay(relay.url)) { 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) 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) { fun addRelay(relay: NormalizedRelayUrl) {
if (relay !in relays) { if (relay !in relays) {

View File

@@ -263,7 +263,7 @@ open class BasicRelayClient(
msg: OkMessage, msg: OkMessage,
onConnected: () -> Unit, 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 this is the OK of an auth event, renew all subscriptions and resend all outgoing events.
if (authResponseWatcher.containsKey(msg.eventId)) { if (authResponseWatcher.containsKey(msg.eventId)) {