From bcce4be8e91d0966f4b8a475cde899c2405559f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Theys?= Date: Fri, 21 Apr 2023 08:01:04 +0000 Subject: [PATCH] [REF] mail, im_livechat: move /mail/chat_history to im_livechat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is only used there. In preparation of splitting discuss and mail modules. Part of task-3265211 closes odoo/odoo#119302 Signed-off-by: Alexandre Kühn (aku) --- addons/im_livechat/controllers/main.py | 8 ++++++++ .../src/legacy/public_models/public_livechat_global.js | 2 +- addons/mail/controllers/bus.py | 8 -------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/addons/im_livechat/controllers/main.py b/addons/im_livechat/controllers/main.py index b74439155cc..529e92945d9 100644 --- a/addons/im_livechat/controllers/main.py +++ b/addons/im_livechat/controllers/main.py @@ -211,3 +211,11 @@ class LivechatController(http.Controller): discuss_channel = request.env['discuss.channel'].sudo().search([('uuid', '=', uuid)]) if discuss_channel: discuss_channel._close_livechat_session() + + @http.route(['/im_livechat/chat_history'], type="json", auth="public", cors="*") + def im_livechat_chat_history(self, uuid, last_id=False, limit=20): + channel = request.env["discuss.channel"].sudo().search([('uuid', '=', uuid)], limit=1) + if not channel: + return [] + else: + return channel._channel_fetch_message(last_id, limit) diff --git a/addons/im_livechat/static/src/legacy/public_models/public_livechat_global.js b/addons/im_livechat/static/src/legacy/public_models/public_livechat_global.js index fc726e7ccc2..c7ec7329081 100644 --- a/addons/im_livechat/static/src/legacy/public_models/public_livechat_global.js +++ b/addons/im_livechat/static/src/legacy/public_models/public_livechat_global.js @@ -52,7 +52,7 @@ Model({ const cookie = JSON.parse(strCookie || "{}"); if (cookie.id) { const history = await this.messaging.rpc({ - route: "/mail/chat_history", + route: "/im_livechat/chat_history", params: { uuid: cookie.uuid, limit: 100 }, }); history.reverse(); diff --git a/addons/mail/controllers/bus.py b/addons/mail/controllers/bus.py index 850a56c36cf..87b73c4a0af 100644 --- a/addons/mail/controllers/bus.py +++ b/addons/mail/controllers/bus.py @@ -35,11 +35,3 @@ class MailChatController(BusController): subtype_xmlid='mail.mt_comment' ) return message.id if message else False - - @route(['/mail/chat_history'], type="json", auth="public", cors="*") - def mail_chat_history(self, uuid, last_id=False, limit=20): - channel = request.env["discuss.channel"].sudo().search([('uuid', '=', uuid)], limit=1) - if not channel: - return [] - else: - return channel._channel_fetch_message(last_id, limit)