Skip to content

Commit d6789c2

Browse files
authored
Batch types, parameters, key names, registration (#566)
* Added target parameter to metadata batch type * Added metadata-subs batch type * Tightened key name restrictions * Clarifications on connection registration behaviour * Various other clarifications and examples
1 parent ea74ace commit d6789c2

File tree

1 file changed

+48
-15
lines changed

1 file changed

+48
-15
lines changed

extensions/metadata.md

Lines changed: 48 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ On joining a channel, users will get the channel's current metadata sent to them
6767

6868
## Relation with other specifications
6969

70-
This specification depends on the [`batch`](../extensions/batch.html) capability which MUST be negotiated to use ``draft/metadata-2``. The order of capability negotiation is not significant and MUST not be enforced.
70+
This specification depends on the [`batch`](../extensions/batch.html) capability which MUST be negotiated to use ``draft/metadata-2``. The order of capability negotiation is not significant and MUST NOT be enforced.
7171

7272
This specification also uses the [standard replies](../extensions/standard-replies.html) framework.
7373

@@ -82,7 +82,7 @@ The ABNF format of the `metadata` capability is:
8282
capability ::= 'metadata' ['=' tokens]
8383
tokens ::= token [',' token]*
8484
token ::= key ['=' value]
85-
key ::= <sequence of a-zA-Z0-9_./:->
85+
key ::= <sequence of one or more a-z0-9_./->
8686
value ::= <utf8>
8787

8888
These are the defined tokens:
@@ -96,23 +96,25 @@ Clients MUST silently ignore any unknown tokens.
9696

9797
## Keys and Values
9898

99-
Key names follow this grammar:
99+
Key names are restricted to the ranges `a-z`, `0-9`, and `_./-`. The empty string is an invalid value.
100100

101-
be restricted to the ranges `A-Z`, `a-z`, `0-9`, and `_./:-` and are case-insensitive. Key names MUST NOT start with a colon (`:`).
102-
They follow [the same rules as message tag names](../extensions/message-tags.html#rules-for-naming-message-tags).
103-
104-
Values can take any form, but MUST be encoded using UTF-8.
101+
Values can take any form, but MUST be encoded using UTF-8. The empty string is a valid value.
105102

106103
The expected handling of individual metadata keys SHOULD be [defined and listed in the IRCv3 extension registry](../registry.html).
107104

108-
## Batch type
105+
## Batch types
106+
107+
This specification adds the `metadata` and `metadata-subs` batch types.
109108

110-
This specification adds the `metadata` batch type.
109+
The `metadata` batch type MUST be sent to clients under the following circumstances:
111110

112-
This batch MUST be sent to clients on connection and as reply to successful `METADATA GET`, `METADATA LIST`, and `METADATA SYNC` subcommands.
111+
* To enclose 0 or more `761 RPL_KEYVALUE` responses to `METADATA GET` or `METADATA LIST`
112+
* To enclose 0 or more `METADATA` commands in response to `METADATA SYNC`
113+
* To enclose 0 or more `METADATA` commands in response to a metadata-capable client completing connection registration and receiving its own metadata
113114

114-
This batch type does not take any parameter, and clients MUST ignore them if any.
115+
It takes one parameter and clients MUST ignore extra parameters. This parameter contains the target for which the metadata was requested, allowing the client to correctly process empty batches. Since a batch sent in response to `METADATA SYNC` on a channel may contain metadata on users as well as the channel itself, clients MUST NOT assume that all metadata in the batch applies to the entity referenced in the batch parameter.
115116

117+
The `metadata-subs` batch type MUST be sent to clients in response to the `SUBS` subcommand, to enclose 0 or more `772 RPL_METADATASUBS` replies. It takes no parameters and clients MUST ignore any parameters sent.
116118

117119
## Notifications
118120

@@ -135,7 +137,7 @@ If a channel/user the client is receiving updates for changes one of the keys th
135137

136138
Here are additional cases where clients will receive `METADATA` messages:
137139

138-
- Upon requesting the `metadata` capability, clients receive their non-transient metadata (for example, metadata stored by the server or by services) in a `metadata` batch with their own nick as target. If none exists, the server MUST send an empty batch instead.
140+
- If the `metadata` capability was negotiated during connection registration, clients receive their current metadata (any metadata stored by the server or by services, plus any metadata set by the client during connection registration via `before-connect`) in a `metadata` batch with their own nick as target as part of the registration burst, i.e. before `RPL_ENDOFMOTD` or `ERR_NOMOTD`. If none exists, the server MUST send an empty batch instead.
139141
- When subscribing to a key, clients SHOULD receive the current value of that key for channels/users they are receiving updates for.
140142
- Clients SHOULD receive the current values of keys they are subscribed to when they [`MONITOR`](https://ircv3.net/specs/extensions/monitor.html#monitor-command) a user, or when one of their monitored users comes online.
141143

@@ -171,7 +173,7 @@ The format of the `METADATA` server message is:
171173

172174
`Subcommand` is one of the subcommands listed below. The allowed params are described in each subcommand description.
173175

174-
Clients MAY use this command during connection registration if the server advertises the `before-connect` token.
176+
Clients MAY use this command during connection registration if the server advertises the `before-connect` token. Clients that have not completed connection registration MUST use `*` to target themselves, since they have not been assigned a nickname, even if they sent a `NICK` command.
175177

176178
### METADATA GET
177179

@@ -231,7 +233,7 @@ This new value MAY differ from the one sent by the client.
231233

232234
METADATA <Target> CLEAR
233235

234-
This subcommand removes all metadata from the target, equivalently to using `METADATA SET` on all currently-set keys with an empty value.
236+
This subcommand removes all metadata from the target, equivalently to using `METADATA SET` on all currently-set keys with no value.
235237

236238
If the user cannot clear keys on the given target, the server responds with `FAIL METADATA KEY_NO_PERMISSION` with an asterisk (`*`) in the `<Key>` field and fails the request.
237239

@@ -286,7 +288,7 @@ Once the server is finished processing keys, it responds with:
286288

287289
This subcommand returns which keys the client is currently subscribed to.
288290

289-
The server responds with zero or more `RPL_METADATASUBS` numerics. The server MAY return the keys in any order. The server MUST NOT list the same key multiple times in a response to this subcommand.
291+
The server responds with a `metadata-subs` batch containing zero or more `RPL_METADATASUBS` numerics. The server MAY return the keys in any order. The server MUST NOT list the same key multiple times in a response to this subcommand.
290292

291293
### METADATA SYNC
292294

@@ -706,6 +708,37 @@ Twice:
706708

707709
-----
708710

711+
### Setting keys and subscribing with `before-connect`
712+
713+
C: CAP LS 302
714+
S: :metadata.test CAP * LS :batch message-tags draft/metadata-2=before-connect,max-subs=100,max-keys=100
715+
C: CAP REQ :batch message-tags draft/metadata-2
716+
S: :metadata.test CAP * ACK :batch message-tags draft/metadata-2
717+
C: METADATA * SUB display-name
718+
S: :metadata.test 770 * display-name
719+
C: METADATA * SET display-name :a b c
720+
S: :metadata.test 761 * * display-name * :a b c
721+
C: NICK abc
722+
C: USER u s e r
723+
C: CAP END
724+
S: :metadata.test 001 abc :Welcome to the MetadataTesting IRC Network abc
725+
S: [redacted registration burst messages]
726+
S: :metadata.test BATCH +1 metadata
727+
S: @batch=1 :metadata.test METADATA abc display-name * :a b c
728+
S: :metadata.test BATCH -1
729+
S: [redacted registration burst messages]
730+
S: :metadata.test 376 abc :End of MOTD command
731+
C: METADATA * LIST
732+
S: :metadata.test BATCH +2 metadata
733+
S: @batch=2 :metadata.test 761 abc abc display-name * :a b c
734+
S: :metadata.test BATCH -2
735+
C: METADATA * SUBS
736+
S: :metadata.test BATCH +3 metadata-subs
737+
S: @batch=3 :metadata.test 772 abc display-name
738+
S: :metadata.test BATCH -3
739+
740+
-----
741+
709742
### Non-normative examples
710743

711744
The following examples describe how an implementation might use certain features.

0 commit comments

Comments
 (0)