What is Nostr?
Aspie96 / Valentino Giudice
npub13mj…8hs2
2024-06-06 04:58:09

Aspie96 on Nostr: Follows on #Nostr are a mess. Users follow other users on Nostr using kind3 events, ...

Follows on #Nostr are a mess.

Users follow other users on Nostr using kind3 events, defined in NIP-02. Events of this kind are replaceable and they contain the whole list of accounts (pubkeys) the author follows.

Fetching the list of accounts a user follows can be done by fetching the relevant kind3 event. Because not all relays have the same events, one should fetch the relevant event from all relays, then pick the most recent one across all received events (within some timeout). This is in contrast with fetching non-replaceable kind0 events (for example): in that case one can stop display the result after receiving the first answer. However, handling this is simple enough.

Fetching what users follow a certain account, on the other hand, is really tricky. The most obvious way is fetching all kind3 events (from all relays) that point to that account, from other users. But this will yield false positives: if a user has followed that account in the past, then unfollowed it, it might be that the updated kind3 event (with that account removed from the updated list) is not available on all relays. The query will return nothing on relays with the updated list, but they will return an obsolete event, yielding a false positive.

This can happen on nostrudel (npub1wyu…87ez), for example. If a user follows you and then unfollows you (but fails to update the list on all relays the second time), the "Following" tab on that user's account will, indeed (correctly) not display your name. This is because the client will still fetch the updated list from at least one relay. But if you go to the "Followers" tab of your own profile, you will still (incorrectly) see that user's name. This is because the client is only fetching (potentially outdated) kind3 events that point to your account.

The only obvious way to fix this is by fetching someone's followers in two steps. First, one would need to fetch all kind3 events that point to that account (which is what currently happens), then one would have to double-check each of them by fetching (from all relays) the most recent kind3 event of each user found in the first step (which can be done with one or few queries, each with multiple authors specified in the filter). This is nontrivial, it's more expensive and slower and it's not what happens in practice (at least not on noStrudel, it seems).

There is another problem which has a very simple solution, on the other hand, but is yet to be solved.
It'd be nice to be able to be notified when a user follows you. That is a rather crucial social event, which I think users want. Yet, notifications don't show that. Indeed, how would they? How would you know, just from kind-3 events, whether the follow is new? What are you even going to fetch?
Here is the simple solution I suggested to this problem: https://github.com/nostr-protocol/nips/discussions/1131
Author Public Key
npub13mjzjryckg9jnxgn3vez73nw5gx82cy0269t2083zjftlxewsjwqny8hs2