diff options
author | Erik Johnston <erik@matrix.org> | 2014-08-19 14:20:03 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2014-08-19 14:20:03 +0100 |
commit | 75b6d982a01a431a89d2ab76d91a09159630d059 (patch) | |
tree | fbcaf076fba353d05f757180ab19f7ea823c37e4 /synapse/handlers/federation.py | |
parent | Change the way pagination works to support out of order events. (diff) | |
download | synapse-75b6d982a01a431a89d2ab76d91a09159630d059.tar.xz |
Add a 'backfill room' button
Diffstat (limited to '')
-rw-r--r-- | synapse/handlers/federation.py | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py index 7026df90a2..ef9ed274df 100644 --- a/synapse/handlers/federation.py +++ b/synapse/handlers/federation.py @@ -35,7 +35,7 @@ class FederationHandler(BaseHandler): @log_function @defer.inlineCallbacks - def on_receive(self, event, is_new_state): + def on_receive(self, event, is_new_state, backfilled): if hasattr(event, "state_key") and not is_new_state: logger.debug("Ignoring old state.") return @@ -70,6 +70,21 @@ class FederationHandler(BaseHandler): else: with (yield self.room_lock.lock(event.room_id)): - store_id = yield self.store.persist_event(event) + store_id = yield self.store.persist_event(event, backfilled) - yield self.notifier.on_new_room_event(event, store_id) + if not backfilled: + yield self.notifier.on_new_room_event(event, store_id) + + + @log_function + @defer.inlineCallbacks + def backfill(self, dest, room_id, limit): + events = yield self.hs.get_federation().backfill(dest, room_id, limit) + + for event in events: + try: + yield self.store.persist_event(event, backfilled=True) + except: + logger.debug("Failed to persiste event: %s", event) + + defer.returnValue(events) |