'Return a mail.channel given a livechat channel. It creates one with a connected operator, or return false otherwise
:param livechat_channel_id : the identifier if the im_livechat.channel
:param anonymous_name : the name of the anonymous person of the channel
:type livechat_channel_id : int
:type anonymous_name : str
:return : channel header
:rtype : dict'

@api.model
def get_mail_channel(self, livechat_channel_id, anonymous_name):

    users = self.sudo().browse(livechat_channel_id).get_available_users()
    if (len(users) == 0):
        return False
    user = random.choice(users)
    operator_partner_id = user.partner_id.id
    channel_partner_to_add = [(4, operator_partner_id)]
    if (self.env.user and self.env.user.active):
        channel_partner_to_add.append((4, self.env.user.partner_id.id))
    mail_channel = self.env['mail.channel'].with_context(mail_create_nosubscribe=False).sudo().create({'channel_partner_ids': channel_partner_to_add, 'livechat_channel_id': livechat_channel_id, 'anonymous_name': anonymous_name, 'channel_type': 'livechat', 'name': ',    '.join([anonymous_name, user.name]), 'public': 'private', 'email_send': False})
    return mail_channel.sudo().with_context(im_livechat_operator_partner_id=operator_partner_id).channel_info()[0]
