@@ -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 = / p h a s e # ( \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' ;
0 commit comments