nip01: allow multiple values for filter attributes.

Fixes https://github.com/fiatjaf/nostr/issues/48
pull/55/head
Greg Heartsfield 2022-01-01 15:22:36 -06:00 zatwierdzone przez fiatjaf
rodzic 8601706ffc
commit dd41ab8393
1 zmienionych plików z 7 dodań i 5 usunięć

Wyświetl plik

@ -61,10 +61,10 @@ Clients can send 3 types of messages, which must be JSON arrays, according to th
```
{
"id": <the id of an event>,
"kind": <a kind number>
"#e": <an event id that is referenced in an "e" tag>,
"#p": <a pubkey that is referenced in a "p" tag>,
"ids": <a list of event ids>,
"kinds": <a list of a kind numbers>,
"#e": <a list of event ids that are referenced in an "e" tag>,
"#p": <a list of pubkeys that are referenced in a "p" tag>,
"since": <a timestamp, events must be newer than this to pass>,
"until": <a timestamp, events must be older than this to pass>,
"authors": <a list of pubkeys, the pubkey of an event must be one of these>
@ -73,7 +73,9 @@ Clients can send 3 types of messages, which must be JSON arrays, according to th
Upon receiving a `REQ` message, the relay MUST query its internal database and return events that match the filter, then store that filter and send again all future events it receives to that same websocket until the websocket is closed, the `CLOSE` event is received with the same `<id>` or a new `REQ` is sent using the same id, in which case it should overwrite the previous subscription.
All conditions of a filter that are specified must be valid for an event for it to pass the filter, i.e., multiple conditions are interpreted as `&&` conditions.
Filter attributes containing lists (such as `ids`, `kinds`, or `#e`) are JSON arrays with one or more values. At least one of the array's values must match the relevant field in an event for the condition itself to be considered a match. For scalar event attributes such as `kind`, the attribute from the event must be contained in the filter list. For tag attributes such as `#e`, where an event may have multiple values, the event and filter condition values must have at least one item in common.
All conditions of a filter that are specified must match for an event for it to pass the filter, i.e., multiple conditions are interpreted as `&&` conditions.
A `REQ` message may contain multiple filters. In this case events that match any of the filters are to be returned, i.e., multiple filters are to be interpreted as `||` conditions.