diff options
author | Erik Johnston <erik@matrix.org> | 2015-01-23 15:42:52 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-01-23 15:42:52 +0000 |
commit | 3b9cc882a50c886afd7d2cf1eaa7e02e8b0d0d51 (patch) | |
tree | 428370ce335951c51400ed5dfdf12b3cc70dc743 /synapse | |
parent | Split out TransactionQueue from replication layer (diff) | |
download | synapse-3b9cc882a50c886afd7d2cf1eaa7e02e8b0d0d51.tar.xz |
Add storage method have_events
Diffstat (limited to '')
-rw-r--r-- | synapse/storage/__init__.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/synapse/storage/__init__.py b/synapse/storage/__init__.py index 015fcc8775..4f09909607 100644 --- a/synapse/storage/__init__.py +++ b/synapse/storage/__init__.py @@ -422,6 +422,35 @@ class DataStore(RoomMemberStore, RoomStore, ], ) + def have_events(self, event_ids): + """Given a list of event ids, check if we have already processed them. + + Returns: + dict: Has an entry for each event id we already have seen. Maps to + the rejected reason string if we rejected the event, else maps to + None. + """ + def f(txn): + sql = ( + "SELECT e.event_id, reason FROM events as e " + "LEFT JOIN rejections as r ON e.event_id = r.event_id " + "WHERE event_id = ?" + ) + + res = {} + for event_id in event_ids: + txn.execute(sql, (event_id,)) + row = txn.fetchone() + if row: + _, rejected = row + res[event_id] = rejected + + return res + + return self.runInteraction( + "have_events", f, + ) + def schema_path(schema): """ Get a filesystem path for the named database schema |