aboutsummaryrefslogtreecommitdiff
path: root/rhodecode/model/comment.py
diff options
context:
space:
mode:
authorMarcin Kuzminski <marcin@python-works.com>2011-11-23 22:46:14 +0200
committerMarcin Kuzminski <marcin@python-works.com>2011-11-23 22:46:14 +0200
commita0fd7484c424b8c6282ec319e774985d3e94598a (patch)
tree8d7f7a934285cd4347e204214e467945f560daa7 /rhodecode/model/comment.py
parent57a5a5acbfbbc41ce98b892da30c1dae43178513 (diff)
notification to commit author + gardening
--HG-- branch : beta
Diffstat (limited to 'rhodecode/model/comment.py')
-rw-r--r--rhodecode/model/comment.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/rhodecode/model/comment.py b/rhodecode/model/comment.py
index 04fe4c80..887f9ecc 100644
--- a/rhodecode/model/comment.py
+++ b/rhodecode/model/comment.py
@@ -41,7 +41,7 @@ log = logging.getLogger(__name__)
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 @@ class ChangesetCommentsModel(BaseModel):
"""
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 @@ class ChangesetCommentsModel(BaseModel):
)
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):