Przeglądaj źródła

Update the error code for duplicate annotation (#15075)

tags/v1.78.0rc1
Richard van der Hoff 1 rok temu
committed by GitHub
rodzic
commit
5febf88b6c
Nie znaleziono w bazie danych klucza dla tego podpisu ID klucza GPG: 4AEE18F83AFDEB23
3 zmienionych plików z 11 dodań i 1 usunięć
  1. +2
    -0
      changelog.d/15075.feature
  2. +4
    -0
      synapse/api/errors.py
  3. +5
    -1
      synapse/handlers/message.py

+ 2
- 0
changelog.d/15075.feature Wyświetl plik

@@ -0,0 +1,2 @@
Update the error code returned when user sends a duplicate annotation.


+ 4
- 0
synapse/api/errors.py Wyświetl plik

@@ -108,6 +108,10 @@ class Codes(str, Enum):

USER_AWAITING_APPROVAL = "ORG.MATRIX.MSC3866_USER_AWAITING_APPROVAL"

# Attempt to send a second annotation with the same event type & annotation key
# MSC2677
DUPLICATE_ANNOTATION = "M_DUPLICATE_ANNOTATION"


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


+ 5
- 1
synapse/handlers/message.py Wyświetl plik

@@ -1337,7 +1337,11 @@ class EventCreationHandler:
relation.parent_id, event.type, aggregation_key, event.sender
)
if already_exists:
raise SynapseError(400, "Can't send same reaction twice")
raise SynapseError(
400,
"Can't send same reaction twice",
errcode=Codes.DUPLICATE_ANNOTATION,
)

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


Ładowanie…
Anuluj
Zapisz