[FIX] mail: not _notify_thread_by_web_push if mute

Do not send the web_push notificaiton if the channel is muted.

closes odoo/odoo#140285

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
zel-odoo
2023-11-02 18:23:11 +00:00
parent 05c5a91881
commit 442edacee2
2 changed files with 18 additions and 1 deletions
@@ -1223,7 +1223,7 @@ class Channel(models.Model):
'type': 'customer',
'groups': [],
}
for partner in chat_channels.mapped("channel_partner_ids")
for partner in chat_channels.channel_member_ids.filtered(lambda member: not member.mute_until_dt).partner_id
]
else:
channel_rdata = recipients_data
@@ -2,6 +2,7 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import json
import socket
from datetime import datetime
import odoo
from odoo.tools.misc import mute_logger
@@ -167,7 +168,23 @@ class TestWebPushNotification(SMSCommon):
self._assert_notification_count_for_cron(0)
push_to_end_point.assert_called_once()
self.assertEqual(push_to_end_point.call_args.kwargs['device']['endpoint'], 'https://test.odoo.com/webpush/user2')
# Reset the mock counter
push_to_end_point.reset_mock()
# Test Direct Message with channel Muted
self.env['discuss.channel.member'].search([
('partner_id', '=', self.user_inbox.partner_id.id),
('channel_id', '=', self.direct_message_channel.id),
]).write({
'mute_until_dt': datetime(9999, 1, 1, 14, 00),
})
self.direct_message_channel.with_user(self.user_email).message_post(
body='Test', message_type='comment', subtype_xmlid='mail.mt_comment')
self._assert_notification_count_for_cron(0)
push_to_end_point.assert_not_called()
# Reset the mock counter
push_to_end_point.reset_mock()