##// END OF EJS Templates
code garden
marcink -
r2077:17960433 beta
parent child Browse files
Show More
@@ -92,22 +92,27 b' class ChangesetCommentsModel(BaseModel):'
92 )
92 )
93 )
93 )
94 body = text
94 body = text
95
96 # get the current participants of this changeset
95 recipients = ChangesetComment.get_users(revision=revision)
97 recipients = ChangesetComment.get_users(revision=revision)
98
96 # add changeset author
99 # add changeset author
97 recipients += [User.get_by_email(author)]
100 recipients += [User.get_by_email(author)]
98
101
99 NotificationModel().create(created_by=user_id, subject=subj,
102 NotificationModel().create(
100 body=body, recipients=recipients,
103 created_by=user_id, subject=subj, body=body,
101 type_=Notification.TYPE_CHANGESET_COMMENT)
104 recipients=recipients, type_=Notification.TYPE_CHANGESET_COMMENT
105 )
102
106
103 mention_recipients = set(self._extract_mentions(body))\
107 mention_recipients = set(self._extract_mentions(body))\
104 .difference(recipients)
108 .difference(recipients)
105 if mention_recipients:
109 if mention_recipients:
106 subj = _('[Mention]') + ' ' + subj
110 subj = _('[Mention]') + ' ' + subj
107 NotificationModel().create(created_by=user_id, subject=subj,
111 NotificationModel().create(
108 body=body,
112 created_by=user_id, subject=subj, body=body,
109 recipients=mention_recipients,
113 recipients=mention_recipients,
110 type_=Notification.TYPE_CHANGESET_COMMENT)
114 type_=Notification.TYPE_CHANGESET_COMMENT
115 )
111
116
112 return comment
117 return comment
113
118
@@ -85,13 +85,19 b' class NotificationModel(BaseModel):'
85 if obj:
85 if obj:
86 recipients_objs.append(obj)
86 recipients_objs.append(obj)
87 recipients_objs = set(recipients_objs)
87 recipients_objs = set(recipients_objs)
88 log.debug('sending notifications %s to %s' % (
89 type_, recipients_objs)
90 )
88 else:
91 else:
89 # empty recipients means to all admins
92 # empty recipients means to all admins
90 recipients_objs = User.query().filter(User.admin == True).all()
93 recipients_objs = User.query().filter(User.admin == True).all()
91
94 log.debug('sending notifications %s to admins: %s' % (
92 notif = Notification.create(created_by=created_by_obj, subject=subject,
95 type_, recipients_objs)
93 body=body, recipients=recipients_objs,
96 )
94 type_=type_)
97 notif = Notification.create(
98 created_by=created_by_obj, subject=subject,
99 body=body, recipients=recipients_objs, type_=type_
100 )
95
101
96 if with_email is False:
102 if with_email is False:
97 return notif
103 return notif
General Comments 0
You need to be logged in to leave comments. Login now