summary refs log tree commit diff
path: root/synapse/api
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-09-01 15:09:23 +0100
committerErik Johnston <erik@matrix.org>2015-09-01 15:47:30 +0100
commita88e16152f00719df152eaef31dcfd457c019293 (patch)
tree40dd70d96415463dbd6dff296e390aebd0034fc1 /synapse/api
parentMerge pull request #264 from matrix-org/markjh/syweb_on_pypi (diff)
downloadsynapse-a88e16152f00719df152eaef31dcfd457c019293.tar.xz
Add flag which disables federation of the room
Diffstat (limited to 'synapse/api')
-rw-r--r--synapse/api/auth.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/synapse/api/auth.py b/synapse/api/auth.py
index 65ee1452ce..f7cf17e433 100644
--- a/synapse/api/auth.py
+++ b/synapse/api/auth.py
@@ -20,7 +20,7 @@ from twisted.internet import defer
 from synapse.api.constants import EventTypes, Membership, JoinRules
 from synapse.api.errors import AuthError, Codes, SynapseError
 from synapse.util.logutils import log_function
-from synapse.types import UserID
+from synapse.types import EventID, RoomID, UserID
 
 import logging
 
@@ -65,6 +65,15 @@ class Auth(object):
                 # FIXME
                 return True
 
+            creating_domain = RoomID.from_string(event.room_id).domain
+            originating_domain = EventID.from_string(event.event_id).domain
+            if creating_domain != originating_domain:
+                if not self.can_federate(event, auth_events):
+                    raise SynapseError(
+                        403,
+                        "This room has been marked as unfederatable."
+                    )
+
             # FIXME: Temp hack
             if event.type == EventTypes.Aliases:
                 return True
@@ -153,6 +162,11 @@ class Auth(object):
                 user_id, room_id, repr(member)
             ))
 
+    def can_federate(self, event, auth_events):
+        creation_event = auth_events.get((EventTypes.Create, ""))
+
+        return creation_event.content.get("m.federate", True) is True
+
     @log_function
     def is_membership_change_allowed(self, event, auth_events):
         membership = event.content["membership"]