check / check (push) Waiting to run
Rewrite the description of the JSON Schema directory from scratch, without tables, as a reader of the files needs it. Describe the envelope as the server sends it: the reply name in `command` and the number in `code`. Drop the federation section, which describes nothing the server does. List where each schema file disagrees with the server, so a reader is not misled; the files themselves are unchanged. Part of #190. Model: fable-5-1
Message schemas
This directory holds JSON Schema files (draft 2020-12) for the messages that the
neoirc HTTP API carries. message.json describes the envelope every message
uses. commands/ holds one file per IRC command and numerics/ one file per
numeric reply. README.md at the repository root documents every command, reply
and field.
The envelope
Every message is one JSON object with these fields:
command: the IRC command name, such asPRIVMSG, or the name of a numeric reply, such asRPL_WELCOME. Always present.code: the number of a numeric reply, such as1forRPL_WELCOME. Absent on other messages.id: the message's UUID, assigned by the server.from: the sender's nick, or the server name on a server message.to: the target: a channel name starting with#, or a nick.params: further positional parameters, as an array of strings.KICKand many numeric replies use it.body: an array of strings, one per line of text. It is never a bare string.ts: when the server stored the message, in RFC 3339 form, in UTC.meta: an object of extra data, such as a hashcash stamp inmeta.hashcash. The server stores and relays it as it is.
Two IRC lines and their JSON form:
IRC: :alice PRIVMSG #general :hello world
JSON: {"command": "PRIVMSG", "from": "alice", "to": "#general", "body": ["hello world"]}
IRC: :neoirc 353 alice = #general :@op1!op1@host1 alice!alice@host2
JSON: {"command": "RPL_NAMREPLY", "code": 353, "from": "neoirc", "to": "alice",
"params": ["=", "#general"], "body": ["@op1!op1@host1 alice!alice@host2"]}
A body with two strings is a two-line message:
{"command": "PRIVMSG", "to": "#general", "body": ["line one", "line two"]}
Files
Commands, in commands/:
PRIVMSG.json: a message to a channel or a user.NOTICE.json: a notice. A client must not answer a notice automatically.JOIN.json: a user joined a channel.PART.json: a user left a channel.QUIT.json: a user left the server.NICK.json: a user changed nick.TOPIC.json: a channel topic was set.MODE.json: a channel mode was changed.KICK.json: a channel operator removed a user from a channel.PING.jsonandPONG.json: keepalive.PUBKEY.json: a public signing key announcement. The server does not have this command and answers it withERR_UNKNOWNCOMMAND(421).
Numeric replies, in numerics/:
001.jsonRPL_WELCOME,002.jsonRPL_YOURHOST,003.jsonRPL_CREATEDand004.jsonRPL_MYINFO: the welcome replies.322.jsonRPL_LISTand323.jsonRPL_LISTEND: the channel list.332.jsonRPL_TOPIC: a channel's topic.353.jsonRPL_NAMREPLYand366.jsonRPL_ENDOFNAMES: a channel's member list.372.jsonRPL_MOTD,375.jsonRPL_MOTDSTARTand376.jsonRPL_ENDOFMOTD: the message of the day.401.jsonERR_NOSUCHNICK: no such nick.403.jsonERR_NOSUCHCHANNEL: no such channel.433.jsonERR_NICKNAMEINUSE: the nick is taken.442.jsonERR_NOTONCHANNEL: the user is not on that channel.482.jsonERR_CHANOPRIVSNEEDED: the user is not a channel operator.
Where the files differ from the server
Where a schema file and the server disagree, the server is right:
- The numeric files put the three-digit code in
commandand have nocodefield. The server puts the reply's name incommandand its number incode. 353.jsonsaysbodylists nicks. Over the HTTP API the server lists hostmasks, such as@op1!op1@host1.MODE.jsonputs the mode change inparams. The server puts it inbody: one string such as"+o bob", or the change and its value as two strings, such as"+k"and"secret".JOIN.jsonhas nobody. The server'sJOINevent repeats the channel name inbody.PING.jsondescribes a token inbody. The server ignores the body of aPINGand answers the HTTP request itself with{"command": "PONG", "from": "<server name>"}.TOPIC.jsonsays aTOPICwithout a body queries the topic. Over the HTTP API aTOPICwithout a body getsERR_NEEDMOREPARAMS(461).PUBKEY.jsondescribes a command the server does not have.