mirror of
https://mau.dev/maunium/synapse.git
synced 2024-11-16 15:01:23 +01:00
Add ts field to all events.
This commit is contained in:
parent
7dac1bfc91
commit
5670da1c1e
2 changed files with 7 additions and 2 deletions
|
@ -33,16 +33,21 @@ class EventFactory(object):
|
||||||
RoomConfigEvent
|
RoomConfigEvent
|
||||||
]
|
]
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, hs):
|
||||||
self._event_list = {} # dict of TYPE to event class
|
self._event_list = {} # dict of TYPE to event class
|
||||||
for event_class in EventFactory._event_classes:
|
for event_class in EventFactory._event_classes:
|
||||||
self._event_list[event_class.TYPE] = event_class
|
self._event_list[event_class.TYPE] = event_class
|
||||||
|
|
||||||
|
self.clock = hs.get_clock()
|
||||||
|
|
||||||
def create_event(self, etype=None, **kwargs):
|
def create_event(self, etype=None, **kwargs):
|
||||||
kwargs["type"] = etype
|
kwargs["type"] = etype
|
||||||
if "event_id" not in kwargs:
|
if "event_id" not in kwargs:
|
||||||
kwargs["event_id"] = random_string(10)
|
kwargs["event_id"] = random_string(10)
|
||||||
|
|
||||||
|
if "ts" not in kwargs:
|
||||||
|
kwargs["ts"] = int(self.clock.time_msec())
|
||||||
|
|
||||||
if etype in self._event_list:
|
if etype in self._event_list:
|
||||||
handler = self._event_list[etype]
|
handler = self._event_list[etype]
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -159,7 +159,7 @@ class HomeServer(BaseHomeServer):
|
||||||
return DataStore(self)
|
return DataStore(self)
|
||||||
|
|
||||||
def build_event_factory(self):
|
def build_event_factory(self):
|
||||||
return EventFactory()
|
return EventFactory(self)
|
||||||
|
|
||||||
def build_handlers(self):
|
def build_handlers(self):
|
||||||
return Handlers(self)
|
return Handlers(self)
|
||||||
|
|
Loading…
Reference in a new issue