Additional constants for EDU types. (#12884)
Instead of hard-coding strings in many places.
2 files changed, 9 insertions, 3 deletions
diff --git a/synapse/api/constants.py b/synapse/api/constants.py
index 4a0552e7e5..f03fdd6dae 100644
--- a/synapse/api/constants.py
+++ b/synapse/api/constants.py
@@ -137,7 +137,13 @@ class DeviceKeyAlgorithms:
class EduTypes:
- Presence: Final = "m.presence"
+ PRESENCE: Final = "m.presence"
+ TYPING: Final = "m.typing"
+ RECEIPT: Final = "m.receipt"
+ DEVICE_LIST_UPDATE: Final = "m.device_list_update"
+ SIGNING_KEY_UPDATE: Final = "m.signing_key_update"
+ UNSTABLE_SIGNING_KEY_UPDATE: Final = "org.matrix.signing_key_update"
+ DIRECT_TO_DEVICE: Final = "m.direct_to_device"
class RejectedReason:
diff --git a/synapse/api/filtering.py b/synapse/api/filtering.py
index b91ce06de7..b007147519 100644
--- a/synapse/api/filtering.py
+++ b/synapse/api/filtering.py
@@ -33,7 +33,7 @@ from typing import (
import jsonschema
from jsonschema import FormatChecker
-from synapse.api.constants import EventContentFields
+from synapse.api.constants import EduTypes, EventContentFields
from synapse.api.errors import SynapseError
from synapse.api.presence import UserPresenceState
from synapse.events import EventBase
@@ -347,7 +347,7 @@ class Filter:
user_id = event.user_id
field_matchers = {
"senders": lambda v: user_id == v,
- "types": lambda v: "m.presence" == v,
+ "types": lambda v: EduTypes.PRESENCE == v,
}
return self._check_fields(field_matchers)
else:
|