'Subscribe to a mailing list : this will create a partner with its email address (if public user not
registered yet) and add it as channel member
:param channel_id : the channel id to join/quit
:param subscription : \'on\' to unsubscribe the user, \'off\' to subscribe'

@http.route(['/groups/subscription'], type='json', auth='public', website=True)
def subscription(self, channel_id=0, subscription='on', email='', **kw):

    unsubscribe = (subscription == 'on')
    channel = request.env['mail.channel'].browse(int(channel_id))
    partner_ids = []
    if (request.env.user != request.website.user_id):
        partner_ids = request.env.user.partner_id.ids
        if unsubscribe:
            channel.check_access_rule('read')
            channel.sudo().write({'channel_partner_ids': [(3, partner_id) for partner_id in partner_ids]})
            return 'off'
        else:
            request.session['partner_id'] = partner_ids[0]
            channel.check_access_rule('read')
            channel.sudo().write({'channel_partner_ids': [(4, partner_id) for partner_id in partner_ids]})
        return 'on'
    else:
        partner_ids = channel.sudo()._find_partner_from_emails([email], check_followers=True)
        if ((not partner_ids) or (not partner_ids[0])):
            name = email.split('@')[0]
            partner_ids = [request.env['res.partner'].sudo().create({'name': name, 'email': email}).id]
        channel.sudo()._send_confirmation_email(partner_ids, unsubscribe)
        return 'email'
