diff options
author | Mark Haines <mjark@negativecurvature.net> | 2015-01-30 15:14:10 +0000 |
---|---|---|
committer | Mark Haines <mjark@negativecurvature.net> | 2015-01-30 15:14:10 +0000 |
commit | 9ec9d6f2cbebff94316d757b3f0267fa860aa612 (patch) | |
tree | 05dc1bfa84f3849511c07784d00e908769fd082d /synapse/storage/__init__.py | |
parent | Add glob asterisks when running rules. (diff) | |
parent | Merge branch 'rejections_storage' of github.com:matrix-org/synapse into repli... (diff) | |
download | synapse-9ec9d6f2cbebff94316d757b3f0267fa860aa612.tar.xz |
Merge pull request #42 from matrix-org/replication_split
Replication split
Diffstat (limited to 'synapse/storage/__init__.py')
-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 f35ece6446..7c54b1b9d3 100644 --- a/synapse/storage/__init__.py +++ b/synapse/storage/__init__.py @@ -469,6 +469,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 e.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 |