Skip to content

Commit c435b20

Browse files
committed
Add user query extension
1 parent 0f6ac0d commit c435b20

File tree

1 file changed

+116
-0
lines changed

1 file changed

+116
-0
lines changed

extensions/user-query.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
---
2+
title: User query
3+
layout: spec
4+
work-in-progress: true
5+
copyrights:
6+
-
7+
name: "Simon Ser"
8+
period: "2025"
9+
email: "contact@emersion.fr"
10+
---
11+
12+
## Notes for implementing work-in-progress version
13+
14+
This is a work-in-progress specification.
15+
16+
Software implementing this work-in-progress specification MUST NOT use the unprefixed `user-query` CAP name. Instead, implementations SHOULD use the `draft/user-query` CAP name to be interoperable with other software implementing a compatible work-in-progress version. The final version of the specification will use unprefixed CAP names.
17+
18+
## Description
19+
20+
This document describes the format of the `user-query` extension. This extension enables several clients of the same user connected to a server or bouncer to tell each other about which user queries (conversations between two users) are currently opened.
21+
22+
Some servers or bouncers remember the channels joined by a user and restore them after connection registration. This can be used by clients to synchronize channels, but doesn't work for user queries. If another client opens or closes a user query, there is no way for other clients to become aware of this action. This extension fills this gap.
23+
24+
The user queries opened by a user MUST NOT be disclosed to other users by the server without an explicit opt-in.
25+
26+
## Implementation
27+
28+
The `user-query` extension uses the `draft/user-query` capability, introduces a new `USERQUERY` command and a `draft/user-query-list` batch type.
29+
30+
The `draft/user-query` capability MUST be negotiated before using the `USERQUERY` command, and affects which messages are sent by the server as specified below.
31+
32+
### `USERQUERY LIST` sub-command
33+
34+
The `USERQUERY LIST` sub-command can be sent by clients to request a list of all opened user queries.
35+
36+
This sub-command has the following client syntax:
37+
38+
USERQUERY LIST
39+
40+
The server MUST reply to a successful `USERQUERY LIST` sub-command with a `draft/user-query-list` batch if the `batch` capability has been negotiated. The batch MUST contain any number of `USERQUERY LIST` replies with the following server syntax:
41+
42+
USERQUERY LIST <nick>
43+
44+
The `nick` parameter specifies a single nickname.
45+
46+
### `USERQUERY OPEN` sub-command
47+
48+
The `USERQUERY OPEN` sub-command can be sent by both clients and servers.
49+
50+
This sub-command has the following general syntax:
51+
52+
USERQUERY OPEN <nick>
53+
54+
The `nick` parameter specifies a single nickname.
55+
56+
When sent from a client, this sub-command signals to the server that the user has opened a query with the specified user. The server MUST reply to a successful `USERQUERY OPEN` client set command using a `USERQUERY OPEN` server sub-command, or using an error message.
57+
58+
When sent from a server, the `USERQUERY OPEN` command signals to the client that the user has a query opened with the specified user. If a `PRIVMSG` is sent to the user while no user query is opened, the server automatically opens a user query before dispatching the message. Servers SHOULD broadcast the `USERQUERY OPEN` notification to all clients connected under the same account.
59+
60+
TODO: interactions with MONITOR?
61+
62+
### `USERQUERY CLOSE` sub-command
63+
64+
The `USERQUERY CLOSE` sub-command can be sent by both clients and servers.
65+
66+
This sub-command has the following general syntax:
67+
68+
USERQUERY CLOSE <nick>
69+
70+
This command has the same syntax and behavior as `USERQUERY OPEN`, but indicates that the user has closed a user query.
71+
72+
### Errors and Warnings
73+
74+
Errors are returned using the standard replies syntax.
75+
76+
If the server receives a syntactically invalid `USERQUERY` command, e.g., an unknown subcommand, missing parameters, excess parameters, parameters that cannot be parsed, or invalid nickname, the `INVALID_PARAMS` error code SHOULD be returned:
77+
78+
FAIL USERQUERY <subcommand> INVALID_PARAMS [invalid_parameters] :Invalid parameters
79+
80+
If `USERQUERY OPEN` was sent while the user query was already opened, the `ALREADY_OPENED` error code MUST be returned. If `USERQUERY CLOSE` was sent while the user query was already closed, the `ALREADY_CLOSED` error code MUST be returned.
81+
82+
FAIL USERQUERY OPEN ALREADY_OPENED <nick> :This user query was already opened
83+
FAIL USERQUERY CLOSE ALREADY_CLOSED <nick> :This user query was already closed
84+
85+
If the user query cannot be opened or closed due to an error, the `INTERNAL_ERROR` error code SHOULD be returned.
86+
87+
FAIL USERQUERY <subcommand> INTERNAL_ERROR <nick> :The user query could not be opened or closed
88+
89+
### Implementation considerations
90+
91+
Servers SHOULD automatically close old user queries to prevent the list of user queries from growing unbounded. For instance, this can be achieved by closing old user queries when the number of opened user queries reaches a limit, or closing user queries after an expiration timeout.
92+
93+
### Examples
94+
95+
Querying the list of opened user queries:
96+
97+
C: USERQUERY LIST
98+
S: BATCH +foo draft/user-query-list
99+
S: @batch=foo USERQUERY LIST gustave
100+
S: @batch=foo USERQUERY LIST aline
101+
S: BATCH -foo
102+
103+
Opening a new user query:
104+
105+
C: USERQUERY OPEN sophie
106+
S: :irc.example.org USERQUERY OPEN sophie
107+
108+
Closing an existing user query:
109+
110+
C: USERQUERY CLOSE sophie
111+
S: :irc.example.org USERQUERY CLOSE sophie
112+
113+
The server automatically opens a user query when receiving a message:
114+
115+
S: :irc.example.org USERQUERY OPEN sophie
116+
S: :sophie!so@example.com PRIVMSG yannick :Hi there!

0 commit comments

Comments
 (0)