summary refs log tree commit diff
path: root/synapse/storage/push_rule.py
diff options
context:
space:
mode:
authorDavid Baker <dave@matrix.org>2015-02-25 19:17:07 +0000
committerDavid Baker <dave@matrix.org>2015-02-25 19:17:07 +0000
commit94fa334b01d232bed96fd4ee05fc44d00330c2b9 (patch)
treef680ff0fb9a16a54a083d63e44fd2d6b04093a2a /synapse/storage/push_rule.py
parentSYWEB-278 Don't allow rules with no rule_id. (diff)
downloadsynapse-94fa334b01d232bed96fd4ee05fc44d00330c2b9.tar.xz
Add enable/disable overlay for push rules (REST API not yet hooked up)
Diffstat (limited to 'synapse/storage/push_rule.py')
-rw-r--r--synapse/storage/push_rule.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/synapse/storage/push_rule.py b/synapse/storage/push_rule.py
index ae46b39cc1..3890c7aab2 100644
--- a/synapse/storage/push_rule.py
+++ b/synapse/storage/push_rule.py
@@ -46,6 +46,17 @@ class PushRuleStore(SQLBaseStore):
         defer.returnValue(dicts)
 
     @defer.inlineCallbacks
+    def get_push_rules_enabled_for_user_name(self, user_name):
+        results = yield self._simple_select_list(
+            PushRuleEnableTable.table_name,
+            {'user_name': user_name},
+            PushRuleEnableTable.fields
+        )
+        defer.returnValue(
+            {r['rule_id']: False if r['enabled'] == 0 else True for r in results}
+        )
+
+    @defer.inlineCallbacks
     def add_push_rule(self, before, after, **kwargs):
         vals = copy.copy(kwargs)
         if 'conditions' in vals:
@@ -216,3 +227,12 @@ class PushRuleTable(Table):
     ]
 
     EntryType = collections.namedtuple("PushRuleEntry", fields)
+
+class PushRuleEnableTable(Table):
+    table_name = "push_rules_enable"
+
+    fields = [
+        "user_name",
+        "rule_id",
+        "enabled"
+    ]
\ No newline at end of file