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
This commit is contained in:
Claude
2026-06-02 21:28:30 +00:00
parent 5bd7b765d6
commit 772355d2fc
@@ -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<HexKey>?,
@@ -51,7 +58,6 @@ fun nip04DMRelays(
val userInboxRelays = account.dmRelays.flow.value
val groupOutboxRelays = mutableSetOf<NormalizedRelayUrl>()
val groupInboxRelays = mutableSetOf<NormalizedRelayUrl>()
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,
)
}