Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 5febf88

Browse files
authored
Update the error code for duplicate annotation (#15075)
1 parent 06ba710 commit 5febf88

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

changelog.d/15075.feature

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Update the error code returned when user sends a duplicate annotation.
2+

synapse/api/errors.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ class Codes(str, Enum):
108108

109109
USER_AWAITING_APPROVAL = "ORG.MATRIX.MSC3866_USER_AWAITING_APPROVAL"
110110

111+
# Attempt to send a second annotation with the same event type & annotation key
112+
# MSC2677
113+
DUPLICATE_ANNOTATION = "M_DUPLICATE_ANNOTATION"
114+
111115

112116
class CodeMessageException(RuntimeError):
113117
"""An exception with integer code and message string attributes.

synapse/handlers/message.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1337,7 +1337,11 @@ async def _validate_event_relation(self, event: EventBase) -> None:
13371337
relation.parent_id, event.type, aggregation_key, event.sender
13381338
)
13391339
if already_exists:
1340-
raise SynapseError(400, "Can't send same reaction twice")
1340+
raise SynapseError(
1341+
400,
1342+
"Can't send same reaction twice",
1343+
errcode=Codes.DUPLICATE_ANNOTATION,
1344+
)
13411345

13421346
# Don't attempt to start a thread if the parent event is a relation.
13431347
elif relation.rel_type == RelationTypes.THREAD:

0 commit comments

Comments
 (0)