From 5555fd53972d1c897575c521da21e7f4e117e78a Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: May 19 2015 15:53:19 +0000 Subject: [PATCH 1/2] Simplify the URL handling, just call what is set in the configuration --- diff --git a/milters/comment_email_milter.py b/milters/comment_email_milter.py index ccd4b87..2ef55e7 100644 --- a/milters/comment_email_milter.py +++ b/milters/comment_email_milter.py @@ -169,15 +169,11 @@ class PagureMilter(Milter.Base): 'comment': get_email_body(emailobj), 'useremail': clean_item(emailobj['From']), } - url = urlparse.urlparse(pagure.APP.config.get('APP_URL')).path + url = pagure.APP.config.get('APP_URL') if url.endswith('/'): url = url[:-1] - if not url.startswith('/'): - url = '/' + url - if url == '/': - url = '' - url = 'http://localhost%s/pv/ticket/comment/' % url + url = '%s/pv/ticket/comment/' % url req = requests.put(url, data=data) if req.status_code == 200: self.log('Comment added') @@ -201,15 +197,11 @@ class PagureMilter(Milter.Base): 'comment': get_email_body(emailobj), 'useremail': clean_item(emailobj['From']), } - url = urlparse.urlparse(pagure.APP.config.get('APP_URL')).path + url = pagure.APP.config.get('APP_URL') if url.endswith('/'): url = url[:-1] - if not url.startswith('/'): - url = '/' + url - if url == '/': - url = '' - url = 'http://localhost%s/pv/pull-request/comment/' % url + url = '%s/pv/pull-request/comment/' % url req = requests.put(url, data=data) return Milter.ACCEPT From df1cf7c5a1ad6f412f80a81f761b2a563ae82728 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: May 19 2015 15:53:41 +0000 Subject: [PATCH 2/2] Fix calling search_user by passing it the appropriate session object --- diff --git a/pagure/internal/__init__.py b/pagure/internal/__init__.py index 8101d03..e03690a 100644 --- a/pagure/internal/__init__.py +++ b/pagure/internal/__init__.py @@ -117,7 +117,7 @@ def ticket_add_comment(): if issue is None: flask.abort(404, 'Issue not found') - user_obj = pagure.lib.search_user(SESSION, email=useremail) + user_obj = pagure.lib.search_user(pagure.SESSION, email=useremail) admin = False if user_obj: admin = user_obj == issue.project.user.user or (