Skip to content

Commit 1b3a088

Browse files
committed
MSC4305 (thread subscriptions): init
1 parent 5beaf2e commit 1b3a088

File tree

1 file changed

+200
-0
lines changed

1 file changed

+200
-0
lines changed
Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
MSC4305: Thread Subscriptions
2+
=====
3+
4+
## Background and Summary
5+
6+
Threads were introduced in [version 1.4 of the Matrix Specification](https://spec.matrix.org/v1.13/changelog/v1.4/) as a way to isolate conversations in a room, making it easier for users to track specific conversations that they care about (and ignore those that they do not).
7+
8+
Thus far, there has been no good way for users to ensure that they see new messages in only the threads that they care about. The current rules only allow expressing one of two choices: users and their clients can either watch all threads, or ignore all threads.
9+
As a result, the user is either being presented with unwanted information (misusing their attention), or they risk missing important messages.
10+
11+
This proposal introduces a new mechanism, Thread Subscriptions, as a first-class way for users to signal which threads they care about.
12+
13+
We then add a new push rule so that users can receive push notifications only for threads that they care about.
14+
15+
16+
## Proposal
17+
18+
This proposal consists of three main parts:
19+
- 3 simple endpoints for subscribing to and unsubscribing from threads;
20+
- new prescribed client behaviour when the user is mentioned in a thread; and
21+
- a new push rule (including a new push rule condition) that prevents notifying about threads that the user has not subscribed to.
22+
23+
24+
### New Endpoints
25+
26+
#### Subscribing to a thread
27+
28+
```
29+
PUT /_matrix/client/v1/rooms/{roomId}/thread/{eventId}/subscription
30+
```
31+
32+
with request body:
33+
34+
```jsonc
35+
{
36+
// Whether the subscription was made automatically
37+
// by a client, not by manual user choice.
38+
"automatic": true
39+
}
40+
```
41+
42+
Returns 200 with empty body `{}`.
43+
44+
If the thread does not exist, or if the user does not have access to it, returns 404/`M_NOT_FOUND`.
45+
46+
If the thread is already subscribed, then the subscription remains and:
47+
48+
- if `automatic` is `false`, the thread is marked as manually-subscribed, even if the existing subscription has it marked as automatically subscribed. (In other words, manual subscriptions take precedence over automatic subscriptions.)
49+
50+
51+
#### Unsubscribing from a thread
52+
```
53+
DELETE /_matrix/client/v1/rooms/{roomId}/thread/{eventId}/subscription
54+
```
55+
56+
Returns 200 with empty body `{}`.
57+
58+
If the thread was not subscribed, returns 200 with empty body `{}` for idempotence.
59+
60+
If the thread does not exist, or is inaccessible, returns 404/`M_NOT_FOUND`.
61+
62+
63+
#### Retrieving thread subscription
64+
65+
```
66+
GET /_matrix/client/v1/rooms/{roomId}/thread/{eventId}/subscription
67+
68+
{"automatic": true}
69+
```
70+
71+
Retrieves the thread subscription for a given thread.
72+
73+
On success (200), returns:
74+
75+
```jsonc
76+
{
77+
// Whether the subscription was automatically made or not
78+
"automatic": true
79+
}
80+
```
81+
82+
If there is no subscription to that thread, or the thread does not exist, or the thread is inaccessible, returns 404/`M_NOT_FOUND`.
83+
84+
85+
### New Client Behaviour: subscribe on mention
86+
87+
When a user is mentioned in a thread (by another user — the *mentioning user*), the user's client should perform an automatic subscription to that thread using `PUT /subscription` with `{"automatic": true}`.
88+
89+
The server does not perform this action on the client's behalf, principally because the server is not able to detect mentions in encrypted rooms.
90+
91+
If the client is already aware of the user being subscribed to the thread, then making a `PUT /subscription` request is not necessary.
92+
93+
If the mentioning user is banned, the automatic thread subscription should not occur.
94+
95+
#### Reversal of automatic subscriptions
96+
97+
If an automatic thread subscription occurs and the mentioning user is subsequently banned, then:
98+
99+
- the thread subscription should be reversed,
100+
- provided that there aren't any other mentions by other, non-banned, users that would have caused the same automatic subscription.
101+
102+
When a client becomes aware of a banned user in a room, it may need to backpaginate thread history to determine whether there are any threads whose automatic subscriptions should be reversed, or to determine if there are any other qualifying mentions that would obviate the need to reverse automatic subscriptions.
103+
104+
For efficiency reasons, clients may limit the depth of this backpagination with an implementation-defined recency limit, owing to the observation that abuse is usually cleaned up shortly after it occurs.
105+
106+
### New Push Rules
107+
108+
As motivation, we want threads to have the following notification semantics:
109+
110+
- Messages in unsubscribed threads should not count as activity at all; as a user, I do not want to see the room as unread because there are new messages in an unsubscribed thread.
111+
- Exceptions: if the user is mentioned, this should generate a notification as usual. (The push notification thus generated is also useful for the client to realise it needs to create an automatic thread subscription.)
112+
- Messages in subscribed threads should always count as a notification, and the (effective) room notification settings should not matter at all. E.g. the room can be muted, but if I, as a user, am subscribed to a thread, I still want to get a notification for new messages in that thread. If I do not want that, then I will unsubscribe.
113+
114+
To achieve this, we propose the addition of two new push rules:
115+
116+
1. an `override` push rule, called `.m.rule.unsubscribed_thread`, at the end of the override list. This rule causes events in unsubscribed threads to skip notification processing without generating a notification.
117+
The rule occurs after mention-specific rules, meaning that mentions continue to generate notifications.
118+
**TODO how do we deal with keyword mentions**
119+
```jsonc
120+
{
121+
"rule_id": ".m.rule.unsubscribed_thread",
122+
"default": true,
123+
"enabled": true,
124+
"conditions": [
125+
{
126+
"kind": "thread_subscription",
127+
"subscribed": false
128+
}
129+
],
130+
"actions": []
131+
}
132+
```
133+
2. an `underride` push rule, called `.m.rule.subscribed_thread`, at the beginning of the underride list. This rule causes events in subscribed threads to generate notifications.
134+
```jsonc
135+
{
136+
"rule_id": ".m.rule.subscribed_thread",
137+
"default": true,
138+
"enabled": true,
139+
"conditions": [
140+
{
141+
"kind": "thread_subscription",
142+
"subscribed": true
143+
}
144+
],
145+
"actions": [
146+
"notify",
147+
{
148+
"set_tweak": "sound",
149+
"value": "default"
150+
}
151+
]
152+
}
153+
```
154+
155+
These push rules use a new push condition `thread_subscription`, which takes an argument `subscribed` (boolean).
156+
The `thread_subscription` push condition is satisfied if and only if all the following hold:
157+
1. the event, which we are running push rules for, is part of a thread.
158+
2. the user is subscribed to the thread (`subscribed` = `true`) or is not subscribed to the thread (`subscribed` = `false`).
159+
160+
## Limitations
161+
162+
- Users will not have enough granularity to subscribe to threads in a way that lets them keep track of threads (being able to 'catch up' through some mechanism in their client) without also getting notifications for them, except by disabling ALL thread subscription notifications altogether.
163+
- There is precedent for this granularity in the popular forum software *Discourse*, but the author is not aware of Instant Messaging software with this granularity.
164+
- With that said, this could be feasibly extended by a later MSC with no apparent issues.
165+
166+
## Alternatives
167+
168+
- Clients could maintain thread subscription settings in Room Account Data, as a map from event ID to the subscription settings.
169+
- This would be inefficient by requiring the entire subscription set for an entire room to be transferred at once, for example in Sliding Sync.
170+
- This would make subscriptions vulnerable to Read-Modify-Write race conditions (though this could be addressed with extensions to the Room Account Data APIs).
171+
- Clients could maintain their thread subscription settings in their global Account Data, but this seems to be strictly worse than doing so in Room Account Data.
172+
173+
## Security considerations
174+
175+
- Abuse of 'subscribe on mention', particularly in public rooms
176+
- Malicious users can be ignored by the user, to stop the subscribe on mention behaviour.
177+
- Users can disable notifications entirely for rooms.
178+
- Room moderators can take action against malicious users abusing the feature.
179+
- If no room moderators are protecting the user, the user can of course also leave the room.
180+
181+
## Notes to Client Implementors
182+
183+
## Notes to Server Implementors
184+
185+
- Since clients will be automatically updating the Thread Subscription Settings when their user is mentioned, server implementations should be ready to handle concurrent updates by multiple of the user's devices/clients when they are online at the same time.
186+
187+
## Unstable prefix
188+
189+
TODO!
190+
191+
192+
## Dependencies
193+
194+
- no dependencies on other pending MSCs
195+
196+
## Dependents
197+
198+
This proposal is known to be depended upon by the following MSCs:
199+
200+
- <a name="ref-ss-ext"></a>\<proto-MSC for Thread Subscriptions extension to Sliding Sync\>

0 commit comments

Comments
 (0)