diff options
author | Erik Johnston <erik@matrix.org> | 2016-07-05 10:28:51 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2016-07-05 10:28:51 +0100 |
commit | 2d21d43c34751cffb5f324bd58ceff060f65f679 (patch) | |
tree | f94af9ec9b706479284c3fe3842fed5f64650fdd /synapse/handlers | |
parent | Add storage function to purge history for a room (diff) | |
download | synapse-2d21d43c34751cffb5f324bd58ceff060f65f679.tar.xz |
Add purge_history API
Diffstat (limited to 'synapse/handlers')
-rw-r--r-- | synapse/handlers/federation.py | 2 | ||||
-rw-r--r-- | synapse/handlers/message.py | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py index 6c0bc7eafa..351b218247 100644 --- a/synapse/handlers/federation.py +++ b/synapse/handlers/federation.py @@ -1413,7 +1413,7 @@ class FederationHandler(BaseHandler): local_view = dict(auth_events) remote_view = dict(auth_events) remote_view.update({ - (d.type, d.state_key): d for d in different_events + (d.type, d.state_key): d for d in different_events if d }) new_state, prev_state = self.state_handler.resolve_events( diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py index 15caf1950a..878809d50d 100644 --- a/synapse/handlers/message.py +++ b/synapse/handlers/message.py @@ -51,6 +51,19 @@ class MessageHandler(BaseHandler): self.snapshot_cache = SnapshotCache() @defer.inlineCallbacks + def purge_history(self, room_id, event_id): + event = yield self.store.get_event(event_id) + + if event.room_id != room_id: + raise SynapseError(400, "Event is for wrong room.") + + depth = event.depth + + # TODO: Lock. + + yield self.store.delete_old_state(room_id, depth) + + @defer.inlineCallbacks def get_messages(self, requester, room_id=None, pagin_config=None, as_client_event=True): """Get messages in a room. |