diff --git a/addons/im_livechat/models/im_livechat_channel.py b/addons/im_livechat/models/im_livechat_channel.py index 731118d31c4..b657f770c6e 100644 --- a/addons/im_livechat/models/im_livechat_channel.py +++ b/addons/im_livechat/models/im_livechat_channel.py @@ -176,7 +176,7 @@ class ImLivechatChannel(models.Model): 'anonymous_name': anonymous_name, 'channel_type': 'livechat', 'name': ', '.join([anonymous_name, user.name]), - 'public': 'public', + 'public': 'private', 'email_send': False, }) return mail_channel.sudo().with_context(im_livechat_operator_partner_id=operator_partner_id).channel_info()[0] diff --git a/addons/im_livechat/models/mail_channel.py b/addons/im_livechat/models/mail_channel.py index eded0ff17da..8fb014f0b8f 100644 --- a/addons/im_livechat/models/mail_channel.py +++ b/addons/im_livechat/models/mail_channel.py @@ -24,6 +24,11 @@ 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 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: @@ -53,7 +58,7 @@ class MailChannel(models.Model): def channel_fetch_slot(self): values = super(MailChannel, self).channel_fetch_slot() pinned_channels = self.env['mail.channel.partner'].search([('partner_id', '=', self.env.user.partner_id.id), ('is_pinned', '=', True)]).mapped('channel_id') - values['channel_livechat'] = self.search([('channel_type', '=', 'livechat'), ('public', 'in', ['public']), ('id', 'in', pinned_channels.ids)]).channel_info() + values['channel_livechat'] = self.search([('channel_type', '=', 'livechat'), ('id', 'in', pinned_channels.ids)]).channel_info() return values @api.model diff --git a/addons/mail/static/src/js/chat_manager.js b/addons/mail/static/src/js/chat_manager.js index 87f7fbdf0fb..ce77ea1f6d4 100644 --- a/addons/mail/static/src/js/chat_manager.js +++ b/addons/mail/static/src/js/chat_manager.js @@ -336,10 +336,8 @@ function make_channel (data, options) { messages: [], }}, }; - if (channel.type === "channel" && data.public !== "private") { - channel.type = "public"; - } else if (data.public === "private") { - channel.type = "private"; + if (channel.type === "channel") { + channel.type = data.public !== "private" ? "public" : "private"; } if (_.size(data.direct_partner) > 0) { channel.type = "dm";