Add enable/disable overlay for push rules (REST API not yet hooked up)

This commit is contained in:
David Baker 2015-02-25 19:17:07 +00:00
parent a025055643
commit 94fa334b01
5 changed files with 46 additions and 0 deletions

View file

@ -45,6 +45,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)
@ -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"
]