Changeset - 40d50bb7cf2f
[Not reviewed]
beta
0 2 0
Mads Kiilerich - 13 years ago 2013-04-10 03:00:38
madski@unity3d.com
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.
2 files changed with 7 insertions and 5 deletions:
0 comments (0 inline, 0 general)
rhodecode/model/notification.py
Show inline comments
 
@@ -82,22 +82,26 @@ class NotificationModel(BaseModel):
 
        if recipients:
 
            recipients_objs = []
 
            for u in recipients:
 
                obj = self._get_user(u)
 
                if obj:
 
                    recipients_objs.append(obj)
 
                else:
 
                    # TODO: inform user that requested operation couldn't be completed
 
                    log.error('cannot email unknown user %r', u)
 
            recipients_objs = set(recipients_objs)
 
            log.debug('sending notifications %s to %s' % (
 
                type_, recipients_objs)
 
            )
 
        else:
 
            # empty recipients means to all admins
 
            recipients_objs = User.query().filter(User.admin == True).all()
 
            log.debug('sending notifications %s to admins: %s' % (
 
                type_, recipients_objs)
 
            )
 
        # 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:
rhodecode/model/pull_request.py
Show inline comments
 
@@ -86,14 +86,12 @@ class PullRequestModel(BaseModel):
 
            user=created_by_user,
 
            pull_request=new
 
        )
 
        revision_data = [(x.raw_id, x.message)
 
                         for x in map(org_repo.get_changeset, revisions)]
 
        #notification to reviewers
 
        notif = NotificationModel()
 

	
 
        pr_url = h.url('pullrequest_show', repo_name=other_repo.repo_name,
 
                       pull_request_id=new.pull_request_id,
 
                       qualified=True,
 
        )
 
        subject = safe_unicode(
 
            h.link_to(
 
@@ -111,15 +109,15 @@ class PullRequestModel(BaseModel):
 
            'pr_repo_url': h.url('summary_home', repo_name=other_repo.repo_name,
 
                                 qualified=True,),
 
            'pr_url': pr_url,
 
            'pr_revisions': revision_data
 
        }
 

	
 
        notif.create(created_by=created_by_user, subject=subject, body=body,
 
                     recipients=reviewers,
 
                     type_=Notification.TYPE_PULL_REQUEST, email_kwargs=kwargs)
 
        NotificationModel().create(created_by=created_by_user, subject=subject, body=body,
 
                                   recipients=reviewers,
 
                                   type_=Notification.TYPE_PULL_REQUEST, email_kwargs=kwargs)
 
        return new
 

	
 
    def update_reviewers(self, pull_request, reviewers_ids):
 
        reviewers_ids = set(reviewers_ids)
 
        pull_request = self.__get_pull_request(pull_request)
 
        current_reviewers = PullRequestReviewers.query()\
0 comments (0 inline, 0 general)