diff --git a/kallithea/model/notification.py b/kallithea/model/notification.py --- a/kallithea/model/notification.py +++ b/kallithea/model/notification.py @@ -98,40 +98,40 @@ class NotificationModel(object): if not with_email: return notif - # don't send email to person who created this comment - rec_objs = set(recipients_objs).difference(set([created_by_obj])) - headers = {} headers['X-Kallithea-Notification-Type'] = type_ if 'threading' in email_kwargs: headers['References'] = ' '.join('<%s>' % x for x in email_kwargs['threading']) + # this is passed into template + html_kwargs = { + 'subject': subject, + 'body': h.render_w_mentions(body, repo_name), + 'when': h.fmt_date(notif.created_on), + 'user': notif.created_by_user.username, + } + + txt_kwargs = { + 'subject': subject, + 'body': body, + 'when': h.fmt_date(notif.created_on), + 'user': notif.created_by_user.username, + } + + html_kwargs.update(email_kwargs) + txt_kwargs.update(email_kwargs) + email_subject = EmailNotificationModel() \ + .get_email_description(type_, **txt_kwargs) + email_txt_body = EmailNotificationModel() \ + .get_email_tmpl(type_, 'txt', **txt_kwargs) + 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])) + # send email with notification to all other participants for rec in rec_objs: - # this is passed into template - html_kwargs = { - 'subject': subject, - 'body': h.render_w_mentions(body, repo_name), - 'when': h.fmt_date(notif.created_on), - 'user': notif.created_by_user.username, - } - - txt_kwargs = { - 'subject': subject, - 'body': body, - 'when': h.fmt_date(notif.created_on), - 'user': notif.created_by_user.username, - } - - html_kwargs.update(email_kwargs) - txt_kwargs.update(email_kwargs) - email_subject = EmailNotificationModel() \ - .get_email_description(type_, **txt_kwargs) - email_txt_body = EmailNotificationModel() \ - .get_email_tmpl(type_, 'txt', **txt_kwargs) - email_html_body = EmailNotificationModel() \ - .get_email_tmpl(type_, 'html', **html_kwargs) - tasks.send_email([rec.email], email_subject, email_txt_body, email_html_body, headers, author=created_by_obj)