mail/controllers/webclient.py
Данил Воробьев 6e6f15d803 initial commit
2024-05-03 09:40:35 +00:00

26 lines
1.0 KiB
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
from odoo.addons.mail.models.discuss.mail_guest import add_guest_to_context
class WebclientController(http.Controller):
@http.route("/mail/init_messaging", methods=["POST"], type="json", auth="public")
@add_guest_to_context
def mail_init_messaging(self):
if not request.env.user._is_public():
return request.env.user.sudo(False)._init_messaging()
guest = request.env["mail.guest"]._get_guest_from_context()
if guest:
return guest._init_messaging()
raise NotFound()
@http.route("/mail/load_message_failures", methods=["POST"], type="json", auth="user")
def mail_load_message_failures(self):
# sudo as to not check ACL, which is far too costly
# sudo: res.users - return only failures of current user as author
return request.env.user.partner_id._message_fetch_failed()