Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions connect/notificationServices/email.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,33 @@ function handler(topicName, messageJSON, notification) {
};
eventMessage.data[eventMessage.data.type] = true;
_.assign(eventMessage.data, notification.contents);

// message service may return tags
// to understand if post notification is regarding phases or no, we will try to get phaseId from the tags
const tags = _.get(notification.contents, 'tags', [])
const PHASE_ID_REGEXP = /phase#(\d+)/
const phaseIds = tags.map((tag) => _.get(tag.match(PHASE_ID_REGEXP), '1', null))
const phaseId = _.find(phaseIds, (phaseId) => phaseId !== null)
if (phaseId) {
eventMessage.data.phaseId = phaseId;
}

// if the notification is regarding topic: dashboard topic, dashboard post or phase post
// we build a link to the post
if (eventMessage.data.topicId) {
// phase post
if (eventMessage.data.phaseId) {
eventMessage.data.postURL = `${config.CONNECT_URL}/projects/${eventMessage.data.projectId}/plan#phase-${eventMessage.data.phaseId}-posts-${eventMessage.data.postId}`;

// dashboard post
} else if (eventMessage.data.postId) {
eventMessage.data.postURL = `${config.CONNECT_URL}/projects/${eventMessage.data.projectId}#comment-${eventMessage.data.postId}`;

// dashboard topic
} else {
eventMessage.data.postURL = `${config.CONNECT_URL}/projects/${eventMessage.data.projectId}#feed-${eventMessage.data.topicId}`;
}
}

// default values that get overridden when the notification is about topics/posts updates
let reference = 'project';
Expand Down
4 changes: 2 additions & 2 deletions emails/src/partials/topics_and_posts.html
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
<tr>
<td class="empty-child-one"></td>
<td class="second-child" align="center">
<a href="{{@root.connectURL}}/projects/{{notifications.[0].projectId}}#feed-{{notifications.[0].topicId}}">
<a href="{{notifications.[0].postURL}}">
View post on Connect
</a>
</td>
Expand All @@ -196,7 +196,7 @@
<tr class="copy-link">
<td class="main-td">
<table class="main-child">
<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>
<tr><td><a href="{{notifications.[0].postURL}}">{{notifications.[0].postURL}}</a></td></tr>
</table>
</td>
</tr>
Expand Down