From f0ebe2f2151ecd92e4bc11d75e9082f443f11555 Mon Sep 17 00:00:00 2001 From: Olivier 'reivilibre Date: Thu, 22 Aug 2024 14:16:10 +0100 Subject: [PATCH 1/4] Remove images from message notification e-mails --- synapse/res/templates/notif.html | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/synapse/res/templates/notif.html b/synapse/res/templates/notif.html index 7d86681fed..39f05b85a3 100644 --- a/synapse/res/templates/notif.html +++ b/synapse/res/templates/notif.html @@ -1,19 +1,6 @@ {%- for message in notif.messages %} - {%- if loop.index0 == 0 or notif.messages[loop.index0 - 1].sender_name != notif.messages[loop.index0].sender_name %} - {%- if message.sender_avatar_url %} - - {%- else %} - {%- if message.sender_hash % 3 == 0 %} - - {%- elif message.sender_hash % 3 == 1 %} - - {%- else %} - - {%- endif %} - {%- endif %} - {%- endif %} {%- if loop.index0 == 0 or notif.messages[loop.index0 - 1].sender_name != notif.messages[loop.index0].sender_name %} @@ -30,7 +17,7 @@ {%- elif message.msgtype == "m.notice" %} {{ message.body_text_html }} {%- elif message.msgtype == "m.image" and message.image_url %} - + {{ message.body_text_plain }} (image) {%- elif message.msgtype == "m.file" %} {{ message.body_text_plain }} {%- else %} From 63df220d71e2a2bf051e1e5c1ea5075790eed764 Mon Sep 17 00:00:00 2001 From: Olivier 'reivilibre Date: Thu, 22 Aug 2024 15:00:44 +0100 Subject: [PATCH 2/4] Remove room avatars from message notification e-mails --- synapse/res/templates/room.html | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/synapse/res/templates/room.html b/synapse/res/templates/room.html index 4fc6f6ac9b..b72a14d7ef 100644 --- a/synapse/res/templates/room.html +++ b/synapse/res/templates/room.html @@ -1,17 +1,6 @@
- {%- if room.avatar_url %} - - {%- else %} - {%- if room.hash % 3 == 0 %} - - {%- elif room.hash % 3 == 1 %} - - {%- else %} - - {%- endif %} - {%- endif %} {{ room.title }} From f068106089392da8ee1e8f635463b56e03710b0e Mon Sep 17 00:00:00 2001 From: Olivier 'reivilibre Date: Thu, 22 Aug 2024 15:03:50 +0100 Subject: [PATCH 3/4] Newsfile Signed-off-by: Olivier 'reivilibre --- changelog.d/17598.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/17598.bugfix diff --git a/changelog.d/17598.bugfix b/changelog.d/17598.bugfix new file mode 100644 index 0000000000..cf8d2b0975 --- /dev/null +++ b/changelog.d/17598.bugfix @@ -0,0 +1 @@ +Remove images from message notification e-mails. \ No newline at end of file From feab17ab45bb19b177b467f23e4c6b21c8388b06 Mon Sep 17 00:00:00 2001 From: Olivier 'reivilibre Date: Fri, 23 Aug 2024 11:22:51 +0100 Subject: [PATCH 4/4] Update test --- tests/push/test_email.py | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/tests/push/test_email.py b/tests/push/test_email.py index e0aab1c046..5ce706682d 100644 --- a/tests/push/test_email.py +++ b/tests/push/test_email.py @@ -338,44 +338,6 @@ def test_multiple_rooms(self) -> None: # We should get emailed about those messages self._check_for_mail() - def test_room_notifications_include_avatar(self) -> None: - # Create a room and set its avatar. - room = self.helper.create_room_as(self.user_id, tok=self.access_token) - self.helper.send_state( - room, "m.room.avatar", {"url": "mxc://DUMMY_MEDIA_ID"}, self.access_token - ) - - # Invite two other uses. - for other in self.others: - self.helper.invite( - room=room, src=self.user_id, tok=self.access_token, targ=other.id - ) - self.helper.join(room=room, user=other.id, tok=other.token) - - # The other users send some messages. - # TODO It seems that two messages are required to trigger an email? - self.helper.send(room, body="Alpha", tok=self.others[0].token) - self.helper.send(room, body="Beta", tok=self.others[1].token) - - # We should get emailed about those messages - args, kwargs = self._check_for_mail() - - # That email should contain the room's avatar - msg: bytes = args[5] - # Multipart: plain text, base 64 encoded; html, base 64 encoded - - # Extract the html Message object from the Multipart Message. - # We need the asserts to convince mypy that this is OK. - html_message = email.message_from_bytes(msg).get_payload(i=1) - assert isinstance(html_message, email.message.Message) - - # Extract the `bytes` from the html Message object, and decode to a `str`. - html = html_message.get_payload(decode=True) - assert isinstance(html, bytes) - html = html.decode() - - self.assertIn("_matrix/media/v1/thumbnail/DUMMY_MEDIA_ID", html) - def test_empty_room(self) -> None: """All users leaving a room shouldn't cause the pusher to break.""" # Create a simple room with two users