From 772355d2fcaecd48aea1a32468cde657e68860f5 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 2 Jun 2026 21:28:30 +0000 Subject: [PATCH] fix: don't ask a correspondent's relays for my own NIP-04 messages A conversation's NIP-04 relay set folded the correspondent's inbox (read) relays into the from-me filter set, so we sent {authors:[me]} to relays that belong to the other party (e.g. ditto). Those relays have no reason to hold my authored messages and auth-walled ones reject the filter outright ("all authors must be authenticated"), stalling the load. Scope filters to relay owners: my outbox carries my messages; the correspondent's outbox (plus my own inbox as a legacy safety net) carries theirs. Drops groupInbox from the from-me set. https://claude.ai/code/session_01B1fmmmX8JjQWH3amMLdvcW --- .../privateDM/datasource/FilterNip04DMs.kt | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/datasource/FilterNip04DMs.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/datasource/FilterNip04DMs.kt index 977f1bcf0d..bdf4d0570e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/datasource/FilterNip04DMs.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/datasource/FilterNip04DMs.kt @@ -38,8 +38,15 @@ class Nip04DmRelays( } /** - * Resolves where a conversation's NIP-04 DMs flow: messages **to me** arrive on my inbox + the - * group's outbox relays; messages **from me** arrive on my outbox + the group's inbox relays. + * Resolves where a conversation's NIP-04 DMs flow, scoped to relay owners so a filter naming a user + * is only sent to relays that user actually lists: + * + * - **to me** (`authors=[group]`) → the group's **outbox** (where they publish) plus **my inbox** + * (my own DM relays, as a safety net for legacy senders that delivered straight to my inbox). + * - **from me** (`authors=[me]`) → **my outbox** only. We deliberately do *not* ask the group's + * inbox relays for my-authored messages: those relays belong to the correspondent, not me, and + * querying them for `authors=[me]` is both redundant (my outbox already has them) and a trigger + * for auth-walled relays like ditto that reject authors they can't authenticate. */ fun nip04DMRelays( group: Set?, @@ -51,7 +58,6 @@ fun nip04DMRelays( val userInboxRelays = account.dmRelays.flow.value val groupOutboxRelays = mutableSetOf() - val groupInboxRelays = mutableSetOf() group.forEach { val authorHomeRelayEventAddress = AdvertisedRelayListEvent.createAddressTag(it) @@ -64,19 +70,11 @@ fun nip04DMRelays( ?: emptyList() groupOutboxRelays.addAll(outbox) - - val inbox = - authorHomeRelayEvent?.readRelaysNorm()?.ifEmpty { null } - ?: LocalCache.getUserIfExists(it)?.allUsedRelaysOrNull() - ?: LocalCache.relayHints.hintsForKey(it).ifEmpty { null } - ?: emptyList() - - groupInboxRelays.addAll(inbox) } return Nip04DmRelays( toMeRelays = userInboxRelays + groupOutboxRelays, - fromMeRelays = userOutboxRelays + groupInboxRelays, + fromMeRelays = userOutboxRelays, ) }