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.

21 lines
650 B

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