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.

17 lines
587 B

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