Skip to content

Commit 43c374e

Browse files
clokepsumnerevansrichvdhanoadragon453
authored
MSC3958: Suppress notifications from message edits (#3958)
* Suppress message edits. * Fix typo. Co-authored-by: Sumner Evans <me@sumnerevans.com> * Add @room. * Match MSC title to PR. * Add a potential issue. * Clarify rule placement. * Change link text. Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> * Fix typo. Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> * Add a note about mobile clients. * Update from anoa's feedback. * Updates for Matrix 1.7 * Update more spec links. * Minor clarifications. Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> * Add downside about "all messages" * Clarify again that this *does* work with all messages. --------- Co-authored-by: Sumner Evans <me@sumnerevans.com> Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
1 parent 7ad992a commit 43c374e

File tree

1 file changed

+142
-0
lines changed

1 file changed

+142
-0
lines changed
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
# MSC3958: Suppress notifications from message edits
2+
3+
[Event replacement](https://spec.matrix.org/v1.7/client-server-api/#event-replacements)
4+
(more commonly known as message edits) signals that a message is intended to
5+
be replaced with new content.
6+
7+
This works well for fixing typos or other minor correction, but can cause
8+
spurious notifications if the event mentions a user's display name / localpart or
9+
if it includes `@room` (which is particularly bad in large rooms as every user
10+
is re-notified). This contributes to notification fatigue as the additional
11+
notifications contain no new information.
12+
13+
Additionally for users which have a room set to "all messages" then every event
14+
edit results in an additional notification.[^1]
15+
16+
## Proposal
17+
18+
A new default push rule is added to suppress notifications due to [edits](https://spec.matrix.org/v1.7/client-server-api/#event-replacements).
19+
20+
```json
21+
{
22+
"rule_id": ".m.rule.suppress_edits",
23+
"default": true,
24+
"enabled": true,
25+
"conditions": [
26+
{
27+
"kind": "event_property_is",
28+
"key": "content.m\\.relates_to.rel_type",
29+
"value": "m.replace"
30+
}
31+
],
32+
"actions": []
33+
}
34+
```
35+
36+
This rule should be placed after the [`.m.rule.room.server_acl` rule](https://spec.matrix.org/v1.7/client-server-api/#default-override-rules)
37+
as the last override rule.
38+
39+
It would match events such as those given in [event replacements](https://spec.matrix.org/v1.7/client-server-api/#event-replacements)
40+
portion of the spec:
41+
42+
```json5
43+
{
44+
"type": "m.room.message",
45+
"content": {
46+
"body": "* Hello! My name is bar",
47+
"msgtype": "m.text",
48+
"m.new_content": {
49+
"body": "Hello! My name is bar",
50+
"msgtype": "m.text"
51+
},
52+
"m.relates_to": {
53+
"rel_type": "m.replace",
54+
"event_id": "$some_event_id"
55+
}
56+
},
57+
// ... other fields required by events
58+
}
59+
```
60+
61+
With the [updated mentions behavior in Matrix 1.7](https://spec.matrix.org/v1.7/client-server-api/#user-and-room-mentions),
62+
this would allow the [`.m.rule.is_user_mention`](https://spec.matrix.org/v1.7/client-server-api/#_m_rule_is_user_mention)
63+
and the [`.m.rule.is_room_mention`](https://spec.matrix.org/v1.7/client-server-api/#_m_rule_is_room_mention)
64+
rules to continue matching, even for edited events, while suppressing notifications
65+
from other edits.
66+
67+
Some users may be depending on notifications of edits. If a user would like to
68+
revert to the old behavior they can disable the `.m.rule.suppress_edits` push rule.
69+
70+
## Potential issues
71+
72+
### Edits of invites and tombstones
73+
74+
The [`.m.rule.invite_for_me` and `.m.rule.tombstone`](https://spec.matrix.org/v1.7/client-server-api/#default-override-rules)
75+
rules may still cause spurious notifications if events which match those rules
76+
are edited. Both of those are state events and
77+
[not subject to valid edits](https://spec.matrix.org/v1.7/client-server-api/#validity-of-replacement-events).
78+
79+
### Keeping notifications up-to-date
80+
81+
Mobile clients currently depend on the push notifications of edited events to update the
82+
text of on-screen notifications. The proposed push rule would result in mobile clients no
83+
longer receiving these edits; but showing slightly outdated text on a notification screen. That
84+
is only a minor impact and it would be better to separate when (& why) we send pushes vs.
85+
when we generate notifications.
86+
87+
### Suppression of notifications to a new keyword
88+
89+
If an event is edited and the new event (but not the original event) matches a keyword
90+
then the notification would erroneously be suppressed.
91+
92+
## Alternatives
93+
94+
An alternative solution would be to add a push rule with no actions and a condition to
95+
check whether a notification was generated for the original message.
96+
97+
This would be placed as an override rule before the `.m.rule.contains_display_name`
98+
and the `.m.rule.roomnotif` [push rules](https://spec.matrix.org/v1.7/client-server-api/#push-rules).
99+
100+
This would suppress duplicate notifications, while still allow for new notifications due
101+
to new mentions or keywords changing.
102+
103+
## Security considerations
104+
105+
None forseen.
106+
107+
## Future extensions
108+
109+
If message edits by other senders were allowed than it would be useful to
110+
know when your own message was edited, but this
111+
[is not currently allowed](https://spec.matrix.org/v1.7/client-server-api/#validity-of-replacement-events).
112+
A future MSC to define this behavior should take into account notifying
113+
users in this situation.
114+
115+
## Unstable prefix
116+
117+
The unstable prefix of `.org.matrix.msc3958.suppress_edits` should be used in place of
118+
`.m.rule.suppress_edits`.
119+
120+
A previous version of this MSC used `.com.beeper.suppress_edits` with a different condition
121+
(which should match the same events), but different rule placement.
122+
123+
## Dependencies
124+
125+
N/A
126+
127+
<!-- Footnotes below -->
128+
129+
[^1]: A room can be configured to be notify for "all messages" by creating a [room-specific push rule](https://spec.matrix.org/v1.7/client-server-api/#push-rules)
130+
with an `rule_id` of the room ID & has `actions` set to "notify" , e.g.:
131+
132+
```json
133+
{
134+
"rule_id" : "!abcdef:example.com",
135+
"default" : false,
136+
"enabled" : true,
137+
"actions" : ["notify"]
138+
}
139+
```
140+
141+
See the [Element Web](https://github.com/matrix-org/matrix-react-sdk/blob/da7aa4055e04f291be9b5141b704bd12aec03d0c/src/RoomNotifs.ts#L162-L170)
142+
implementation.

0 commit comments

Comments
 (0)