From a8a25d09ee8925f4672dd141a695b0c543980cdd Mon Sep 17 00:00:00 2001 From: miruka Date: Wed, 16 Sep 2020 11:22:50 -0400 Subject: [PATCH] Ensure room has 2 members to hide notif. sender --- src/backend/matrix_client.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/backend/matrix_client.py b/src/backend/matrix_client.py index 050b00b4..d291905d 100644 --- a/src/backend/matrix_client.py +++ b/src/backend/matrix_client.py @@ -2139,17 +2139,19 @@ class MatrixClient(nio.AsyncClient): if unread or highlight: AlertRequested(high_importance=highlight) - notif_room = room.display_name - notif_sender = item.sender_name or item.sender_id - body_start = f"{notif_sender}: " + members = self.models[self.user_id, room.room_id, "members"] + room_name = room.display_name + sender = item.sender_name or item.sender_id - if notif_room == notif_sender: + if len(members) == 2 and room_name == sender: body_start = "" elif isinstance(ev, nio.RoomMessageEmote): - body_start = f"{notif_sender} " + body_start = f"{sender} " + else: + body_start = f"{sender}: " await self.backend.desktop_notify( - title = notif_room, + title = room_name, body = f"{body_start}{item.inline_content}", # await self.backend.media_cache.get_thumbnail( # item.sender_avatar, 32, 32,