From 19946509a4ddbdd647261f9f19358e6f1f0e337b Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Fri, 15 Aug 2014 16:06:08 +0100 Subject: [PATCH] Support generic events. --- synapse/api/events/factory.py | 9 ++++----- synapse/api/events/room.py | 4 ++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/synapse/api/events/factory.py b/synapse/api/events/factory.py index 23d2b0401..b61dac7ac 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 8136d495d..d9b3d572f 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"