summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorKrombel <krombel@krombel.de>2017-05-11 16:05:30 +0200
committerKrombel <krombel@krombel.de>2017-05-11 16:05:30 +0200
commit6b95e35e969f730f7f92f6c3f814691c4bedaeff (patch)
tree3758ea57b5e0a28f23c1eacf01c4f753cc74624a /synapse
parentMerge pull request #2214 from matrix-org/rav/hurry_up_purge (diff)
downloadsynapse-6b95e35e969f730f7f92f6c3f814691c4bedaeff.tar.xz
add check to only add a new filter if the same filter does not exist previously
Signed-off-by: Matthias Kesler <krombel@krombel.de>
Diffstat (limited to 'synapse')
-rw-r--r--synapse/storage/filtering.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/synapse/storage/filtering.py b/synapse/storage/filtering.py
index a2ccc66ea7..e7ec43cf97 100644
--- a/synapse/storage/filtering.py
+++ b/synapse/storage/filtering.py
@@ -52,6 +52,15 @@ class FilteringStore(SQLBaseStore):
         # INSERT a new one
         def _do_txn(txn):
             sql = (
+                "SELECT filter_id FROM user_filters "
+                "WHERE user_id = ? AND filter_json = ?"
+            )
+            txn.execute(sql, (user_localpart,def_json))
+            filter_id = txn.fetchone()[0]
+            if filter_id is not None:
+                return filter_id
+
+            sql = (
                 "SELECT MAX(filter_id) FROM user_filters "
                 "WHERE user_id = ?"
             )