nips icon indicating copy to clipboard operation
nips copied to clipboard

Question regarding filtering by multiple tags

Open flashtea opened this issue 2 years ago • 2 comments
trafficstars

Hi, im currently building on Nostr trying to utilize NIP-28. Like the spec suggests i am using the e tag to differentiate between root and reply messages. I also add the Channel id as e tag.

Root message:

tags: [  
  ['t', <custom-tag>]
  ['e', <channel-id>, <relay>, 'root']
]

Reply:

tags: [
  ['t', <custom-tag>]
  ['e', <channel-id>, <relay>, 'reply'],
  ['p', <parent-id>]
]

How would i go about querying for only root or only reply messages belonging to the specific channel.

It seems like relays only accept ids as #e tag parameter. And even if they would accept it, the spec says that the list would be evaluated using OR so this would not work anyway.

const filter: Filter = {
      kinds: [42],
      '#t': [<costom-tag>],
      '#e': [<channel-id>]   // only works without 'root'
};

Is this a missing feature? Are relays not implementing this correctly? Or do i have to use another method to load this combination?

flashtea avatar Feb 20 '23 20:02 flashtea

See https://github.com/nostr-protocol/nips/issues/267 for an ongoing discussion on this topic

staab avatar Feb 20 '23 20:02 staab

You cannot query for only "root" or only "reply". The relays only index the e tags "value" (the nostr tag "value" is the index 1 entry of the tag). As a client developer, you should query with {#e: ["e1...","e2..."]} and then handle the returned events appropriately.

barkyq avatar Feb 21 '23 00:02 barkyq