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.

18 lines
528 B

  1. # -*- coding: utf-8 -*-
  2. import requests
  3. from odoo import models, api
  4. import logging
  5. _logger = logging.getLogger(__name__)
  6. class MailThread(models.AbstractModel):
  7. _inherit = 'mail.thread'
  8. @api.model
  9. def mailgun_fetch_message(self, message_url):
  10. api_key = self.env['ir.config_parameter'].sudo().get_param('mailgun.apikey')
  11. res = requests.get(message_url, headers={'Accept': 'message/rfc2822'}, auth=('api', api_key), verify=False)
  12. self.message_process(False, res.json().get('body-mime'))