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>
17 lines
707 B
Python
17 lines
707 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 MessageReactionController(http.Controller):
|
|
@http.route("/mail/message/reaction", methods=["POST"], type="json", auth="public")
|
|
def mail_message_add_reaction(self, message_id, content, action):
|
|
guest_sudo = request.env["mail.guest"]._get_guest_from_context().sudo()
|
|
message_sudo = guest_sudo.env["mail.message"].browse(int(message_id)).exists()
|
|
if not message_sudo._validate_access_for_current_persona("write"):
|
|
raise NotFound()
|
|
message_sudo._message_reaction(content, action)
|