From 683132d4570611ac08d9c2bf1b12ca60326effde Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Mar 30 2015 21:52:19 +0000 Subject: Parse the APP_URL to replace the domain name by `localhost` --- diff --git a/milters/comment_email_milter.py b/milters/comment_email_milter.py index eefaeb8..0de0274 100644 --- a/milters/comment_email_milter.py +++ b/milters/comment_email_milter.py @@ -8,6 +8,7 @@ import base64 import email import os +import urlparse import StringIO import sys import time @@ -164,10 +165,13 @@ class PagureMilter(Milter.Base): 'comment': get_email_body(emailobj), 'useremail': clean_item(emailobj['From']), } - url = pagure.APP.config.get('APP_URL') + url = urlparse.urlparse(pagure.APP.config.get('APP_URL')).path + if url.endswith('/'): url = url[:-1] - url += '/pv/ticket/comment/' + if url.startswith('/'): + url = url[1:] + url = 'http://localhost/%s/pv/ticket/comment/' % url req = requests.put(url, data=data) return Milter.ACCEPT @@ -199,10 +203,13 @@ class PagureMilter(Milter.Base): 'comment': get_email_body(emailobj), 'useremail': clean_item(emailobj['From']), } - url = pagure.APP.config.get('APP_URL') + url = urlparse.urlparse(pagure.APP.config.get('APP_URL')).path + if url.endswith('/'): url = url[:-1] - url += '/pv/pull-request/comment/' + if url.startswith('/'): + url = url[1:] + url = 'http://localhost/%s/pv/pull-request/comment/' % url req = requests.put(url, data=data) return Milter.ACCEPT