Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Outbox read relays are not used for DMs #80

Open
dtonon opened this issue Feb 18, 2025 · 5 comments
Open

Outbox read relays are not used for DMs #80

dtonon opened this issue Feb 18, 2025 · 5 comments

Comments

@dtonon
Copy link

dtonon commented Feb 18, 2025

I sent a message to myself with a test account, and it's only delivered to the "preferred relay" I set up for this test account, it has not been delivered to my read relays.
Without some more info for the profile, I cannot check if the app is actually fetching my correct NIP-65 list.

@prolic
Copy link
Collaborator

prolic commented Feb 20, 2025

probably related to #92

@prolic
Copy link
Collaborator

prolic commented Feb 20, 2025

@dtonon I have a question about this:

NIP-17 states: "It's advisable that relays do not serve kind:1059 to clients other than the ones tagged in them. It's advisable that users choose relays that conform to these practices."

I have read this as "only send to my own preferred dm relays and the receivers preferred dm relays". why would I want to have this on any public outbox relay? Most of those are not auth relays.

@dtonon
Copy link
Author

dtonon commented Feb 20, 2025

You are right, sorry, I was thinking about kind:10050 events, not kid:10002 ones.
The problem is the same, it seems that Futr does not deliver to the recipient DMs relays, but only to the sender preferred relays.

@prolic
Copy link
Collaborator

prolic commented Feb 20, 2025 via email

@prolic
Copy link
Collaborator

prolic commented Feb 21, 2025

Code wise:

    PublishGiftWrap event' senderPk recipientPk -> do
        void $ putEvent $ EventWithRelays event' Set.empty
        dmRelayList <- getDMRelays senderPk
        recipientDMRelays <- getDMRelays recipientPk

        if null dmRelayList || null recipientDMRelays
            then pure ()
            else do
                let allRelayURIs = nub $ dmRelayList ++ recipientDMRelays

                modify $ \st -> st
                    { publishStatus = Map.insert
                        (eventId event')
                        (Map.fromList [(relay, Publishing) | relay <- allRelayURIs])
                        (publishStatus st)
                    }

                existingConnections <- getConnectedRelays
                let (existingRelays, newRelays) = partition 
                        (`elem` existingConnections) 
                        allRelayURIs

                forM_ existingRelays $ \r -> writeToChannel event' r
                forM_ newRelays $ \r -> async $ do
                    connected <- connect r
                    if connected
                        then do
                            writeToChannel event' r
                            disconnect r
                        else do
                            modify $ \st' -> st'
                                { publishStatus = Map.adjust
                                    (Map.insert r (Failure "Relay server unreachable"))
                                    (eventId event')
                                    (publishStatus st')
                                }

I see it sending to all relays. I just added publish status UI for sent events, maybe this helps debugging what's going wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants