# HG changeset patch # User Thomas De Schampheleire # Date 1584832446 -3600 # Node ID fcff67b0de83bae7cd09fc8a910b8f977984dd54 # Parent f6ee6d26b9bda6deea59bec506e0352cf3b66889 notifications: explicitly add author of pull request in invitation mail When an author of a pull request does not get feedback from any of the reviewers, he is left wondering whether they got the invitation mail at all. By explicitly sending the invitation also to the author, he can at least know if e-mail works at the server side and how reviewers see it. The mail can also be forwarded as a 'reminder'. diff -r f6ee6d26b9bd -r fcff67b0de83 kallithea/model/notification.py --- a/kallithea/model/notification.py Sun May 10 21:31:56 2020 +0200 +++ b/kallithea/model/notification.py Sun Mar 22 00:14:06 2020 +0100 @@ -126,12 +126,18 @@ email_html_body = EmailNotificationModel() \ .get_email_tmpl(type_, 'html', **html_kwargs) - # don't send email to person who created this comment - rec_objs = set(recipients_objs).difference(set([created_by_obj])) + # don't send email to the person who caused the notification, except for + # notifications about new pull requests where the author is explicitly + # added. + rec_mails = set(obj.email for obj in recipients_objs) + if type_ == NotificationModel.TYPE_PULL_REQUEST: + rec_mails.add(created_by_obj.email) + else: + rec_mails.discard(created_by_obj.email) - # send email with notification to all other participants - for rec in rec_objs: - tasks.send_email([rec.email], email_subject, email_txt_body, + # send email with notification to participants + for rec_mail in sorted(rec_mails): + tasks.send_email([rec_mail], email_subject, email_txt_body, email_html_body, headers, from_name=created_by_obj.full_name_or_username) diff -r f6ee6d26b9bd -r fcff67b0de83 kallithea/tests/models/test_dump_html_mails.ref.html --- a/kallithea/tests/models/test_dump_html_mails.ref.html Sun May 10 21:31:56 2020 +0200 +++ b/kallithea/tests/models/test_dump_html_mails.ref.html Sun Mar 22 00:14:06 2020 +0100 @@ -882,6 +882,197 @@

pull_request, is_mention=False

 From: u1 u1 
+To: u1@example.com
+Subject: [Review] repo/name PR #7 "The Title" from devbranch by u2
+
+
+
http://pr.org/7
+
+Added as Reviewer of Pull Request #7 "The Title" by Requesting User (root)
+
+
+Pull request #7 "The Title" by u2 u3 (u2)
+from https://dev.org/repo branch devbranch
+to http://mainline.com/repo branch trunk
+
+
+Description:
+
+This PR is 'awesome' because it does 
+ - please approve indented!
+
+
+Changesets:
+
+Introduce one and two
+Make one plus two equal tree
+
+
+View Pull Request: http://pr.org/7
+
+
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + +
+ Added as Reviewer of Pull Request #7 "The Title" by Requesting User (root) +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+
+ Pull request + #7 "The Title" + by + u2 u3 (u2). +
+
+ from + https://dev.org/repo + branch + devbranch +
+ to + http://mainline.com/repo + branch + trunk +
+
+
+ Description: +
+
+ + + + + + + + + + + + +
+
This PR is 'awesome' because it does <stuff>
- please approve indented!
+
+
+
Changesets:
+
+ +
+
+ + + + + + + +
+ +
+ + View Pull Request + +
+
+
+
+
+
+
+ + +
+
+

pull_request, is_mention=False

+
+From: u1 u1 
 To: u2@example.com
 Subject: [Review] repo/name PR #7 "The Title" from devbranch by u2
 
@@ -1073,6 +1264,197 @@

pull_request, is_mention=True

 From: u1 u1 
+To: u1@example.com
+Subject: [Review] repo/name PR #7 "The Title" from devbranch by u2
+
+
+
http://pr.org/7
+
+Mention on Pull Request #7 "The Title" by Requesting User (root)
+
+
+Pull request #7 "The Title" by u2 u3 (u2)
+from https://dev.org/repo branch devbranch
+to http://mainline.com/repo branch trunk
+
+
+Description:
+
+This PR is 'awesome' because it does 
+ - please approve indented!
+
+
+Changesets:
+
+Introduce one and two
+Make one plus two equal tree
+
+
+View Pull Request: http://pr.org/7
+
+
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + +
+ Mention on Pull Request #7 "The Title" by Requesting User (root) +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+
+ Pull request + #7 "The Title" + by + u2 u3 (u2). +
+
+ from + https://dev.org/repo + branch + devbranch +
+ to + http://mainline.com/repo + branch + trunk +
+
+
+ Description: +
+
+ + + + + + + + + + + + +
+
This PR is 'awesome' because it does <stuff>
- please approve indented!
+
+
+
Changesets:
+
+ +
+
+ + + + + + + +
+ +
+ + View Pull Request + +
+
+
+
+
+
+
+ + +
+
+

pull_request, is_mention=True

+
+From: u1 u1 
 To: u2@example.com
 Subject: [Review] repo/name PR #7 "The Title" from devbranch by u2