diff options
| author | Lucas Perais (lpe) <lpe@odoo.com> | 2017-10-18 13:40:44 +0200 |
|---|---|---|
| committer | Lucas Perais (lpe) <lpe@odoo.com> | 2017-11-09 10:42:36 +0100 |
| commit | bb38c7047e739b250ceff9e90099e25d59bc2b3d (patch) | |
| tree | c58a4e3b6be21a3b7c5c9f48f2164e38ab44a138 | |
| parent | 35aa2a977f5169db12b6a7367f7d3b7fa87277cc (diff) | |
[FIX] im_livechat, mail: visitor to portal_user should keep livechat channel
Before this commit, when starting a livechat session as a public user and continuing as a portal user, the conversation was lost
(the poral user couldn't see previous messages posted as a public user)
After this commit, the conversation is kept and security insured by the uuid in the cookie
OPW 775568
closes #20279
| -rw-r--r-- | addons/im_livechat/controllers/main.py | 3 | ||||
| -rw-r--r-- | addons/mail/controllers/bus.py | 5 |
2 files changed, 4 insertions, 4 deletions
diff --git a/addons/im_livechat/controllers/main.py b/addons/im_livechat/controllers/main.py index eaf54eaf399..25e5a946fbc 100644 --- a/addons/im_livechat/controllers/main.py +++ b/addons/im_livechat/controllers/main.py @@ -70,9 +70,10 @@ class LivechatController(http.Controller): anonymous_name = request.env.user.name return request.env["im_livechat.channel"].get_mail_channel(channel_id, anonymous_name) + # Do not forward port in 10.0 @http.route('/im_livechat/history', type="json", auth="public") def history(self, channel_id, limit): - return request.env["mail.channel"].browse(channel_id).channel_fetch_message(limit=limit) + return request.env["mail.channel"].browse(channel_id).sudo().channel_fetch_message(limit=limit) @http.route('/im_livechat/feedback', type='json', auth='public') def feedback(self, uuid, rate, reason=None, **kwargs): diff --git a/addons/mail/controllers/bus.py b/addons/mail/controllers/bus.py index 96d092f97b4..274cb722655 100644 --- a/addons/mail/controllers/bus.py +++ b/addons/mail/controllers/bus.py @@ -36,14 +36,13 @@ class MailChatController(openerp.addons.bus.controllers.main.BusController): # -------------------------- @openerp.http.route('/mail/chat_post', type="json", auth="none") def mail_chat_post(self, uuid, message_content, **kwargs): - request_uid = self._default_request_uid() # find the author from the user session, which can be None author_id = False # message_post accept 'False' author_id, but not 'None' if request.session.uid: author_id = request.env['res.users'].sudo().browse(request.session.uid).partner_id.id # post a message without adding followers to the channel. email_from=False avoid to get author from email data - mail_channel = request.env["mail.channel"].sudo(request_uid).search([('uuid', '=', uuid)], limit=1) - message = mail_channel.sudo(request_uid).with_context(mail_create_nosubscribe=True).message_post(author_id=author_id, email_from=False, body=message_content, message_type='comment', subtype='mail.mt_comment', content_subtype='plaintext', **kwargs) + mail_channel = request.env["mail.channel"].sudo().search([('uuid', '=', uuid)], limit=1) + message = mail_channel.sudo().with_context(mail_create_nosubscribe=True).message_post(author_id=author_id, email_from=False, body=message_content, message_type='comment', subtype='mail.mt_comment', content_subtype='plaintext') return message and message.id or False @openerp.http.route(['/mail/chat_history'], type="json", auth="none") |
