summary refs log tree commit diff
path: root/synapse/handlers/message.py
diff options
context:
space:
mode:
authorShay <hillerys@element.io>2024-03-19 10:52:53 -0700
committerGitHub <noreply@github.com>2024-03-19 17:52:53 +0000
commit8fb5b0f335b3dc54962aea102c71a7e449497487 (patch)
tree698b5e92f822198a51131108a15fe61ac1501358 /synapse/handlers/message.py
parentBump pydantic from 2.6.0 to 2.6.4 (#17004) (diff)
downloadsynapse-8fb5b0f335b3dc54962aea102c71a7e449497487.tar.xz
Improve event validation (#16908)
As the title states.
Diffstat (limited to 'synapse/handlers/message.py')
-rw-r--r--synapse/handlers/message.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py
index 0ce6eeee15..ccaa5508ff 100644
--- a/synapse/handlers/message.py
+++ b/synapse/handlers/message.py
@@ -34,6 +34,7 @@ from synapse.api.constants import (
     EventTypes,
     GuestAccess,
     HistoryVisibility,
+    JoinRules,
     Membership,
     RelationTypes,
     UserTypes,
@@ -1325,6 +1326,18 @@ class EventCreationHandler:
 
         self.validator.validate_new(event, self.config)
         await self._validate_event_relation(event)
+
+        if event.type == EventTypes.CallInvite:
+            room_id = event.room_id
+            room_info = await self.store.get_room_with_stats(room_id)
+            assert room_info is not None
+
+            if room_info.join_rules == JoinRules.PUBLIC:
+                raise SynapseError(
+                    403,
+                    "Call invites are not allowed in public rooms.",
+                    Codes.FORBIDDEN,
+                )
         logger.debug("Created event %s", event.event_id)
 
         return event, context