Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Fix up tagging server notice rooms. #3755

Merged
merged 3 commits into from
Aug 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/3755.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix tagging of server notice rooms
9 changes: 7 additions & 2 deletions synapse/server_notices/resource_limits_server_notices.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ def __init__(self, hs):
self._message_handler = hs.get_message_handler()
self._state = hs.get_state_handler()

self._notifier = hs.get_notifier()

@defer.inlineCallbacks
def maybe_send_server_notice_to_user(self, user_id):
"""Check if we need to send a notice to this user, this will be true in
Expand Down Expand Up @@ -152,8 +154,11 @@ def _check_and_set_tags(self, user_id, room_id):
# tag already present, nothing to do here
need_to_set_tag = False
if need_to_set_tag:
yield self._store.add_tag_to_room(
user_id, room_id, SERVER_NOTICE_ROOM_TAG, None
max_id = yield self._store.add_tag_to_room(
user_id, room_id, SERVER_NOTICE_ROOM_TAG, {}
)
self._notifier.on_new_event(
"account_data_key", max_id, users=[user_id]
)

@defer.inlineCallbacks
Expand Down
10 changes: 8 additions & 2 deletions synapse/server_notices/server_notices_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ def __init__(self, hs):
self._event_creation_handler = hs.get_event_creation_handler()
self._is_mine_id = hs.is_mine_id

self._notifier = hs.get_notifier()

def is_enabled(self):
"""Checks if server notices are enabled on this server.

Expand Down Expand Up @@ -153,8 +155,12 @@ def get_notice_room_for_user(self, user_id):
creator_join_profile=join_profile,
)
room_id = info['room_id']
yield self._store.add_tag_to_room(
user_id, room_id, SERVER_NOTICE_ROOM_TAG, None

max_id = yield self._store.add_tag_to_room(
user_id, room_id, SERVER_NOTICE_ROOM_TAG, {},
)
self._notifier.on_new_event(
"account_data_key", max_id, users=[user_id]
)

logger.info("Created server notices room %s for %s", room_id, user_id)
Expand Down