Show More
@@ -257,7 +257,7 b' def get_commits_stats(repo_name, ts_min_' | |||
|
257 | 257 | |
|
258 | 258 | @task(ignore_result=True) |
|
259 | 259 | @dbsession |
|
260 | def send_email(recipients, subject, body='', html_body=''): | |
|
260 | def send_email(recipients, subject, body='', html_body='', headers=None): | |
|
261 | 261 | """ |
|
262 | 262 | Sends an email with defined parameters from the .ini files. |
|
263 | 263 | |
@@ -304,7 +304,7 b' def send_email(recipients, subject, body' | |||
|
304 | 304 | try: |
|
305 | 305 | m = SmtpMailer(mail_from, user, passwd, mail_server, smtp_auth, |
|
306 | 306 | mail_port, ssl, tls, debug=debug) |
|
307 | m.send(recipients, subject, body, html_body) | |
|
307 | m.send(recipients, subject, body, html_body, headers=headers) | |
|
308 | 308 | except: |
|
309 | 309 | log.error('Mail sending failed') |
|
310 | 310 | log.error(traceback.format_exc()) |
@@ -61,13 +61,13 b' class SmtpMailer(object):' | |||
|
61 | 61 | self.auth = smtp_auth |
|
62 | 62 | |
|
63 | 63 | def send(self, recipients=[], subject='', body='', html='', |
|
64 | attachment_files=None): | |
|
64 | attachment_files=None, headers=None): | |
|
65 | 65 | |
|
66 | 66 | if isinstance(recipients, basestring): |
|
67 | 67 | recipients = [recipients] |
|
68 |
headers |
|
|
69 | 'Date': formatdate(time.time()) | |
|
70 | } | |
|
68 | if headers is None: | |
|
69 | headers = {} | |
|
70 | headers.setdefault('Date', formatdate(time.time())) | |
|
71 | 71 | msg = Message(subject, recipients, body, html, self.mail_from, |
|
72 | 72 | recipients_separator=", ", extra_headers=headers) |
|
73 | 73 | raw_msg = msg.to_message() |
@@ -82,7 +82,11 b' class ChangesetCommentsModel(BaseModel):' | |||
|
82 | 82 | cs = repo.scm_instance.get_changeset(revision) |
|
83 | 83 | desc = "%s" % (cs.short_id) |
|
84 | 84 | |
|
85 | _url = h.url('changeset_home', | |
|
85 | revision_url = h.url('changeset_home', | |
|
86 | repo_name=repo.repo_name, | |
|
87 | revision=revision, | |
|
88 | qualified=True,) | |
|
89 | comment_url = h.url('changeset_home', | |
|
86 | 90 | repo_name=repo.repo_name, |
|
87 | 91 | revision=revision, |
|
88 | 92 | anchor='comment-%s' % comment.comment_id, |
@@ -91,7 +95,7 b' class ChangesetCommentsModel(BaseModel):' | |||
|
91 | 95 | subj = safe_unicode( |
|
92 | 96 | h.link_to('Re changeset: %(desc)s %(line)s' % \ |
|
93 | 97 | {'desc': desc, 'line': line}, |
|
94 | _url) | |
|
98 | comment_url) | |
|
95 | 99 | ) |
|
96 | 100 | # get the current participants of this changeset |
|
97 | 101 | recipients = ChangesetComment.get_users(revision=revision) |
@@ -106,20 +110,25 b' class ChangesetCommentsModel(BaseModel):' | |||
|
106 | 110 | 'cs_comment_user': h.person(user), |
|
107 | 111 | 'cs_target_repo': h.url('summary_home', repo_name=repo.repo_name, |
|
108 | 112 | qualified=True), |
|
109 | 'cs_comment_url': _url, | |
|
113 | 'cs_comment_url': comment_url, | |
|
110 | 114 | 'raw_id': revision, |
|
111 | 115 | 'message': cs.message, |
|
112 | 116 | 'repo_name': repo.repo_name, |
|
113 | 117 | 'short_id': h.short_id(revision), |
|
114 | 118 | 'branch': cs.branch, |
|
115 | 119 | 'comment_username': user.username, |
|
120 | 'threading': [revision_url, comment_url], # TODO: url to line number | |
|
116 | 121 | } |
|
117 | 122 | #pull request |
|
118 | 123 | elif pull_request: |
|
119 | 124 | notification_type = Notification.TYPE_PULL_REQUEST_COMMENT |
|
120 | 125 | desc = comment.pull_request.title |
|
121 | 126 | _org_ref_type, org_ref_name, _org_rev = comment.pull_request.org_ref.split(':') |
|
122 | _url = h.url('pullrequest_show', | |
|
127 | pr_url = h.url('pullrequest_show', | |
|
128 | repo_name=pull_request.other_repo.repo_name, | |
|
129 | pull_request_id=pull_request.pull_request_id, | |
|
130 | qualified=True,) | |
|
131 | comment_url = h.url('pullrequest_show', | |
|
123 | 132 | repo_name=pull_request.other_repo.repo_name, |
|
124 | 133 | pull_request_id=pull_request.pull_request_id, |
|
125 | 134 | anchor='comment-%s' % comment.comment_id, |
@@ -130,7 +139,7 b' class ChangesetCommentsModel(BaseModel):' | |||
|
130 | 139 | {'desc': desc, |
|
131 | 140 | 'pr_id': comment.pull_request.pull_request_id, |
|
132 | 141 | 'line': line}, |
|
133 | _url) | |
|
142 | comment_url) | |
|
134 | 143 | ) |
|
135 | 144 | # get the current participants of this pull request |
|
136 | 145 | recipients = ChangesetComment.get_users(pull_request_id= |
@@ -147,7 +156,7 b' class ChangesetCommentsModel(BaseModel):' | |||
|
147 | 156 | 'pr_id': pull_request.pull_request_id, |
|
148 | 157 | 'status_change': status_change, |
|
149 | 158 | 'closing_pr': closing_pr, |
|
150 | 'pr_comment_url': _url, | |
|
159 | 'pr_comment_url': comment_url, | |
|
151 | 160 | 'pr_comment_user': h.person(user), |
|
152 | 161 | 'pr_target_repo': h.url('summary_home', |
|
153 | 162 | repo_name=pull_request.other_repo.repo_name, |
@@ -155,6 +164,7 b' class ChangesetCommentsModel(BaseModel):' | |||
|
155 | 164 | 'repo_name': pull_request.other_repo.repo_name, |
|
156 | 165 | 'ref': org_ref_name, |
|
157 | 166 | 'comment_username': user.username, |
|
167 | 'threading': [pr_url, comment_url], # TODO: url to line number | |
|
158 | 168 | } |
|
159 | 169 | |
|
160 | 170 | return subj, body, recipients, notification_type, email_kwargs |
@@ -114,6 +114,10 b' class NotificationModel(BaseModel):' | |||
|
114 | 114 | #don't send email to person who created this comment |
|
115 | 115 | rec_objs = set(recipients_objs).difference(set([created_by_obj])) |
|
116 | 116 | |
|
117 | headers = None | |
|
118 | if 'threading' in email_kwargs: | |
|
119 | headers = {'References': ' '.join('<%s>' % x for x in email_kwargs['threading'])} | |
|
120 | ||
|
117 | 121 | # send email with notification to all other participants |
|
118 | 122 | for rec in rec_objs: |
|
119 | 123 | email_body = None # we set body to none, we just send HTML emails |
@@ -131,7 +135,7 b' class NotificationModel(BaseModel):' | |||
|
131 | 135 | .get_email_tmpl(type_, **kwargs) |
|
132 | 136 | |
|
133 | 137 | run_task(tasks.send_email, [rec.email], email_subject, email_body, |
|
134 | email_body_html) | |
|
138 | email_body_html, headers) | |
|
135 | 139 | |
|
136 | 140 | return notif |
|
137 | 141 |
@@ -144,6 +144,7 b' class PullRequestModel(BaseModel):' | |||
|
144 | 144 | 'pr_id': pr.pull_request_id, |
|
145 | 145 | 'ref': org_ref_name, |
|
146 | 146 | 'pr_username': pr.author.username, |
|
147 | 'threading': [pr_url], | |
|
147 | 148 | } |
|
148 | 149 | NotificationModel().create(created_by=pr.author, subject=subject, body=body, |
|
149 | 150 | recipients=reviewers, |
General Comments 0
You need to be logged in to leave comments.
Login now