Support generic events.
This commit is contained in:
parent
cd2967d271
commit
19946509a4
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
from synapse.api.events.room import (
|
from synapse.api.events.room import (
|
||||||
RoomTopicEvent, MessageEvent, RoomMemberEvent, FeedbackEvent,
|
RoomTopicEvent, MessageEvent, RoomMemberEvent, FeedbackEvent,
|
||||||
InviteJoinEvent, RoomConfigEvent, RoomNameEvent,
|
InviteJoinEvent, RoomConfigEvent, RoomNameEvent, GenericEvent,
|
||||||
)
|
)
|
||||||
|
|
||||||
from synapse.util.stringutils import random_string
|
from synapse.util.stringutils import random_string
|
||||||
|
@ -43,10 +43,9 @@ class EventFactory(object):
|
||||||
if "event_id" not in kwargs:
|
if "event_id" not in kwargs:
|
||||||
kwargs["event_id"] = random_string(10)
|
kwargs["event_id"] = random_string(10)
|
||||||
|
|
||||||
try:
|
if etype in self._event_list:
|
||||||
handler = self._event_list[etype]
|
handler = self._event_list[etype]
|
||||||
except KeyError: # unknown event type
|
else:
|
||||||
# TODO allow custom event types.
|
handler = GenericEvent
|
||||||
raise NotImplementedError("Unknown etype=%s" % etype)
|
|
||||||
|
|
||||||
return handler(**kwargs)
|
return handler(**kwargs)
|
||||||
|
|
|
@ -16,6 +16,10 @@
|
||||||
from . import SynapseEvent
|
from . import SynapseEvent
|
||||||
|
|
||||||
|
|
||||||
|
class GenericEvent(SynapseEvent):
|
||||||
|
def get_content_template(self):
|
||||||
|
return {}
|
||||||
|
|
||||||
class RoomTopicEvent(SynapseEvent):
|
class RoomTopicEvent(SynapseEvent):
|
||||||
TYPE = "m.room.topic"
|
TYPE = "m.room.topic"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue