Skip to content

Commit 7235307

Browse files
author
vikasrohit
authoredApr 23, 2019
Merge pull request #105 from topcoder-platform/dev
Supporting Release Connect 2.4.11
2 parents cf08a26 + 783d367 commit 7235307

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed
 

‎connect/notificationServices/email.js

+26
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,33 @@ function handler(topicName, messageJSON, notification) {
245245
};
246246
eventMessage.data[eventMessage.data.type] = true;
247247
_.assign(eventMessage.data, notification.contents);
248+
249+
// message service may return tags
250+
// to understand if post notification is regarding phases or no, we will try to get phaseId from the tags
251+
const tags = _.get(notification.contents, 'tags', [])
252+
const PHASE_ID_REGEXP = /phase#(\d+)/
253+
const phaseIds = tags.map((tag) => _.get(tag.match(PHASE_ID_REGEXP), '1', null))
254+
const phaseId = _.find(phaseIds, (phaseId) => phaseId !== null)
255+
if (phaseId) {
256+
eventMessage.data.phaseId = phaseId;
257+
}
258+
259+
// if the notification is regarding topic: dashboard topic, dashboard post or phase post
260+
// we build a link to the post
261+
if (eventMessage.data.topicId) {
262+
// phase post
263+
if (eventMessage.data.phaseId) {
264+
eventMessage.data.postURL = `${config.CONNECT_URL}/projects/${eventMessage.data.projectId}/plan#phase-${eventMessage.data.phaseId}-posts-${eventMessage.data.postId}`;
265+
266+
// dashboard post
267+
} else if (eventMessage.data.postId) {
268+
eventMessage.data.postURL = `${config.CONNECT_URL}/projects/${eventMessage.data.projectId}#comment-${eventMessage.data.postId}`;
248269

270+
// dashboard topic
271+
} else {
272+
eventMessage.data.postURL = `${config.CONNECT_URL}/projects/${eventMessage.data.projectId}#feed-${eventMessage.data.topicId}`;
273+
}
274+
}
249275

250276
// default values that get overridden when the notification is about topics/posts updates
251277
let reference = 'project';

‎emails/src/partials/topics_and_posts.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@
170170
<tr>
171171
<td class="empty-child-one"></td>
172172
<td class="second-child" align="center">
173-
<a href="{{@root.connectURL}}/projects/{{notifications.[0].projectId}}#feed-{{notifications.[0].topicId}}">
173+
<a href="{{notifications.[0].postURL}}">
174174
View post on Connect
175175
</a>
176176
</td>
@@ -196,7 +196,7 @@
196196
<tr class="copy-link">
197197
<td class="main-td">
198198
<table class="main-child">
199-
<tr><td><a href="{{@root.connectURL}}/projects/{{notifications.[0].projectId}}#feed-{{notifications.[0].topicId}}">{{@root.connectURL}}/projects/{{notifications.[0].projectId}}#feed-{{notifications.[0].topicId}}</a></td></tr>
199+
<tr><td><a href="{{notifications.[0].postURL}}">{{notifications.[0].postURL}}</a></td></tr>
200200
</table>
201201
</td>
202202
</tr>

0 commit comments

Comments
 (0)
Please sign in to comment.