You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
563 B

  1. import re
  2. from odoo import http
  3. from odoo.http import request
  4. class MailMailgun(http.Controller):
  5. @http.route("/mailgun/notify", auth="public", type="http", csrf=False)
  6. def mailgun_notify(self, **kw):
  7. # mailgun notification in json format
  8. message_url = kw.get("message-url")
  9. if not re.match("^https://[^/]*api.mailgun.net/", message_url):
  10. # simple security check failed
  11. raise Exception("wrong message-url")
  12. request.env["mail.thread"].sudo().mailgun_fetch_message(message_url)
  13. return "ok"