From cf5142e05972cbf81d0af5b62e5a637c9eeabe9a Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Tue, 6 Mar 2018 09:16:16 +0100 Subject: [PATCH] [FIX] im_livechat: make /history command work for public user Have the public user (not logged in -- user B) having a live chat with any logged in user (user A) Having in mind that: - (A) issues /history in his chatter to see where (B) has gone on the website - The bus sends a kind of a "pull cookie request" on each clients - The browser of (B) retrieves the cookie info and calls the relevant route - That route sends the transient message for (A) Before this commit: The command did not work because the user of the route we end up on is the public one hence, the search for the channel would not yield anything After this commit: The command does work as expected OPW 1818732 closes #23485 --- addons/im_livechat/controllers/main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/im_livechat/controllers/main.py b/addons/im_livechat/controllers/main.py index a79c6f4dc80..805b6ba797a 100644 --- a/addons/im_livechat/controllers/main.py +++ b/addons/im_livechat/controllers/main.py @@ -110,7 +110,8 @@ class LivechatController(http.Controller): @http.route('/im_livechat/history', type="json", auth="public") def history_pages(self, pid, channel_uuid, page_history=None): - channel = request.env['mail.channel'].search([('uuid', '=', channel_uuid)]) + partner_ids = (pid, request.env.user.partner_id.id) + channel = request.env['mail.channel'].sudo().search([('uuid', '=', channel_uuid), ('channel_partner_ids', 'in', partner_ids)]) if channel: channel._send_history_message(pid, page_history) return True