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.

19 lines
662 B

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