Skip to content

Supporting Release Connect 2.4.11 #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 23, 2019
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