mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-03 04:24:52 -04:00
Merge pull request #618 from matrix-org/markjh/pushrule_stream
Add a stream for push rule updates
This commit is contained in:
commit
b7a3be693b
15 changed files with 484 additions and 194 deletions
|
@ -20,6 +20,7 @@ from synapse.api.constants import Membership, EventTypes
|
|||
from synapse.util import unwrapFirstError
|
||||
from synapse.util.logcontext import LoggingContext, preserve_fn
|
||||
from synapse.util.metrics import Measure
|
||||
from synapse.push.clientformat import format_push_rules_for_user
|
||||
|
||||
from twisted.internet import defer
|
||||
|
||||
|
@ -224,6 +225,10 @@ class SyncHandler(BaseHandler):
|
|||
)
|
||||
)
|
||||
|
||||
account_data['m.push_rules'] = yield self.push_rules_for_user(
|
||||
sync_config.user
|
||||
)
|
||||
|
||||
tags_by_room = yield self.store.get_tags_for_user(
|
||||
sync_config.user.to_string()
|
||||
)
|
||||
|
@ -328,6 +333,14 @@ class SyncHandler(BaseHandler):
|
|||
|
||||
defer.returnValue(room_sync)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def push_rules_for_user(self, user):
|
||||
user_id = user.to_string()
|
||||
rawrules = yield self.store.get_push_rules_for_user(user_id)
|
||||
enabled_map = yield self.store.get_push_rules_enabled_for_user(user_id)
|
||||
rules = format_push_rules_for_user(user, rawrules, enabled_map)
|
||||
defer.returnValue(rules)
|
||||
|
||||
def account_data_for_user(self, account_data):
|
||||
account_data_events = []
|
||||
|
||||
|
@ -487,6 +500,15 @@ class SyncHandler(BaseHandler):
|
|||
)
|
||||
)
|
||||
|
||||
push_rules_changed = yield self.store.have_push_rules_changed_for_user(
|
||||
user_id, int(since_token.push_rules_key)
|
||||
)
|
||||
|
||||
if push_rules_changed:
|
||||
account_data["m.push_rules"] = yield self.push_rules_for_user(
|
||||
sync_config.user
|
||||
)
|
||||
|
||||
# Get a list of membership change events that have happened.
|
||||
rooms_changed = yield self.store.get_membership_changes_for_user(
|
||||
user_id, since_token.room_key, now_token.room_key
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue