mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-07-31 22:48:33 -04:00
Hook up the push rules stream to account_data in /sync
This commit is contained in:
parent
3406eba4ef
commit
1b4f4a936f
4 changed files with 85 additions and 69 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()
|
||||
)
|
||||
|
@ -322,6 +327,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 = []
|
||||
|
||||
|
@ -481,6 +494,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