[PATCH 4 of 5] e-mail: remove user and add relevant title to subject of e-mails

Thomas De Schampheleire patrickdepinguin at gmail.com
Mon Jul 13 04:45:10 EDT 2015


# HG changeset patch
# User Thomas De Schampheleire <thomas.de.schampheleire at gmail.com>
# Date 1436473046 -7200
#      Thu Jul 09 22:17:26 2015 +0200
# Node ID 46d77b6a81fb27aa9b7f247fed5138f1125ec019
# Parent  bdca2f365e3feb81ba7329b8f42eada6a342a811
e-mail: remove user and add relevant title to subject of e-mails

For comment and pullrequest mails:
- remove user that triggered the e-mail, as this is now in the From header.
- add changeset/pullrequest title (shortened to first 50 characters of first
  line)

Based on code by Cedric De Herdt.

diff --git a/kallithea/model/comment.py b/kallithea/model/comment.py
--- a/kallithea/model/comment.py
+++ b/kallithea/model/comment.py
@@ -105,6 +105,7 @@ class ChangesetCommentsModel(BaseModel):
                 'cs_comment_url': comment_url,
                 'raw_id': revision,
                 'message': cs.message,
+                'message_short': h.shorter(cs.message.splitlines()[0], 50),
                 'repo_name': repo.repo_name,
                 'short_id': h.short_id(revision),
                 'branch': cs.branch,
@@ -144,6 +145,7 @@ class ChangesetCommentsModel(BaseModel):
             #set some variables for email notification
             email_kwargs = {
                 'pr_title': pull_request.title,
+                'pr_title_short': h.shorter(pull_request.title, 50),
                 'pr_nice_id': pull_request.nice_id(),
                 'status_change': status_change,
                 'closing_pr': closing_pr,
diff --git a/kallithea/model/notification.py b/kallithea/model/notification.py
--- a/kallithea/model/notification.py
+++ b/kallithea/model/notification.py
@@ -299,13 +299,13 @@ class EmailNotificationModel(BaseModel):
             self.TYPE_PULL_REQUEST_COMMENT: 'pull_request_comment',
         }
         self._subj_map = {
-            self.TYPE_CHANGESET_COMMENT: _('[Comment from %(comment_username)s] %(repo_name)s changeset %(short_id)s on %(branch)s'),
+            self.TYPE_CHANGESET_COMMENT: _('[Comment] %(repo_name)s changeset %(short_id)s: "%(message_short)s" on %(branch)s'),
             self.TYPE_MESSAGE: 'Test Message',
             # self.TYPE_PASSWORD_RESET
             self.TYPE_REGISTRATION: _('New user %(new_username)s registered'),
             # self.TYPE_DEFAULT
-            self.TYPE_PULL_REQUEST: _('[Added by %(pr_username)s] %(repo_name)s pull request %(pr_nice_id)s from %(ref)s'),
-            self.TYPE_PULL_REQUEST_COMMENT: _('[Comment from %(comment_username)s] %(repo_name)s pull request %(pr_nice_id)s from %(ref)s'),
+            self.TYPE_PULL_REQUEST: _('[Added] %(repo_name)s pull request %(pr_nice_id)s: "%(pr_title_short)s" from %(ref)s'),
+            self.TYPE_PULL_REQUEST_COMMENT: _('[Comment] %(repo_name)s pull request %(pr_nice_id)s: "%(pr_title_short)s" from %(ref)s'),
         }
 
     def get_email_description(self, type_, **kwargs):


More information about the kallithea-general mailing list