From bfb18f4326c8191e46518ea9e50697918391d347 Mon Sep 17 00:00:00 2001 From: David Beguin Date: Fri, 30 Nov 2018 09:19:44 +0000 Subject: [PATCH] [IMP] im_livechat : avoid double notif for public livechat channel and clean method As in super, we add uuid and message if channel is public we have to exculde the public channel to add the same in a livechat case Also, _channel_message_notifications is a bit rewritten to remove useless code. Indeed, notifications will always be filled in as _channel_message_notifications is only called by _notify that ensure that self is not null and that message is singleton. In super, the notifications will then be filled in and in override, no need to check if notifications is not empty. We take the message dict from notif to avoid calling message_format a second time. Task ID : 1895998 Closes PR #28283 --- addons/im_livechat/models/mail_channel.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/im_livechat/models/mail_channel.py b/addons/im_livechat/models/mail_channel.py index d028e301fc1..1e21c5b2d11 100644 --- a/addons/im_livechat/models/mail_channel.py +++ b/addons/im_livechat/models/mail_channel.py @@ -48,11 +48,10 @@ class MailChannel(models.Model): should be added to the notification, since the user cannot be listining to the channel. """ notifications = super(MailChannel, self)._channel_message_notifications(message) - message_values_dict = notifications[0][1] if len(notifications) else dict(message.message_format()[0]) for channel in self: # add uuid for private livechat channels to allow anonymous to listen - if channel.channel_type == 'livechat': - notifications.append([channel.uuid, message_values_dict]) + if channel.channel_type == 'livechat' and channel.public == 'private': + notifications.append([channel.uuid, notifications[0][1]]) if not message.author_id: unpinned_channel_partner = self.mapped('channel_last_seen_partner_ids').filtered(lambda cp: not cp.is_pinned) if unpinned_channel_partner: