From a2efa3ccc5a16e24120f51d760d5f76d5c77e14b Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Aug 16 2015 16:16:46 +0000 Subject: [PATCH 1/2] Ensure we do not offer to reply by email if the milter is not set up --- diff --git a/pagure/lib/notify.py b/pagure/lib/notify.py index 882f8f5..b73412f 100644 --- a/pagure/lib/notify.py +++ b/pagure/lib/notify.py @@ -30,6 +30,10 @@ from kitchen.text.converters import to_bytes _i = 0 +REPLY_MSG = 'To reply, visit the link below' +if pagure.APP.config['EVENTSOURCE_SOURCE']: + REPLY_MSG += 'or just reply to this email' + def fedmsg_publish(*args, **kwargs): # pragma: no cover ''' Try to publish a message on the fedmsg bus. ''' @@ -239,10 +243,11 @@ def notify_new_comment(comment, user=None): %s `` -To reply, visit the link below or just reply to this email +%s %s """ % (comment.user.user, comment.comment, + REPLY_MSG, _build_url( pagure.APP.config['APP_URL'], comment.issue.project.name, @@ -274,11 +279,12 @@ def notify_new_issue(issue, user=None): %s `` -To reply, visit the link below or just reply to this email +%s %s """ % (issue.user.user, issue.project.name, issue.content, + REPLY_MSG, _build_url( pagure.APP.config['APP_URL'], issue.project.name, @@ -378,11 +384,12 @@ def notify_new_pull_request(request): %s `` -To reply, visit the link below or just reply to this email +%s %s """ % (request.user.user, request.project.name, request.title, + REPLY_MSG, _build_url( pagure.APP.config['APP_URL'], request.project.name, @@ -479,11 +486,12 @@ def notify_pull_request_comment(comment, user): %s `` -To reply, visit the link below or just reply to this email +%s %s """ % (comment.user.user, comment.pull_request.title, comment.comment, + REPLY_MSG, _build_url( pagure.APP.config['APP_URL'], comment.pull_request.project.name, From ceca759bedd10b6fe07ba58d91398b71e0e6c7ca Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Aug 16 2015 16:16:46 +0000 Subject: [PATCH 2/2] Move down the import so that we can import pagure.APP from the start --- diff --git a/pagure/__init__.py b/pagure/__init__.py index 2e91631..e726987 100644 --- a/pagure/__init__.py +++ b/pagure/__init__.py @@ -31,12 +31,6 @@ from pagure.flask_fas_openid import FAS from functools import wraps from sqlalchemy.exc import SQLAlchemyError -import pagure.lib -import pagure.mail_logging -import pagure.doc_utils -import pagure.forms -import pagure.login_forms - from pygments import highlight from pygments.lexers.text import DiffLexer from pygments.formatters import HtmlFormatter @@ -53,6 +47,13 @@ if 'PAGURE_CONFIG' in os.environ: APP.config.from_envvar('PAGURE_CONFIG') +import pagure.lib +import pagure.mail_logging +import pagure.doc_utils +import pagure.forms +import pagure.login_forms + + FAS = FAS(APP) SESSION = pagure.lib.create_session(APP.config['DB_URL']) REDIS = None