From 78f9002b34a1f95b03de27924797708f48e59443 Mon Sep 17 00:00:00 2001 From: Neil Smyth <30729240+techsmyth@users.noreply.github.com> Date: Wed, 15 May 2024 16:14:41 +0200 Subject: [PATCH 1/2] added notification for changes in global roles (#305) * added notificaiton for changes in global roles; updated global role related rules * updated subject * updated payload for global roles changed to allow displaying the name of the person changing * added actor field * Fixed tests * Reverted default credentials * Fixed wrong privilege lookup * Fixed client-lib * Fix --------- Co-authored-by: Carlos Cano Co-authored-by: Valentin Yanakiev --- lib/package-lock.json | 4 +- lib/package.json | 2 +- lib/src/common/enums/role.change.type.ts | 5 ++ lib/src/dto/index.ts | 1 + ...atform.global.role.change.event.payload.ts | 11 +++ lib/src/index.ts | 1 + lib/src/notification.event.type.ts | 1 + service/notifications.yml | 45 +++++----- service/package-lock.json | 28 +++--- service/package.json | 4 +- service/src/app.controller.ts | 15 ++++ service/src/app.module.ts | 2 + ...atform.global.role.change.email.payload.ts | 18 ++++ service/src/common/enums/email.template.ts | 1 + ...n.recipient.template.provider.interface.ts | 1 + ...global.role.change.notification.builder.ts | 86 +++++++++++++++++++ .../notification/notification.service.spec.ts | 2 + .../notification/notification.service.ts | 12 +++ .../platform.global.role.change.admin.js | 23 +++++ 19 files changed, 220 insertions(+), 42 deletions(-) create mode 100644 lib/src/common/enums/role.change.type.ts create mode 100644 lib/src/dto/platform.global.role.change.event.payload.ts create mode 100644 service/src/common/email-template-payload/platform.global.role.change.email.payload.ts create mode 100644 service/src/services/domain/builders/platform-global-role-change/platform.global.role.change.notification.builder.ts create mode 100644 service/src/templates/platform.global.role.change.admin.js diff --git a/lib/package-lock.json b/lib/package-lock.json index 7a84d894..418e98e5 100644 --- a/lib/package-lock.json +++ b/lib/package-lock.json @@ -1,12 +1,12 @@ { "name": "@alkemio/notifications-lib", - "version": "0.7.0", + "version": "0.8.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@alkemio/notifications-lib", - "version": "0.7.0", + "version": "0.8.0", "license": "EUPL-1.2", "devDependencies": { "@types/node": "^16.4.6", diff --git a/lib/package.json b/lib/package.json index b652c84c..d44a2899 100644 --- a/lib/package.json +++ b/lib/package.json @@ -1,6 +1,6 @@ { "name": "@alkemio/notifications-lib", - "version": "0.7.1", + "version": "0.8.2", "description": "Library for interacting with Alkemio notifications service", "author": "Alkemio Foundation", "private": false, diff --git a/lib/src/common/enums/role.change.type.ts b/lib/src/common/enums/role.change.type.ts new file mode 100644 index 00000000..83e26a59 --- /dev/null +++ b/lib/src/common/enums/role.change.type.ts @@ -0,0 +1,5 @@ +// todo: remove once notifications can use the types directly from +export enum RoleChangeType { + ADDED = 'added', + REMOVED = 'removed', +} diff --git a/lib/src/dto/index.ts b/lib/src/dto/index.ts index 8d090496..78cec9ff 100644 --- a/lib/src/dto/index.ts +++ b/lib/src/dto/index.ts @@ -17,6 +17,7 @@ export * from './collaboration.post.created.event.payload'; export * from './collaboration.post.comment.event.payload'; export * from './collaboration.callout.published.event.payload'; export * from './collaboration.discussion.comment.event.payload'; +export * from './platform.global.role.change.event.payload'; export * from './platform.user.registration.event.payload'; export * from './platform.user.removed.event.payload'; export * from './platform.forum.discussion.comment.event.payload'; diff --git a/lib/src/dto/platform.global.role.change.event.payload.ts b/lib/src/dto/platform.global.role.change.event.payload.ts new file mode 100644 index 00000000..d4e2453a --- /dev/null +++ b/lib/src/dto/platform.global.role.change.event.payload.ts @@ -0,0 +1,11 @@ +import { RoleChangeType } from "@src/common/enums/role.change.type"; +import { BaseEventPayload } from "./base.event.payload"; +import { ContributorPayload } from "./contributor.payload"; + +export interface PlatformGlobalRoleChangeEventPayload + extends BaseEventPayload { + type: RoleChangeType; + user: ContributorPayload + role: string; + actor: ContributorPayload; +}; diff --git a/lib/src/index.ts b/lib/src/index.ts index 430dfb96..9d1864cc 100644 --- a/lib/src/index.ts +++ b/lib/src/index.ts @@ -1,3 +1,4 @@ export * from './notification.event.type'; export * from './dto'; export * from './common/enums/space.type'; +export * from './common/enums/role.change.type'; diff --git a/lib/src/notification.event.type.ts b/lib/src/notification.event.type.ts index 7417f9cb..6a4d14e6 100644 --- a/lib/src/notification.event.type.ts +++ b/lib/src/notification.event.type.ts @@ -17,6 +17,7 @@ export enum NotificationEventType { COLLABORATION_CALLOUT_PUBLISHED = 'collaborationCalloutPublished', PLATFORM_USER_REGISTERED = 'platformUserRegistered', PLATFORM_USER_REMOVED = 'platformUserRemoved', + PLATFORM_GLOBAL_ROLE_CHANGE = 'platformGlobalRoleChange', PLATFORM_FORUM_DISCUSSION_COMMENT = 'platformForumDiscussionComment', PLATFORM_FORUM_DISCUSSION_CREATED = 'platformForumDiscussionCreated', COMMENT_REPLY = 'commentReply', diff --git a/service/notifications.yml b/service/notifications.yml index 56f476e1..01b64b51 100644 --- a/service/notifications.yml +++ b/service/notifications.yml @@ -92,11 +92,13 @@ recipients: - rule: type: SPACE_ADMIN resource_id: + # We don't have SUBSPACE_ADMIN any more. We have SPACE_SUBSPACE_ADMIN, but it's different payload that needs to be provided for this to work (the resource_id should be the parent of the entity). + # toDo - clarify this rule + # - rule: + # type: SUBSPACE_ADMIN + # resource_id: - rule: - type: SUBSPACE_ADMIN - resource_id: - - rule: - type: GLOBAL_ADMIN_COMMUNITY + type: GLOBAL_COMMUNITY_READ resource_id: - rule: type: GLOBAL_ADMIN @@ -112,9 +114,9 @@ recipients: - rule: type: SPACE_ADMIN resource_id: - - rule: - type: SUBSPACE_ADMIN - resource_id: + # - rule: + # type: SUBSPACE_ADMIN + # resource_id: - name: member rules: - rule: @@ -140,9 +142,6 @@ recipients: communication_update_sent: - name: admin rules: - - rule: - type: GLOBAL_ADMIN_COMMUNITY - resource_id: - rule: type: GLOBAL_ADMIN resource_id: @@ -208,9 +207,9 @@ recipients: - rule: type: SPACE_ADMIN resource_id: - - rule: - type: SUBSPACE_ADMIN - resource_id: + # - rule: + # type: SUBSPACE_ADMIN + # resource_id: - name: user rules: - rule: @@ -225,9 +224,9 @@ recipients: - rule: type: SPACE_ADMIN resource_id: - - rule: - type: SUBSPACE_ADMIN - resource_id: + # - rule: + # type: SUBSPACE_ADMIN + # resource_id: - name: user rules: - rule: @@ -263,31 +262,31 @@ recipients: platform_user_registered: - name: admin rules: - - rule: - type: GLOBAL_ADMIN_COMMUNITY - resource_id: - rule: type: GLOBAL_ADMIN resource_id: - rule: - type: GLOBAL_ADMIN_SPACES + type: GLOBAL_SUPPORT resource_id: - name: registrant rules: - rule: type: USER_SELF_MANAGEMENT resource_id: - platform_user_removed: + platform_global_role_change: - name: admin rules: - rule: - type: GLOBAL_ADMIN_COMMUNITY + type: GLOBAL_ADMIN resource_id: + platform_user_removed: + - name: admin + rules: - rule: type: GLOBAL_ADMIN resource_id: - rule: - type: GLOBAL_ADMIN_SPACES + type: GLOBAL_SUPPORT resource_id: platform_forum_discussion_comment: - name: discussionCreator diff --git a/service/package-lock.json b/service/package-lock.json index 17d51e98..cd7a4ee4 100644 --- a/service/package-lock.json +++ b/service/package-lock.json @@ -9,8 +9,8 @@ "version": "0.16.0", "license": "EUPL-1.2", "dependencies": { - "@alkemio/client-lib": "^0.28.0", - "@alkemio/notifications-lib": "^0.7.1", + "@alkemio/client-lib": "^0.29.4", + "@alkemio/notifications-lib": "^0.8.2", "@nestjs/common": "^8.0.5", "@nestjs/config": "^1.0.1", "@nestjs/core": "^8.0.5", @@ -65,9 +65,9 @@ } }, "node_modules/@alkemio/client-lib": { - "version": "0.28.0", - "resolved": "https://registry.npmjs.org/@alkemio/client-lib/-/client-lib-0.28.0.tgz", - "integrity": "sha512-eh0/ub2K40yup9k3S+7IFzC4BUvkwufOCyOmHbtiefy9Rt4cjlybvt/fZNy1TIbkBex4cHuiJoXPUeakQJNfwA==", + "version": "0.29.4", + "resolved": "https://registry.npmjs.org/@alkemio/client-lib/-/client-lib-0.29.4.tgz", + "integrity": "sha512-vBPc8XvHuwP0uK/XuZqAIaCSMLBZBhZveehMfMNvE+wuBBzHhfHwtX1gWXadMlbMQDCrueTh/9GoKZNJGIZ0fg==", "dependencies": { "@graphql-codegen/typescript-graphql-request": "^4.5.3", "@graphql-codegen/typescript-operations": "^2.5.3", @@ -185,9 +185,9 @@ } }, "node_modules/@alkemio/notifications-lib": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/@alkemio/notifications-lib/-/notifications-lib-0.7.1.tgz", - "integrity": "sha512-X2Ik8UKMXopV7qGUxKhAJLLI9RekjatTXps5L1v1C3shLwT7hOtnaw7+fTU3/E6aYY9TMWPm+39l56HIFi28RA==", + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/@alkemio/notifications-lib/-/notifications-lib-0.8.2.tgz", + "integrity": "sha512-W+OCcC/0+icMqW0uk40SIYcfDnfWlGNEjkF9HkJ4w6RDA4xi5s0+B3OMK1Qu0o0TKq/hbTQGYgPBMh31piw5BQ==", "engines": { "node": ">=16.15.0", "npm": ">=8.5.5" @@ -14600,9 +14600,9 @@ }, "dependencies": { "@alkemio/client-lib": { - "version": "0.28.0", - "resolved": "https://registry.npmjs.org/@alkemio/client-lib/-/client-lib-0.28.0.tgz", - "integrity": "sha512-eh0/ub2K40yup9k3S+7IFzC4BUvkwufOCyOmHbtiefy9Rt4cjlybvt/fZNy1TIbkBex4cHuiJoXPUeakQJNfwA==", + "version": "0.29.4", + "resolved": "https://registry.npmjs.org/@alkemio/client-lib/-/client-lib-0.29.4.tgz", + "integrity": "sha512-vBPc8XvHuwP0uK/XuZqAIaCSMLBZBhZveehMfMNvE+wuBBzHhfHwtX1gWXadMlbMQDCrueTh/9GoKZNJGIZ0fg==", "requires": { "@graphql-codegen/typescript-graphql-request": "^4.5.3", "@graphql-codegen/typescript-operations": "^2.5.3", @@ -14670,9 +14670,9 @@ } }, "@alkemio/notifications-lib": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/@alkemio/notifications-lib/-/notifications-lib-0.7.1.tgz", - "integrity": "sha512-X2Ik8UKMXopV7qGUxKhAJLLI9RekjatTXps5L1v1C3shLwT7hOtnaw7+fTU3/E6aYY9TMWPm+39l56HIFi28RA==" + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/@alkemio/notifications-lib/-/notifications-lib-0.8.2.tgz", + "integrity": "sha512-W+OCcC/0+icMqW0uk40SIYcfDnfWlGNEjkF9HkJ4w6RDA4xi5s0+B3OMK1Qu0o0TKq/hbTQGYgPBMh31piw5BQ==" }, "@angular-devkit/core": { "version": "13.3.6", diff --git a/service/package.json b/service/package.json index edb23946..025953a1 100644 --- a/service/package.json +++ b/service/package.json @@ -35,8 +35,8 @@ "validate-connection": "ts-node src/utils/validate-connection.ts" }, "dependencies": { - "@alkemio/client-lib": "^0.28.0", - "@alkemio/notifications-lib": "^0.7.1", + "@alkemio/client-lib": "^0.29.4", + "@alkemio/notifications-lib": "^0.8.2", "@nestjs/common": "^8.0.5", "@nestjs/config": "^1.0.1", "@nestjs/core": "^8.0.5", diff --git a/service/src/app.controller.ts b/service/src/app.controller.ts index 8ac2b30c..aa2fc476 100644 --- a/service/src/app.controller.ts +++ b/service/src/app.controller.ts @@ -24,6 +24,7 @@ import { CommunicationOrganizationMentionEventPayload, CommunicationUpdateEventPayload, CommunityNewMemberPayload, + PlatformGlobalRoleChangeEventPayload, PlatformUserRegistrationEventPayload, CollaborationCalloutPublishedEventPayload, BaseEventPayload, @@ -109,6 +110,20 @@ export class AppController { ); } + @EventPattern(NotificationEventType.PLATFORM_GLOBAL_ROLE_CHANGE) + async sendGlobalRoleChangeNotification( + // todo is auto validation possible + @Payload() eventPayload: PlatformGlobalRoleChangeEventPayload, + @Ctx() context: RmqContext + ) { + this.sendNotifications( + eventPayload, + context, + this.notificationService.sendGlobalRoleChangeNotification(eventPayload), + NotificationEventType.PLATFORM_GLOBAL_ROLE_CHANGE + ); + } + @EventPattern(NotificationEventType.PLATFORM_USER_REGISTERED) async sendUserRegisteredNotification( // todo is auto validation possible diff --git a/service/src/app.module.ts b/service/src/app.module.ts index 47033b5e..eac2eb35 100644 --- a/service/src/app.module.ts +++ b/service/src/app.module.ts @@ -39,6 +39,7 @@ import { CommunityInvitationCreatedNotificationBuilder } from './services/domain import { CommentReplyNotificationBuilder } from './services/domain/builders/comment-reply/comment.reply.notification.builder'; import { CommunityExternalInvitationCreatedNotificationBuilder } from './services/domain/builders/community-external-invitation-created/community.external.invitation.created.notification.builder'; import { AlkemioUrlGeneratorModule } from './services/application/alkemio-url-generator/alkemio.url.generator.module'; +import { PlatformGlobalRoleChangeNotificationBuilder } from './services/domain/builders/platform-global-role-change/platform.global.role.change.notification.builder'; @Module({ imports: [ @@ -66,6 +67,7 @@ import { AlkemioUrlGeneratorModule } from './services/application/alkemio-url-ge CommunityApplicationCreatedNotificationBuilder, CommunityInvitationCreatedNotificationBuilder, CommunityExternalInvitationCreatedNotificationBuilder, + PlatformGlobalRoleChangeNotificationBuilder, PlatformUserRegisteredNotificationBuilder, PlatformUserRemovedNotificationBuilder, PlatformForumDiscussionCommentNotificationBuilder, diff --git a/service/src/common/email-template-payload/platform.global.role.change.email.payload.ts b/service/src/common/email-template-payload/platform.global.role.change.email.payload.ts new file mode 100644 index 00000000..e4087146 --- /dev/null +++ b/service/src/common/email-template-payload/platform.global.role.change.email.payload.ts @@ -0,0 +1,18 @@ +import { RoleChangeType } from '@alkemio/notifications-lib'; +import { BaseEmailPayload } from './base.email.payload'; + +export interface PlatformGlobalRoleChangeEmailPayload extends BaseEmailPayload { + user: { + displayName: string; + firstName: string; + email: string; + profile: string; + }; + actor: { + displayName: string; + url: string; + }; + type: RoleChangeType; + role: string; + triggeredBy: string; +} diff --git a/service/src/common/enums/email.template.ts b/service/src/common/enums/email.template.ts index f330c2e7..7977da77 100644 --- a/service/src/common/enums/email.template.ts +++ b/service/src/common/enums/email.template.ts @@ -29,6 +29,7 @@ export enum EmailTemplate { COLLABORATION_WHITEBOARD_CREATED_MEMBER = 'collaboration.whiteboard.created.member', COLLABORATION_CALLOUT_PUBLISHED_MEMBER = 'collaboration.callout.published.member', COLLABORATION_DISCUSSION_COMMENT_MEMBER = 'collaboration.discussion.comment.member', + PLATFORM_GLOBAL_ROLE_CHANGE_ADMIN = 'platform.global.role.change.admin', PLATFORM_USER_REGISTRATION_REGISTRANT = 'platform.user.registration.registrant', PLATFORM_USER_REGISTRATION_ADMIN = 'platform.user.registration.admin', PLATFORM_USER_REMOVED_ADMIN = 'platform.user.removed.admin', diff --git a/service/src/core/contracts/notification.recipient.template.provider.interface.ts b/service/src/core/contracts/notification.recipient.template.provider.interface.ts index 9b6e8b02..2977b99f 100644 --- a/service/src/core/contracts/notification.recipient.template.provider.interface.ts +++ b/service/src/core/contracts/notification.recipient.template.provider.interface.ts @@ -32,6 +32,7 @@ export type TemplateConfig = { collaboration_review_submitted?: TemplateRuleSet[]; collaboration_interest?: TemplateRuleSet[]; collaboration_callout_published?: TemplateRuleSet[]; + platform_global_role_change?: TemplateRuleSet[]; platform_user_registered?: TemplateRuleSet[]; platform_user_removed?: TemplateRuleSet[]; platform_forum_discussion_comment?: TemplateRuleSet[]; diff --git a/service/src/services/domain/builders/platform-global-role-change/platform.global.role.change.notification.builder.ts b/service/src/services/domain/builders/platform-global-role-change/platform.global.role.change.notification.builder.ts new file mode 100644 index 00000000..f65c2fb9 --- /dev/null +++ b/service/src/services/domain/builders/platform-global-role-change/platform.global.role.change.notification.builder.ts @@ -0,0 +1,86 @@ +import { Injectable } from '@nestjs/common'; +import { NotificationEventType } from '@alkemio/notifications-lib'; +import { ExternalUser, User } from '@core/models'; +import { INotificationBuilder } from '@core/contracts/notification.builder.interface'; +import { NotificationBuilder, RoleConfig } from '../../../application'; +import { UserPreferenceType } from '@alkemio/client-lib'; +import { EmailTemplate } from '@common/enums/email.template'; +import { NotificationTemplateType } from '@src/types/notification.template.type'; +import { AlkemioUrlGenerator } from '@src/services/application/alkemio-url-generator/alkemio.url.generator'; +import { PlatformGlobalRoleChangeEmailPayload } from '@src/common/email-template-payload/platform.global.role.change.email.payload'; +import { PlatformGlobalRoleChangeEventPayload } from '@alkemio/notifications-lib'; + +@Injectable() +export class PlatformGlobalRoleChangeNotificationBuilder + implements INotificationBuilder +{ + constructor( + private readonly alkemioUrlGenerator: AlkemioUrlGenerator, + private readonly notificationBuilder: NotificationBuilder< + PlatformGlobalRoleChangeEventPayload, + PlatformGlobalRoleChangeEmailPayload + > + ) {} + + build( + payload: PlatformGlobalRoleChangeEventPayload + ): Promise { + const roleConfig: RoleConfig[] = [ + { + role: 'admin', + emailTemplate: EmailTemplate.PLATFORM_GLOBAL_ROLE_CHANGE_ADMIN, + preferenceType: UserPreferenceType.NotificationUserSignUp, + }, + ]; + + const templateVariables = { registrantID: payload.user.id }; + + return this.notificationBuilder.build({ + payload, + eventUserId: payload.user.id, + roleConfig, + templateType: 'platform_global_role_change', + templateVariables, + templatePayloadBuilderFn: this.createTemplatePayload.bind(this), + }); + } + + private createTemplatePayload( + eventPayload: PlatformGlobalRoleChangeEventPayload, + recipient: User | ExternalUser, + user?: User + ): PlatformGlobalRoleChangeEmailPayload { + if (!user) { + throw Error( + `User not provided for '${NotificationEventType.PLATFORM_GLOBAL_ROLE_CHANGE}' event` + ); + } + + const notificationPreferenceURL = + this.alkemioUrlGenerator.createUserNotificationPreferencesURL(recipient); + return { + emailFrom: 'info@alkem.io', + user: { + displayName: user.profile.displayName, + firstName: user.firstName, + email: user.email, + profile: user.profile.url, + }, + actor: { + displayName: eventPayload.actor.profile.displayName, + url: eventPayload.actor.profile.url, + }, + recipient: { + firstName: recipient.firstName, + email: recipient.email, + notificationPreferences: notificationPreferenceURL, + }, + role: eventPayload.role, + type: eventPayload.type, + platform: { + url: eventPayload.platform.url, + }, + triggeredBy: eventPayload.triggeredBy, + }; + } +} diff --git a/service/src/services/domain/notification/notification.service.spec.ts b/service/src/services/domain/notification/notification.service.spec.ts index 5925a58d..15279980 100644 --- a/service/src/services/domain/notification/notification.service.spec.ts +++ b/service/src/services/domain/notification/notification.service.spec.ts @@ -45,6 +45,7 @@ import { import { NotificationTemplateType } from '@src/types'; import { CollaborationWhiteboardCreatedNotificationBuilder } from '../builders/collaboration-whiteboard-created/collaboration.whiteboard.created.notification.builder'; import { CollaborationDiscussionCommentNotificationBuilder } from '../builders/collaboration-discussion-comment/collaboration.discussion.comment.notification.builder'; +import { PlatformGlobalRoleChangeNotificationBuilder } from '../builders/platform-global-role-change/platform.global.role.change.notification.builder'; const testData = { ...challengeAdminsData, @@ -89,6 +90,7 @@ describe('NotificationService', () => { CollaborationDiscussionCommentNotificationBuilder, CollaborationCalloutPublishedNotificationBuilder, CommentReplyNotificationBuilder, + PlatformGlobalRoleChangeNotificationBuilder, MockNotificationBuilderProvider, MockConfigServiceProvider, MockAlkemioClientAdapterProvider, diff --git a/service/src/services/domain/notification/notification.service.ts b/service/src/services/domain/notification/notification.service.ts index dc7c46c3..18892ab7 100644 --- a/service/src/services/domain/notification/notification.service.ts +++ b/service/src/services/domain/notification/notification.service.ts @@ -55,6 +55,8 @@ import { CollaborationWhiteboardCreatedNotificationBuilder } from '../builders/c import { CollaborationDiscussionCommentNotificationBuilder } from '../builders/collaboration-discussion-comment/collaboration.discussion.comment.notification.builder'; import { CommentReplyNotificationBuilder } from '../builders/comment-reply/comment.reply.notification.builder'; import { CommunityExternalInvitationCreatedEventPayload } from '@alkemio/notifications-lib'; +import { PlatformGlobalRoleChangeNotificationBuilder } from '../builders/platform-global-role-change/platform.global.role.change.notification.builder'; +import { PlatformGlobalRoleChangeEventPayload } from '@alkemio/notifications-lib'; @Injectable() export class NotificationService { @@ -68,6 +70,7 @@ export class NotificationService { private communityApplicationCreatedNotificationBuilder: CommunityApplicationCreatedNotificationBuilder, private communityInvitationCreatedNotificationBuilder: CommunityInvitationCreatedNotificationBuilder, private communityExternalInvitationCreatedNotificationBuilder: CommunityExternalInvitationCreatedNotificationBuilder, + private platformGlobalRoleChangeNotificationBuilder: PlatformGlobalRoleChangeNotificationBuilder, private platformUserRegisteredNotificationBuilder: PlatformUserRegisteredNotificationBuilder, private platformUserRemovedNotificationBuilder: PlatformUserRemovedNotificationBuilder, private platformForumDiscussionCommentNotificationBuilder: PlatformForumDiscussionCommentNotificationBuilder, @@ -145,6 +148,15 @@ export class NotificationService { ); } + async sendGlobalRoleChangeNotification( + payload: PlatformGlobalRoleChangeEventPayload + ): Promise[]> { + return this.sendNotifications( + payload, + this.platformGlobalRoleChangeNotificationBuilder + ); + } + async sendUserRegisteredNotification( payload: PlatformUserRegistrationEventPayload ): Promise[]> { diff --git a/service/src/templates/platform.global.role.change.admin.js b/service/src/templates/platform.global.role.change.admin.js new file mode 100644 index 00000000..05565032 --- /dev/null +++ b/service/src/templates/platform.global.role.change.admin.js @@ -0,0 +1,23 @@ +// eslint-disable-next-line @typescript-eslint/no-var-requires +var templates = require('./alkemio.template.blocks'); +/* eslint-disable quotes */ +module.exports = () => ({ + name: 'platform-global-role-change-admin', + title: '[Alkemio] Global role change: {{user.name}} - {{type}} - {{role}}', + version: 1, + channels: { + email: { + from: '{{emailFrom}}', + to: '{{recipient.email}}', + subject: 'Global role change on Alkemio: {{user.displayName}} - {{type}} - {{role}}', + html: `{% extends "src/templates/_layouts/email-transactional.html" %} + {% block content %}Hi {{recipient.firstName}},

+ {{user.displayName}} with the following email address: {{user.email}} - {{type}} - {{role}}. +

+ Action carried out by: {{actor.displayName}}. +

+ {% endblock %} + ${templates.footerBlock}`, + }, + }, +}); From dad60f57a266dd17093c0b5ddd2b746fc6145fbf Mon Sep 17 00:00:00 2001 From: Valentin Yanakiev Date: Wed, 15 May 2024 17:16:12 +0300 Subject: [PATCH 2/2] Major version bump --- service/package-lock.json | 4 ++-- service/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/service/package-lock.json b/service/package-lock.json index cd7a4ee4..117d1482 100644 --- a/service/package-lock.json +++ b/service/package-lock.json @@ -1,12 +1,12 @@ { "name": "alkemio-notifications", - "version": "0.16.0", + "version": "0.17.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "alkemio-notifications", - "version": "0.16.0", + "version": "0.17.0", "license": "EUPL-1.2", "dependencies": { "@alkemio/client-lib": "^0.29.4", diff --git a/service/package.json b/service/package.json index 025953a1..3ab26c4b 100644 --- a/service/package.json +++ b/service/package.json @@ -1,6 +1,6 @@ { "name": "alkemio-notifications", - "version": "0.16.0", + "version": "0.17.0", "description": "Alkemio notifications service", "author": "Alkemio Foundation", "private": false,