[FIX] im_livechat: do not add public user to livechat channels

Public users (website visitors) do not need to be part of
a livechat channel to talk with the operator, they are using
a dedicated mechanism.
Explicitly including them is redundant and bloats the database.
This commit is contained in:
Olivier Dony
2017-05-05 17:02:46 +02:00
parent 831a2a00e3
commit ff59e24093
@@ -166,7 +166,7 @@ class ImLivechatChannel(models.Model):
operator_partner_id = user.partner_id.id
# partner to add to the mail.channel
channel_partner_to_add = [(4, operator_partner_id)]
if self.env.uid: # if the user if logged (portal user), he can be identify
if self.env.user and self.env.user.active: # valid session user (not public)
channel_partner_to_add.append((4, self.env.user.partner_id.id))
# create the session, and add the link with the given channel
mail_channel = self.env["mail.channel"].with_context(mail_create_nosubscribe=False).sudo().create({