mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-11-10 22:56:41 +01:00
Fixes the sending of multiple old events back to the relays that send old events to Amethyst.
This commit is contained in:
@@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user