Mercurial > kallithea
comparison rhodecode/model/notification.py @ 3781:40d50bb7cf2f beta
emailing: log failing emailing as an error
TODO: The failure should be reported back to the user (or the admins). The
system should not silently not send any emails to the targeted recipients.
Even better: it should inform the user whenever emails was (scheduled to be)
sent - and to whom.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Wed, 10 Apr 2013 03:00:38 +0200 |
parents | ec6354949623 |
children | ffd45b185016 |
comparison
equal
deleted
inserted
replaced
3780:1de8abd9a4e1 | 3781:40d50bb7cf2f |
---|---|
83 recipients_objs = [] | 83 recipients_objs = [] |
84 for u in recipients: | 84 for u in recipients: |
85 obj = self._get_user(u) | 85 obj = self._get_user(u) |
86 if obj: | 86 if obj: |
87 recipients_objs.append(obj) | 87 recipients_objs.append(obj) |
88 else: | |
89 # TODO: inform user that requested operation couldn't be completed | |
90 log.error('cannot email unknown user %r', u) | |
88 recipients_objs = set(recipients_objs) | 91 recipients_objs = set(recipients_objs) |
89 log.debug('sending notifications %s to %s' % ( | 92 log.debug('sending notifications %s to %s' % ( |
90 type_, recipients_objs) | 93 type_, recipients_objs) |
91 ) | 94 ) |
92 else: | 95 else: |
93 # empty recipients means to all admins | 96 # empty recipients means to all admins |
94 recipients_objs = User.query().filter(User.admin == True).all() | 97 recipients_objs = User.query().filter(User.admin == True).all() |
95 log.debug('sending notifications %s to admins: %s' % ( | 98 log.debug('sending notifications %s to admins: %s' % ( |
96 type_, recipients_objs) | 99 type_, recipients_objs) |
97 ) | 100 ) |
101 # TODO: inform user who are notified | |
98 notif = Notification.create( | 102 notif = Notification.create( |
99 created_by=created_by_obj, subject=subject, | 103 created_by=created_by_obj, subject=subject, |
100 body=body, recipients=recipients_objs, type_=type_ | 104 body=body, recipients=recipients_objs, type_=type_ |
101 ) | 105 ) |
102 | 106 |