Skip to content

Commit

Permalink
Merge pull request #209 from alkem-io/develop
Browse files Browse the repository at this point in the history
Release: Notifications for forum discussions
  • Loading branch information
valentinyanakiev authored May 10, 2023
2 parents 18993c2 + 102ed83 commit 9b89d3f
Show file tree
Hide file tree
Showing 25 changed files with 253 additions and 131 deletions.
4 changes: 2 additions & 2 deletions lib/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@alkemio/notifications-lib",
"version": "0.3.2",
"version": "0.4.1",
"description": "Library for interacting with Alkemio notifications service",
"author": "Alkemio Foundation",
"private": false,
Expand Down
11 changes: 0 additions & 11 deletions lib/src/dto/communication.discussion.created.event.payload.ts

This file was deleted.

3 changes: 2 additions & 1 deletion lib/src/dto/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export * from './base.event.payload';
export * from './journey.payload';
export * from './communication.discussion.created.event.payload';
export * from './communication.update.event.payload';
export * from './communication.user.message.event.payload';
export * from './communication.organization.message.event.payload';
Expand All @@ -18,3 +17,5 @@ export * from './collaboration.callout.published.event.payload';
export * from './collaboration.discussion.comment.event.payload';
export * from './platform.user.registration.event.payload';
export * from './platform.user.removed.event.payload';
export * from './platform.forum.discussion.comment.event.payload';
export * from './platform.forum.discussion.created.event.payload';
14 changes: 14 additions & 0 deletions lib/src/dto/platform.forum.discussion.comment.event.payload.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { BaseEventPayload } from './base.event.payload';

export interface PlatformForumDiscussionCommentEventPayload
extends BaseEventPayload {
discussion: {
displayName: string;
createdBy: string;
url: string;
};
comment: {
message: string;
createdBy: string;
};
}
11 changes: 11 additions & 0 deletions lib/src/dto/platform.forum.discussion.created.event.payload.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { BaseEventPayload } from './base.event.payload';

export interface PlatformForumDiscussionCreatedEventPayload
extends BaseEventPayload {
discussion: {
id: string;
createdBy: string;
displayName: string;
url: string;
};
}
3 changes: 2 additions & 1 deletion lib/src/notification.event.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ export enum NotificationEventType {
COMMUNITY_NEW_MEMBER = 'communityNewMember',
COMMUNICATION_COMMENT_SENT = 'communicationCommentSent',
COMMUNICATION_UPDATE_SENT = 'communicationUpdateSent',
COMMUNICATION_DISCUSSION_CREATED = 'communicationDiscussionCreated',
COMMUNICATION_USER_MESSAGE = 'communicationUserMessage',
COMMUNICATION_ORGANIZATION_MESSAGE = 'communicationOrganizationMessage',
COMMUNICATION_COMMUNITY_MESSAGE = 'communicationCommunityMessage',
Expand All @@ -18,4 +17,6 @@ export enum NotificationEventType {
COLLABORATION_CALLOUT_PUBLISHED = 'collaborationCalloutPublished',
PLATFORM_USER_REGISTERED = 'platformUserRegistered',
PLATFORM_USER_REMOVED = 'platformUserRemoved',
PLATFORM_FORUM_DISCUSSION_COMMENT = 'platformForumDiscussionComment',
PLATFORM_FORUM_DISCUSSION_CREATED = 'platformForumDiscussionCreated',
}
32 changes: 12 additions & 20 deletions service/notifications.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,26 +146,6 @@ recipients:
- rule:
type: OPPORTUNITY_MEMBER
resource_id: <journeyID>
communication_discussion_created:
- name: admin
rules:
- rule:
type: GLOBAL_ADMIN_COMMUNITY
resource_id:
- rule:
type: GLOBAL_ADMIN
resource_id:
- name: member
rules:
- rule:
type: HUB_MEMBER
resource_id: <journeyID>
- rule:
type: CHALLENGE_MEMBER
resource_id: <journeyID>
- rule:
type: OPPORTUNITY_MEMBER
resource_id: <journeyID>
communication_user_message:
- name: sender
rules:
Expand Down Expand Up @@ -344,3 +324,15 @@ recipients:
- rule:
type: GLOBAL_ADMIN_HUBS
resource_id:
platform_forum_discussion_comment:
- name: discussionCreator
rules:
- rule:
type: USER_SELF_MANAGEMENT
resource_id: <discussionCreatorID>
platform_forum_discussion_created:
- name: user
rules:
- rule:
type: GLOBAL_REGISTERED
resource_id:
32 changes: 16 additions & 16 deletions service/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions service/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "alkemio-notifications",
"version": "0.8.1",
"version": "0.9.0",
"description": "Alkemio notifications service",
"author": "Alkemio Foundation",
"private": false,
Expand Down Expand Up @@ -35,8 +35,8 @@
"validate-connection": "ts-node src/utils/validate-connection.ts"
},
"dependencies": {
"@alkemio/client-lib": "^0.18.1",
"@alkemio/notifications-lib": "^0.3.1",
"@alkemio/client-lib": "^0.18.6",
"@alkemio/notifications-lib": "^0.4.1",
"@nestjs/common": "^8.0.5",
"@nestjs/config": "^1.0.1",
"@nestjs/core": "^8.0.5",
Expand Down
28 changes: 22 additions & 6 deletions service/src/app.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
CommunityApplicationCreatedEventPayload,
CollaborationCardCommentEventPayload,
CollaborationCardCreatedEventPayload,
CommunicationDiscussionCreatedEventPayload,
PlatformForumDiscussionCreatedEventPayload,
CommunicationUserMessageEventPayload,
CommunicationOrganizationMessageEventPayload,
CommunicationCommunityLeadsMessageEventPayload,
Expand All @@ -31,6 +31,7 @@ import {
BaseEventPayload,
CollaborationCanvasCreatedEventPayload,
CollaborationDiscussionCommentEventPayload,
PlatformForumDiscussionCommentEventPayload,
} from '@alkemio/notifications-lib';
import { NotificationService } from './services/domain/notification/notification.service';
import { ALKEMIO_CLIENT_ADAPTER, LogContext } from './common/enums';
Expand Down Expand Up @@ -136,19 +137,34 @@ export class AppController {
);
}

@EventPattern(NotificationEventType.COMMUNICATION_DISCUSSION_CREATED)
async sendCommunicationDiscussionCreatedNotifications(
@EventPattern(NotificationEventType.PLATFORM_FORUM_DISCUSSION_CREATED)
async sendPlatformForumDiscussionCreatedNotifications(
// todo is auto validation possible
@Payload() eventPayload: CommunicationDiscussionCreatedEventPayload,
@Payload() eventPayload: PlatformForumDiscussionCreatedEventPayload,
@Ctx() context: RmqContext
) {
this.sendNotifications(
eventPayload,
context,
this.notificationService.sendCommunicationDiscussionCreatedNotification(
this.notificationService.sendPlatformForumDiscussionCreatedNotification(
eventPayload
),
NotificationEventType.COMMUNICATION_DISCUSSION_CREATED
NotificationEventType.PLATFORM_FORUM_DISCUSSION_CREATED
);
}

@EventPattern(NotificationEventType.PLATFORM_FORUM_DISCUSSION_COMMENT)
async sendPlatformForumDiscussionCommentNotifications(
@Payload() eventPayload: PlatformForumDiscussionCommentEventPayload,
@Ctx() context: RmqContext
) {
this.sendNotifications(
eventPayload,
context,
this.notificationService.sendPlatformForumDiscussionCommentNotification(
eventPayload
),
NotificationEventType.PLATFORM_FORUM_DISCUSSION_COMMENT
);
}

Expand Down
6 changes: 4 additions & 2 deletions service/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from '@src/services';
import { AlkemioClientModule, NotifmeModule } from '@src/services/external';
import {
CommunicationDiscussionCreatedNotificationBuilder,
PlatformForumDiscussionCreatedNotificationBuilder,
CommunicationUpdateCreatedNotificationBuilder,
CollaborationContextReviewSubmittedNotificationBuilder,
CommunityNewMemberNotificationBuilder,
Expand All @@ -28,6 +28,7 @@ import {
CommunicationCommunityLeadsMessageNotificationBuilder,
CommunicationUserMentionNotificationBuilder,
CommunicationOrganizationMentionNotificationBuilder,
PlatformForumDiscussionCommentNotificationBuilder,
} from './services/domain/builders';
import { NotificationService } from './services/domain/notification/notification.service';
import {
Expand Down Expand Up @@ -62,8 +63,9 @@ import { CollaborationDiscussionCommentNotificationBuilder } from './services/do
CommunityApplicationCreatedNotificationBuilder,
PlatformUserRegisteredNotificationBuilder,
PlatformUserRemovedNotificationBuilder,
PlatformForumDiscussionCommentNotificationBuilder,
CommunicationUpdateCreatedNotificationBuilder,
CommunicationDiscussionCreatedNotificationBuilder,
PlatformForumDiscussionCreatedNotificationBuilder,
CommunicationUserMessageNotificationBuilder,
CommunicationOrganizationMessageNotificationBuilder,
CommunicationCommunityLeadsMessageNotificationBuilder,
Expand Down

This file was deleted.

3 changes: 2 additions & 1 deletion service/src/common/email-template-payload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ export * from './collaboration.callout.published.email.payload';
export * from './collaboration.interest.email.payload';
export * from './collaboration.context.email.payload';
export * from './collaboration.discussion.comment.email.payload';
export * from './communication.discussion.created.email.payload';
export * from './communication.update.created.email.payload';
export * from './communication.user.message.email.payload';
export * from './communication.organization.message.email.payload';
export * from './communication.community.leads.message.email.payload';
export * from './communication.user.mention.email.payload';
export * from './communication.organization.mention.email.payload';
export * from './platform.user.registered.email.payload';
export * from './platform.forum.discussion.comment.email.payload';
export * from './platform.forum.discussion.created.email.payload';
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { BaseEmailPayload } from './base.email.payload';

export interface PlatformForumDiscussionCommentEmailPayload
extends BaseEmailPayload {
comment: {
message: string;
createdBy: string;
};
discussion: {
displayName: string;
createdBy: string;
url: string;
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { BaseEmailPayload } from './base.email.payload';

export interface PlatformForumDiscussionCreatedEmailPayload
extends BaseEmailPayload {
createdBy: {
firstName: string;
};
discussion: {
displayName: string;
url: string;
};
}
4 changes: 2 additions & 2 deletions service/src/common/enums/email.template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ export enum EmailTemplate {
COMMUNITY_NEW_MEMBER_MEMBER = 'community.new.member.member',
COMMUNITY_USER_APPLICATION_APPLICANT = 'community.user.application.applicant',
COMMUNITY_USER_APPLICATION_ADMIN = 'community.user.application.admin',
COMMUNICATION_DISCUSSION_CREATED_ADMIN = 'communication.discussion.created.admin',
COMMUNICATION_DISCUSSION_CREATED_MEMBER = 'communication.discussion.created.member',
COMMUNICATION_UPDATE_ADMIN = 'communication.update.admin',
COMMUNICATION_UPDATE_MEMBER = 'communication.update.member',
COMMUNICATION_USER_MESSAGE_SENDER = 'communication.user.message.sender',
Expand All @@ -29,4 +27,6 @@ export enum EmailTemplate {
PLATFORM_USER_REGISTRATION_REGISTRANT = 'platform.user.registration.registrant',
PLATFORM_USER_REGISTRATION_ADMIN = 'platform.user.registration.admin',
PLATFORM_USER_REMOVED_ADMIN = 'platform.user.removed.admin',
PLATFORM_FORUM_DISCUSSION_CREATED = 'platform.forum.discussion.created',
PLATFORM_FORUM_DISCUSSION_COMMENT = 'platform.forum.discussion.comment',
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export type TemplateConfig = {
community_application_created?: TemplateRuleSet[];
community_new_member?: TemplateRuleSet[];
communication_update_sent?: TemplateRuleSet[];
communication_discussion_created?: TemplateRuleSet[];
platform_forum_discussion_created?: TemplateRuleSet[];
communication_user_message?: TemplateRuleSet[];
communication_organization_message?: TemplateRuleSet[];
communication_community_leads_message?: TemplateRuleSet[];
Expand All @@ -32,6 +32,7 @@ export type TemplateConfig = {
collaboration_callout_published?: TemplateRuleSet[];
platform_user_registered?: TemplateRuleSet[];
platform_user_removed?: TemplateRuleSet[];
platform_forum_discussion_comment?: TemplateRuleSet[];
};

export interface INotificationRecipientTemplateProvider {
Expand Down
Loading

0 comments on commit 9b89d3f

Please sign in to comment.