comparison kallithea/model/comment.py @ 4384:0529498575ce

notifications: insert 'References' mail headers to help MUA threading gmail is however fubar.
author Mads Kiilerich <madski@unity3d.com>
date Fri, 18 Jul 2014 19:22:01 +0200
parents 55f2f2b4c462
children 231442b0b6aa
comparison
equal deleted inserted replaced
4383:2bb17f6f3044 4384:0529498575ce
80 if revision: 80 if revision:
81 notification_type = Notification.TYPE_CHANGESET_COMMENT 81 notification_type = Notification.TYPE_CHANGESET_COMMENT
82 cs = repo.scm_instance.get_changeset(revision) 82 cs = repo.scm_instance.get_changeset(revision)
83 desc = "%s" % (cs.short_id) 83 desc = "%s" % (cs.short_id)
84 84
85 _url = h.url('changeset_home', 85 revision_url = h.url('changeset_home',
86 repo_name=repo.repo_name,
87 revision=revision,
88 qualified=True,)
89 comment_url = h.url('changeset_home',
86 repo_name=repo.repo_name, 90 repo_name=repo.repo_name,
87 revision=revision, 91 revision=revision,
88 anchor='comment-%s' % comment.comment_id, 92 anchor='comment-%s' % comment.comment_id,
89 qualified=True, 93 qualified=True,
90 ) 94 )
91 subj = safe_unicode( 95 subj = safe_unicode(
92 h.link_to('Re changeset: %(desc)s %(line)s' % \ 96 h.link_to('Re changeset: %(desc)s %(line)s' % \
93 {'desc': desc, 'line': line}, 97 {'desc': desc, 'line': line},
94 _url) 98 comment_url)
95 ) 99 )
96 # get the current participants of this changeset 100 # get the current participants of this changeset
97 recipients = ChangesetComment.get_users(revision=revision) 101 recipients = ChangesetComment.get_users(revision=revision)
98 # add changeset author if it's in kallithea system 102 # add changeset author if it's in kallithea system
99 cs_author = User.get_from_cs_author(cs.author) 103 cs_author = User.get_from_cs_author(cs.author)
104 email_kwargs = { 108 email_kwargs = {
105 'status_change': status_change, 109 'status_change': status_change,
106 'cs_comment_user': h.person(user), 110 'cs_comment_user': h.person(user),
107 'cs_target_repo': h.url('summary_home', repo_name=repo.repo_name, 111 'cs_target_repo': h.url('summary_home', repo_name=repo.repo_name,
108 qualified=True), 112 qualified=True),
109 'cs_comment_url': _url, 113 'cs_comment_url': comment_url,
110 'raw_id': revision, 114 'raw_id': revision,
111 'message': cs.message, 115 'message': cs.message,
112 'repo_name': repo.repo_name, 116 'repo_name': repo.repo_name,
113 'short_id': h.short_id(revision), 117 'short_id': h.short_id(revision),
114 'branch': cs.branch, 118 'branch': cs.branch,
115 'comment_username': user.username, 119 'comment_username': user.username,
120 'threading': [revision_url, comment_url], # TODO: url to line number
116 } 121 }
117 #pull request 122 #pull request
118 elif pull_request: 123 elif pull_request:
119 notification_type = Notification.TYPE_PULL_REQUEST_COMMENT 124 notification_type = Notification.TYPE_PULL_REQUEST_COMMENT
120 desc = comment.pull_request.title 125 desc = comment.pull_request.title
121 _org_ref_type, org_ref_name, _org_rev = comment.pull_request.org_ref.split(':') 126 _org_ref_type, org_ref_name, _org_rev = comment.pull_request.org_ref.split(':')
122 _url = h.url('pullrequest_show', 127 pr_url = h.url('pullrequest_show',
128 repo_name=pull_request.other_repo.repo_name,
129 pull_request_id=pull_request.pull_request_id,
130 qualified=True,)
131 comment_url = h.url('pullrequest_show',
123 repo_name=pull_request.other_repo.repo_name, 132 repo_name=pull_request.other_repo.repo_name,
124 pull_request_id=pull_request.pull_request_id, 133 pull_request_id=pull_request.pull_request_id,
125 anchor='comment-%s' % comment.comment_id, 134 anchor='comment-%s' % comment.comment_id,
126 qualified=True, 135 qualified=True,
127 ) 136 )
128 subj = safe_unicode( 137 subj = safe_unicode(
129 h.link_to('Re pull request #%(pr_id)s: %(desc)s %(line)s' % \ 138 h.link_to('Re pull request #%(pr_id)s: %(desc)s %(line)s' % \
130 {'desc': desc, 139 {'desc': desc,
131 'pr_id': comment.pull_request.pull_request_id, 140 'pr_id': comment.pull_request.pull_request_id,
132 'line': line}, 141 'line': line},
133 _url) 142 comment_url)
134 ) 143 )
135 # get the current participants of this pull request 144 # get the current participants of this pull request
136 recipients = ChangesetComment.get_users(pull_request_id= 145 recipients = ChangesetComment.get_users(pull_request_id=
137 pull_request.pull_request_id) 146 pull_request.pull_request_id)
138 # add pull request author 147 # add pull request author
145 email_kwargs = { 154 email_kwargs = {
146 'pr_title': pull_request.title, 155 'pr_title': pull_request.title,
147 'pr_id': pull_request.pull_request_id, 156 'pr_id': pull_request.pull_request_id,
148 'status_change': status_change, 157 'status_change': status_change,
149 'closing_pr': closing_pr, 158 'closing_pr': closing_pr,
150 'pr_comment_url': _url, 159 'pr_comment_url': comment_url,
151 'pr_comment_user': h.person(user), 160 'pr_comment_user': h.person(user),
152 'pr_target_repo': h.url('summary_home', 161 'pr_target_repo': h.url('summary_home',
153 repo_name=pull_request.other_repo.repo_name, 162 repo_name=pull_request.other_repo.repo_name,
154 qualified=True), 163 qualified=True),
155 'repo_name': pull_request.other_repo.repo_name, 164 'repo_name': pull_request.other_repo.repo_name,
156 'ref': org_ref_name, 165 'ref': org_ref_name,
157 'comment_username': user.username, 166 'comment_username': user.username,
167 'threading': [pr_url, comment_url], # TODO: url to line number
158 } 168 }
159 169
160 return subj, body, recipients, notification_type, email_kwargs 170 return subj, body, recipients, notification_type, email_kwargs
161 171
162 def create(self, text, repo, user, revision=None, pull_request=None, 172 def create(self, text, repo, user, revision=None, pull_request=None,