summary refs log tree commit diff
path: root/synapse/api
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-08-15 16:06:08 +0100
committerErik Johnston <erik@matrix.org>2014-08-15 16:06:08 +0100
commit19946509a4ddbdd647261f9f19358e6f1f0e337b (patch)
treeb1c20c645492901c14c54d3e4085ac94c5acf6e6 /synapse/api
parentFix bug when generating a key when get_room_events_stream returned zero rows (diff)
downloadsynapse-19946509a4ddbdd647261f9f19358e6f1f0e337b.tar.xz
Support generic events.
Diffstat (limited to 'synapse/api')
-rw-r--r--synapse/api/events/factory.py9
-rw-r--r--synapse/api/events/room.py4
2 files changed, 8 insertions, 5 deletions
diff --git a/synapse/api/events/factory.py b/synapse/api/events/factory.py
index 23d2b0401c..b61dac7acd 100644
--- a/synapse/api/events/factory.py
+++ b/synapse/api/events/factory.py
@@ -15,7 +15,7 @@
 
 from synapse.api.events.room import (
     RoomTopicEvent, MessageEvent, RoomMemberEvent, FeedbackEvent,
-    InviteJoinEvent, RoomConfigEvent, RoomNameEvent,
+    InviteJoinEvent, RoomConfigEvent, RoomNameEvent, GenericEvent,
 )
 
 from synapse.util.stringutils import random_string
@@ -43,10 +43,9 @@ class EventFactory(object):
         if "event_id" not in kwargs:
             kwargs["event_id"] = random_string(10)
 
-        try:
+        if etype in self._event_list:
             handler = self._event_list[etype]
-        except KeyError:  # unknown event type
-            # TODO allow custom event types.
-            raise NotImplementedError("Unknown etype=%s" % etype)
+        else:
+            handler = GenericEvent
 
         return handler(**kwargs)
diff --git a/synapse/api/events/room.py b/synapse/api/events/room.py
index 8136d495d5..d9b3d572fa 100644
--- a/synapse/api/events/room.py
+++ b/synapse/api/events/room.py
@@ -16,6 +16,10 @@
 from . import SynapseEvent
 
 
+class GenericEvent(SynapseEvent):
+    def get_content_template(self):
+        return {}
+
 class RoomTopicEvent(SynapseEvent):
     TYPE = "m.room.topic"