Changeset - c25392980f91
[Not reviewed]
stable
0 1 0
Thomas De Schampheleire - 9 years ago 2016-10-11 17:45:40
thomas.de.schampheleire@gmail.com
Grafted from: 84099c5e0920
email: add X-Kallithea-Notification-Type header

To simplify email filtering, add a header indicating the type of email being
sent. The 'type_' value corresponds to one of the types defined in class
Notification in kallithea/model/db.py, e.g. 'cs_comment', 'pull_request',
'pull_request_comment', ...
1 file changed with 3 insertions and 2 deletions:
0 comments (0 inline, 0 general)
kallithea/model/notification.py
Show inline comments
 
@@ -105,27 +105,28 @@ class NotificationModel(BaseModel):
 
        # TODO: inform user who are notified
 
        notif = Notification.create(
 
            created_by=created_by_obj, subject=subject,
 
            body=body, recipients=recipients_objs, type_=type_
 
        )
 

	
 
        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 = None
 
        headers = {}
 
        headers['X-Kallithea-Notification-Type'] = type_
 
        if 'threading' in email_kwargs:
 
            headers = {'References': ' '.join('<%s>' % x for x in email_kwargs['threading'])}
 
            headers['References'] = ' '.join('<%s>' % x for x in email_kwargs['threading'])
 

	
 
        # send email with notification to all other participants
 
        for rec in rec_objs:
 
            ## this is passed into template
 
            html_kwargs = {
 
                      'subject': subject,
 
                      'body': h.rst_w_mentions(body),
 
                      'when': h.fmt_date(notif.created_on),
 
                      'user': notif.created_by_user.username,
 
                      }
 

	
 
            txt_kwargs = {
0 comments (0 inline, 0 general)