Mercurial > kallithea
diff rhodecode/model/comment.py @ 1716:7d1fc253549e beta
notification to commit author + gardening
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Wed, 23 Nov 2011 22:46:14 +0200 |
parents | 54687aa00724 |
children | 7ff304d3028f |
line wrap: on
line diff
--- a/rhodecode/model/comment.py Wed Nov 23 22:26:54 2011 +0200 +++ b/rhodecode/model/comment.py Wed Nov 23 22:46:14 2011 +0200 @@ -41,7 +41,7 @@ class ChangesetCommentsModel(BaseModel): def __get_changeset_comment(self, changeset_comment): - return self.__get_instance(ChangesetComment, changeset_comment) + return self._get_instance(ChangesetComment, changeset_comment) def _extract_mentions(self, s): user_objects = [] @@ -65,7 +65,9 @@ """ if text: repo = Repository.get(repo_id) - desc = repo.scm_instance.get_changeset(revision).message + cs = repo.scm_instance.get_changeset(revision) + desc = cs.message + author = cs.author_email comment = ChangesetComment() comment.repo = repo comment.user_id = user_id @@ -90,11 +92,21 @@ ) body = text recipients = ChangesetComment.get_users(revision=revision) - recipients += self._extract_mentions(body) + # add changeset author + recipients += [User.get_by_email(author)] + NotificationModel().create(created_by=user_id, subject=subj, body=body, recipients=recipients, type_=Notification.TYPE_CHANGESET_COMMENT) + mention_recipients = set(self._extract_mentions(body)).difference(recipients) + if mention_recipients: + subj = _('[Mention]') + ' ' + subj + NotificationModel().create(created_by=user_id, subject=subj, + body = body, recipients = mention_recipients, + type_=Notification.TYPE_CHANGESET_COMMENT) + + self.sa.commit() return comment def delete(self, comment):