diff --git a/service/package-lock.json b/service/package-lock.json index 5eba6292..ce2dec40 100644 --- a/service/package-lock.json +++ b/service/package-lock.json @@ -1,12 +1,12 @@ { "name": "alkemio-notifications", - "version": "0.14.2", + "version": "0.14.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "alkemio-notifications", - "version": "0.14.2", + "version": "0.14.3", "license": "EUPL-1.2", "dependencies": { "@alkemio/client-lib": "^0.23.0", diff --git a/service/package.json b/service/package.json index 2cdd26d3..2136ce0c 100644 --- a/service/package.json +++ b/service/package.json @@ -1,6 +1,6 @@ { "name": "alkemio-notifications", - "version": "0.14.2", + "version": "0.14.3", "description": "Alkemio notifications service", "author": "Alkemio Foundation", "private": false, diff --git a/service/src/services/domain/builders/collaboration-post-created/collaboration.post.created.notification.builder.ts b/service/src/services/domain/builders/collaboration-post-created/collaboration.post.created.notification.builder.ts index a44b6584..2959819f 100644 --- a/service/src/services/domain/builders/collaboration-post-created/collaboration.post.created.notification.builder.ts +++ b/service/src/services/domain/builders/collaboration-post-created/collaboration.post.created.notification.builder.ts @@ -42,9 +42,19 @@ export class CollaborationPostCreatedNotificationBuilder }, ]; + const spaceIDTemplateVar = + !payload.journey?.challenge?.opportunity?.id && + !payload.journey?.challenge?.id + ? payload.journey.spaceID + : ''; + + const challengeIDTemplateVar = !payload.journey?.challenge?.opportunity?.id + ? payload.journey?.challenge?.id + : undefined; + const templateVariables = { - spaceID: payload.journey.spaceID, - challengeID: payload.journey?.challenge?.id ?? '', + spaceID: spaceIDTemplateVar, + challengeID: challengeIDTemplateVar ?? '', opportunityID: payload.journey?.challenge?.opportunity?.id ?? '', journeyID: payload.journey?.challenge?.opportunity?.id ?? diff --git a/service/src/services/domain/builders/collaboration-whiteboard-created/collaboration.whiteboard.created.notification.builder.ts b/service/src/services/domain/builders/collaboration-whiteboard-created/collaboration.whiteboard.created.notification.builder.ts index 72085c58..b3359a71 100644 --- a/service/src/services/domain/builders/collaboration-whiteboard-created/collaboration.whiteboard.created.notification.builder.ts +++ b/service/src/services/domain/builders/collaboration-whiteboard-created/collaboration.whiteboard.created.notification.builder.ts @@ -42,9 +42,19 @@ export class CollaborationWhiteboardCreatedNotificationBuilder }, ]; + const spaceIDTemplateVar = + !payload.journey?.challenge?.opportunity?.id && + !payload.journey?.challenge?.id + ? payload.journey.spaceID + : ''; + + const challengeIDTemplateVar = !payload.journey?.challenge?.opportunity?.id + ? payload.journey?.challenge?.id + : undefined; + const templateVariables = { - spaceID: payload.journey.spaceID, - challengeID: payload.journey?.challenge?.id ?? '', + spaceID: spaceIDTemplateVar, + challengeID: challengeIDTemplateVar ?? '', opportunityID: payload.journey?.challenge?.opportunity?.id ?? '', journeyID: payload.journey?.challenge?.opportunity?.id ?? diff --git a/service/src/services/domain/builders/community-application-created/community.application.created.notification.builder.ts b/service/src/services/domain/builders/community-application-created/community.application.created.notification.builder.ts index 0f5dfee6..e83ce660 100644 --- a/service/src/services/domain/builders/community-application-created/community.application.created.notification.builder.ts +++ b/service/src/services/domain/builders/community-application-created/community.application.created.notification.builder.ts @@ -42,11 +42,20 @@ export class CommunityApplicationCreatedNotificationBuilder preferenceType: UserPreferenceType.NotificationApplicationSubmitted, }, ]; + const spaceIDTemplateVar = + !payload.journey?.challenge?.opportunity?.id && + !payload.journey?.challenge?.id + ? payload.journey.spaceID + : ''; + + const challengeIDTemplateVar = !payload.journey?.challenge?.opportunity?.id + ? payload.journey?.challenge?.id + : undefined; const templateVariables = { applicantID: payload.applicantID, - spaceID: payload.journey.spaceID, - challengeID: payload.journey.challenge?.id ?? '', + spaceID: spaceIDTemplateVar, + challengeID: challengeIDTemplateVar ?? '', opportunityID: payload.journey.challenge?.opportunity?.id ?? '', }; diff --git a/service/src/services/domain/builders/community-new-member/community.new.member.notification.builder.ts b/service/src/services/domain/builders/community-new-member/community.new.member.notification.builder.ts index 21fa8ed7..3c07fa3e 100644 --- a/service/src/services/domain/builders/community-new-member/community.new.member.notification.builder.ts +++ b/service/src/services/domain/builders/community-new-member/community.new.member.notification.builder.ts @@ -43,10 +43,20 @@ export class CommunityNewMemberNotificationBuilder }, ]; + const spaceIDTemplateVar = + !payload.journey?.challenge?.opportunity?.id && + !payload.journey?.challenge?.id + ? payload.journey.spaceID + : ''; + + const challengeIDTemplateVar = !payload.journey?.challenge?.opportunity?.id + ? payload.journey?.challenge?.id + : undefined; + const templateVariables = { memberID: payload.userID, - spaceID: payload.journey.spaceID, - challengeID: payload.journey.challenge?.id ?? '', + spaceID: spaceIDTemplateVar, + challengeID: challengeIDTemplateVar ?? '', opportunityID: payload.journey.challenge?.opportunity?.id ?? '', };