From dd41ab839342637a15c07adb6fad5ae4abc7c567 Mon Sep 17 00:00:00 2001 From: Greg Heartsfield Date: Sat, 1 Jan 2022 15:22:36 -0600 Subject: [PATCH] nip01: allow multiple values for filter attributes. Fixes https://github.com/fiatjaf/nostr/issues/48 --- nips/01.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/nips/01.md b/nips/01.md index 127bce9..2c51985 100644 --- a/nips/01.md +++ b/nips/01.md @@ -61,10 +61,10 @@ Clients can send 3 types of messages, which must be JSON arrays, according to th ``` { - "id": , - "kind": - "#e": , - "#p": , + "ids": , + "kinds": , + "#e": , + "#p": , "since": , "until": , "authors": @@ -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 `` 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.