[MERGE] merge with latest trunk

bzr revid: amb@tinyerp.com-20130620045831-28d3qp2ue4iadkes
This commit is contained in:
Amit Bhavsar (Open ERP)
2013-06-20 10:28:31 +05:30
+18
View File
@@ -1,4 +1,7 @@
import base64
import openerp
from openerp import SUPERUSER_ID
import openerp.addons.web.http as oeweb
from openerp.addons.web.controllers.main import content_disposition
@@ -20,3 +23,18 @@ class MailController(oeweb.Controller):
headers=[('Content-Type', 'application/octet-stream'),
('Content-Disposition', content_disposition(filename, req))])
return req.not_found()
@oeweb.jsonrequest
def receive(self, req):
""" End-point to receive mail from an external SMTP server. """
dbs = req.jsonrequest.get('databases')
for db in dbs:
message = dbs[db].decode('base64')
try:
registry = openerp.registry(db)
with registry.cursor() as cr:
mail_thread = registry['mail.thread']
mail_thread.message_process(cr, SUPERUSER_ID, None, message)
except psycopg2.Error:
pass
return True