summary refs log tree commit diff
path: root/synapse/api
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-12-03 16:07:21 +0000
committerErik Johnston <erik@matrix.org>2014-12-03 16:07:21 +0000
commit75b4329aaad400abcee4b23e9c88ff845e0d73c7 (patch)
treeb2e947686ad0cf166e9dbcd8a5a3ac50555f862f /synapse/api
parentMerge branch 'develop' of github.com:matrix-org/synapse into events_refactor (diff)
downloadsynapse-75b4329aaad400abcee4b23e9c88ff845e0d73c7.tar.xz
WIP for new way of managing events.
Diffstat (limited to 'synapse/api')
-rw-r--r--synapse/api/auth.py13
-rw-r--r--synapse/api/constants.py9
2 files changed, 16 insertions, 6 deletions
diff --git a/synapse/api/auth.py b/synapse/api/auth.py
index 2b0475543d..50d4be113f 100644
--- a/synapse/api/auth.py
+++ b/synapse/api/auth.py
@@ -351,7 +351,7 @@ class Auth(object):
         return self.store.is_server_admin(user)
 
     @defer.inlineCallbacks
-    def add_auth_events(self, event):
+    def get_auth_events(self, event, current_state):
         if event.type == RoomCreateEvent.TYPE:
             event.auth_events = []
             return
@@ -359,19 +359,19 @@ class Auth(object):
         auth_events = []
 
         key = (RoomPowerLevelsEvent.TYPE, "", )
-        power_level_event = event.old_state_events.get(key)
+        power_level_event = current_state.get(key)
 
         if power_level_event:
             auth_events.append(power_level_event.event_id)
 
         key = (RoomJoinRulesEvent.TYPE, "", )
-        join_rule_event = event.old_state_events.get(key)
+        join_rule_event = current_state.get(key)
 
         key = (RoomMemberEvent.TYPE, event.user_id, )
-        member_event = event.old_state_events.get(key)
+        member_event = current_state.get(key)
 
         key = (RoomCreateEvent.TYPE, "", )
-        create_event = event.old_state_events.get(key)
+        create_event = current_state.get(key)
         if create_event:
             auth_events.append(create_event.event_id)
 
@@ -403,7 +403,8 @@ class Auth(object):
             }
             for h in hashes
         ]
-        event.auth_events = zip(auth_events, hashes)
+
+        defer.returnValue(zip(auth_events, hashes))
 
     @log_function
     def _can_send_event(self, event, auth_events):
diff --git a/synapse/api/constants.py b/synapse/api/constants.py
index 3cafff0e32..acf50e42ab 100644
--- a/synapse/api/constants.py
+++ b/synapse/api/constants.py
@@ -59,3 +59,12 @@ class LoginType(object):
     EMAIL_URL = u"m.login.email.url"
     EMAIL_IDENTITY = u"m.login.email.identity"
     RECAPTCHA = u"m.login.recaptcha"
+
+
+class EventTypes(object):
+    Member = "m.room.member"
+    Create = "m.room.create"
+    JoinRules = "m.room.join_rules"
+    PowerLevels = "m.room.power_levels"
+    Aliases = "m.room.aliases"
+    Redaction = "m.room.redaction"
\ No newline at end of file