diff options
author | Erik Johnston <erik@matrix.org> | 2014-10-17 15:04:17 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2014-10-17 15:04:17 +0100 |
commit | f71627567b4aa58c5aba7e79c6d972b8ac26b449 (patch) | |
tree | 08f077bc1cbcc2d84e5783d41b2bbe84fbc3b24c /synapse/api/events | |
parent | Start implementing the invite/join dance. Continue moving auth to use event.s... (diff) | |
download | synapse-f71627567b4aa58c5aba7e79c6d972b8ac26b449.tar.xz |
Finish implementing the new join dance.
Diffstat (limited to 'synapse/api/events')
-rw-r--r-- | synapse/api/events/factory.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/synapse/api/events/factory.py b/synapse/api/events/factory.py index 0d94850cec..c6d1151cac 100644 --- a/synapse/api/events/factory.py +++ b/synapse/api/events/factory.py @@ -51,12 +51,20 @@ class EventFactory(object): self.clock = hs.get_clock() self.hs = hs + self.event_id_count = 0 + + def create_event_id(self): + i = str(self.event_id_count) + self.event_id_count += 1 + + local_part = str(int(self.clock.time())) + i + random_string(5) + + return "%s@%s" % (local_part, self.hs.hostname) + def create_event(self, etype=None, **kwargs): kwargs["type"] = etype if "event_id" not in kwargs: - kwargs["event_id"] = "%s@%s" % ( - random_string(10), self.hs.hostname - ) + kwargs["event_id"] = self.create_event_id() if "ts" not in kwargs: kwargs["ts"] = int(self.clock.time_msec()) |