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

Commit

Permalink
Add a sync flag for unread thread notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Aug 5, 2022
1 parent e0ed95a commit d56296a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 7 additions & 0 deletions synapse/api/filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"contains_url": {"type": "boolean"},
"lazy_load_members": {"type": "boolean"},
"include_redundant_members": {"type": "boolean"},
"unread_thread_notifications": {"type": "boolean"},
# Include or exclude events with the provided labels.
# cf https://github.com/matrix-org/matrix-doc/pull/2326
"org.matrix.labels": {"type": "array", "items": {"type": "string"}},
Expand Down Expand Up @@ -240,6 +241,9 @@ def lazy_load_members(self) -> bool:
def include_redundant_members(self) -> bool:
return self._room_state_filter.include_redundant_members

def unread_thread_notifications(self) -> bool:
return self._room_timeline_filter.unread_thread_notifications

async def filter_presence(
self, events: Iterable[UserPresenceState]
) -> List[UserPresenceState]:
Expand Down Expand Up @@ -304,6 +308,9 @@ def __init__(self, hs: "HomeServer", filter_json: JsonDict):
self.include_redundant_members = filter_json.get(
"include_redundant_members", False
)
self.unread_thread_notifications = filter_json.get(
"unread_thread_notifications", False
)

self.types = filter_json.get("types", None)
self.not_types = filter_json.get("not_types", [])
Expand Down
7 changes: 5 additions & 2 deletions synapse/handlers/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -2133,8 +2133,11 @@ async def _generate_room_entry(
highlight_count = notifs.highlight_count
unread_count = notifs.unread_count

# XXX Check the sync configuration.
if self._msc3773_enabled:
# Check the sync configuration.
if (
self._msc3773_enabled
and sync_config.filter_collection.unread_thread_notifications()
):
# And add info for each thread.
room_sync.unread_thread_notifications = {
thread_id: {
Expand Down

0 comments on commit d56296a

Please sign in to comment.