summary refs log tree commit diff
path: root/synapse/server.py
diff options
context:
space:
mode:
authorMark Haines <mjark@negativecurvature.net>2014-12-16 13:53:43 +0000
committerMark Haines <mjark@negativecurvature.net>2014-12-16 13:53:43 +0000
commit2af40cfa14ba579c156349ae3457a55bc93f8548 (patch)
tree2b94b53c72d51fc170549213ed8cb88556c2b501 /synapse/server.py
parentAdd a script for talking matrix federation adding X-Matrix Authorization (diff)
parentFix pyflakes (diff)
downloadsynapse-2af40cfa14ba579c156349ae3457a55bc93f8548.tar.xz
Merge pull request #25 from matrix-org/events_refactor
Event refactor
Diffstat (limited to 'synapse/server.py')
-rw-r--r--synapse/server.py29
1 files changed, 15 insertions, 14 deletions
diff --git a/synapse/server.py b/synapse/server.py
index 7eb15270fc..e4021481e8 100644
--- a/synapse/server.py
+++ b/synapse/server.py
@@ -20,9 +20,7 @@
 
 # Imports required for the default HomeServer() implementation
 from synapse.federation import initialize_http_replication
-from synapse.api.events import serialize_event
-from synapse.api.events.factory import EventFactory
-from synapse.api.events.validator import EventValidator
+from synapse.events.utils import serialize_event
 from synapse.notifier import Notifier
 from synapse.api.auth import Auth
 from synapse.handlers import Handlers
@@ -36,6 +34,7 @@ from synapse.util.lockutils import LockManager
 from synapse.streams.events import EventSources
 from synapse.api.ratelimiting import Ratelimiter
 from synapse.crypto.keyring import Keyring
+from synapse.events.builder import EventBuilderFactory
 
 
 class BaseHomeServer(object):
@@ -65,7 +64,6 @@ class BaseHomeServer(object):
         'persistence_service',
         'replication_layer',
         'datastore',
-        'event_factory',
         'handlers',
         'auth',
         'rest_servlet_factory',
@@ -82,7 +80,7 @@ class BaseHomeServer(object):
         'event_sources',
         'ratelimiter',
         'keyring',
-        'event_validator',
+        'event_builder_factory',
     ]
 
     def __init__(self, hostname, **kwargs):
@@ -134,22 +132,22 @@ class BaseHomeServer(object):
     def parse_userid(self, s):
         """Parse the string given by 's' as a User ID and return a UserID
         object."""
-        return UserID.from_string(s, hs=self)
+        return UserID.from_string(s)
 
     def parse_roomalias(self, s):
         """Parse the string given by 's' as a Room Alias and return a RoomAlias
         object."""
-        return RoomAlias.from_string(s, hs=self)
+        return RoomAlias.from_string(s)
 
     def parse_roomid(self, s):
         """Parse the string given by 's' as a Room ID and return a RoomID
         object."""
-        return RoomID.from_string(s, hs=self)
+        return RoomID.from_string(s)
 
     def parse_eventid(self, s):
         """Parse the string given by 's' as a Event ID and return a EventID
         object."""
-        return EventID.from_string(s, hs=self)
+        return EventID.from_string(s)
 
     def serialize_event(self, e):
         return serialize_event(self, e)
@@ -166,6 +164,9 @@ class BaseHomeServer(object):
 
         return ip_addr
 
+    def is_mine(self, domain_specific_string):
+        return domain_specific_string.domain == self.hostname
+
 # Build magic accessors for every dependency
 for depname in BaseHomeServer.DEPENDENCIES:
     BaseHomeServer._make_dependency_method(depname)
@@ -193,9 +194,6 @@ class HomeServer(BaseHomeServer):
     def build_datastore(self):
         return DataStore(self)
 
-    def build_event_factory(self):
-        return EventFactory(self)
-
     def build_handlers(self):
         return Handlers(self)
 
@@ -226,8 +224,11 @@ class HomeServer(BaseHomeServer):
     def build_keyring(self):
         return Keyring(self)
 
-    def build_event_validator(self):
-        return EventValidator(self)
+    def build_event_builder_factory(self):
+        return EventBuilderFactory(
+            clock=self.get_clock(),
+            hostname=self.hostname,
+        )
 
     def register_servlets(self):
         """ Register all servlets associated with this HomeServer.