Files
odoo_source/addons/mail/controllers/webclient.py
T
tsm-odoo f5442e970a [IMP] mail: add guest to context when available
This PR prepares the ground for the one introducing guests
for livechat visitors. Since our SameSite cookie policy
is Lax, the cookie won't be send on unsafe cross site
requests thus another mechanism will be introduced to
retrieve the guest.

This PR abstracts the way the guest is retrieved in order
to ease this transition as much as possible by overriding
the `ir_http._pre_dispatch` method in order to inject the
guest in the context if any.

part of task-3332628

closes odoo/odoo#129039

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-07-25 17:35:40 +02:00

22 lines
860 B
Python

# Part of Odoo. See LICENSE file for full copyright and licensing details.
from werkzeug.exceptions import NotFound
from odoo import http
from odoo.http import request
class WebclientController(http.Controller):
@http.route("/mail/init_messaging", methods=["POST"], type="json", auth="public")
def mail_init_messaging(self):
if not request.env.user.sudo()._is_public():
return request.env.user.sudo(request.env.user.has_group("base.group_portal"))._init_messaging()
guest = request.env["mail.guest"]._get_guest_from_context()
if guest:
return guest.sudo()._init_messaging()
raise NotFound()
@http.route("/mail/load_message_failures", methods=["POST"], type="json", auth="user")
def mail_load_message_failures(self):
return request.env.user.partner_id._message_fetch_failed()