Skip to content

Commit

Permalink
extended lib with new notifications payloads + types; (#165)
Browse files Browse the repository at this point in the history
* extended lib with new notifications payloads + types; created tempaltes + logic to receive + process new notification types

* fixed test:ci
  • Loading branch information
techsmyth authored Dec 13, 2022
1 parent 5c52d8b commit 75fc4d2
Show file tree
Hide file tree
Showing 27 changed files with 519 additions and 25 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.2.1",
"version": "0.2.5",
"description": "Library for interacting with Alkemio notifications service",
"author": "Alkemio Foundation",
"private": false,
Expand Down
14 changes: 14 additions & 0 deletions lib/src/dto/collaboration.canvas.created.event.payload.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { JourneyBaseEventPayload } from './journey.base.event.payload';

export interface CollaborationCanvasCreatedEventPayload extends JourneyBaseEventPayload {
callout: {
displayName: string;
nameID: string;
}
canvas: {
id: string;
createdBy: string;
displayName: string;
nameID: string;
};
}
12 changes: 12 additions & 0 deletions lib/src/dto/collaboration.discussion.comment.event.payload.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { JourneyBaseEventPayload } from './journey.base.event.payload';

export interface CollaborationDiscussionCommentEventPayload extends JourneyBaseEventPayload {
callout: {
displayName: string;
nameID: string;
}
comment: {
message: string;
createdBy: string;
};
}
2 changes: 2 additions & 0 deletions lib/src/dto/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ export * from './communication.update.event.payload';
export * from './community.application.created.event.payload';
export * from './community.new.member.payload';
export * from './collaboration.interest.payload';
export * from './collaboration.canvas.created.event.payload';
export * from './collaboration.card.created.event.payload';
export * from './collaboration.context.review.submitted.payload';
export * from './collaboration.card.comment.event.payload';
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';
2 changes: 2 additions & 0 deletions lib/src/notification.event.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ export enum NotificationEventType {
COMMUNICATION_DISCUSSION_CREATED = 'communicationDiscussionCreated',
COLLABORATION_INTEREST = 'collaborationInterest',
COLLABORATION_CONTEXT_REVIEW_SUBMITTED = 'collaborationContextReviewSubmitted',
COLLABORATION_CANVAS_CREATED = 'collaborationCanvasCreated',
COLLABORATION_CARD_CREATED = 'collaborationCardCreated',
COLLABORATION_CARD_COMMENT = 'collaborationCommentOnCard',
COLLABORATION_DISCUSSION_COMMENT = 'collaborationCommentOnDiscussion',
COLLABORATION_CALLOUT_PUBLISHED = 'collaborationCalloutPublished',
PLATFORM_USER_REGISTERED = 'platformUserRegistered',
PLATFORM_USER_REMOVED = 'platformUserRemoved',
Expand Down
35 changes: 35 additions & 0 deletions service/notifications.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,47 @@ recipients:
- rule:
type: OPPORTUNITY_MEMBER
resource_id: <journeyID>
collaboration_canvas_created:
- name: admin
rules:
- rule:
type: HUB_ADMIN
resource_id: <hubID>
- rule:
type: CHALLENGE_ADMIN
resource_id: <challengeID>
- rule:
type: OPPORTUNITY_ADMIN
resource_id: <opportunityID>
- name: user
rules:
- rule:
type: HUB_MEMBER
resource_id: <journeyID>
- rule:
type: CHALLENGE_MEMBER
resource_id: <journeyID>
- rule:
type: OPPORTUNITY_MEMBER
resource_id: <journeyID>
collaboration_card_comment:
- name: owner
rules:
- rule:
type: USER_SELF_MANAGEMENT
resource_id: <ownerID>
collaboration_discussion_comment:
- name: member
rules:
- rule:
type: HUB_MEMBER
resource_id: <journeyID>
- rule:
type: CHALLENGE_MEMBER
resource_id: <journeyID>
- rule:
type: OPPORTUNITY_MEMBER
resource_id: <journeyID>
collaboration_callout_published:
- name: user
rules:
Expand Down
28 changes: 14 additions & 14 deletions service/package-lock.json

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

4 changes: 2 additions & 2 deletions service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"validate-connection": "ts-node src/utils/validate-connection.ts"
},
"dependencies": {
"@alkemio/client-lib": "^0.17.1",
"@alkemio/notifications-lib": "^0.2.1",
"@alkemio/client-lib": "^0.17.2",
"@alkemio/notifications-lib": "^0.2.5",
"@nestjs/common": "^8.0.5",
"@nestjs/config": "^1.0.1",
"@nestjs/core": "^8.0.5",
Expand Down
36 changes: 36 additions & 0 deletions service/src/app.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import {
PlatformUserRegistrationEventPayload,
CollaborationCalloutPublishedEventPayload,
BaseEventPayload,
CollaborationCanvasCreatedEventPayload,
CollaborationDiscussionCommentEventPayload,
} from '@alkemio/notifications-lib';
import { NotificationService } from './services/domain/notification/notification.service';
import { ALKEMIO_CLIENT_ADAPTER, LogContext } from './common/enums';
Expand Down Expand Up @@ -160,6 +162,22 @@ export class AppController {
);
}

@EventPattern(
NotificationEventType.COLLABORATION_CANVAS_CREATED,
Transport.RMQ
)
async sendCanvasCreatedNotifications(
@Payload() eventPayload: CollaborationCanvasCreatedEventPayload,
@Ctx() context: RmqContext
) {
this.sendNotifications(
eventPayload,
context,
this.notificationService.sendCanvasCreatedNotification(eventPayload),
NotificationEventType.COLLABORATION_CANVAS_CREATED
);
}

@EventPattern(NotificationEventType.COLLABORATION_CARD_CREATED, Transport.RMQ)
async sendAspectCreatedNotifications(
@Payload() eventPayload: CollaborationCardCreatedEventPayload,
Expand Down Expand Up @@ -188,6 +206,24 @@ export class AppController {
);
}

@EventPattern(
NotificationEventType.COLLABORATION_DISCUSSION_COMMENT,
Transport.RMQ
)
async sendDiscussionCommentCreatedNotifications(
@Payload() eventPayload: CollaborationDiscussionCommentEventPayload,
@Ctx() context: RmqContext
) {
this.sendNotifications(
eventPayload,
context,
this.notificationService.sendDiscussionCommentCreatedNotification(
eventPayload
),
NotificationEventType.COLLABORATION_DISCUSSION_COMMENT
);
}

@EventPattern(
NotificationEventType.COLLABORATION_CALLOUT_PUBLISHED,
Transport.RMQ
Expand Down
4 changes: 4 additions & 0 deletions service/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import {
AlkemioUrlGeneratorModule,
NotificationBuilder,
} from './services/application';
import { CollaborationCanvasCreatedNotificationBuilder } from './services/domain/builders/collaboration-canvas-created/collaboration.canvas.created.notification.builder';
import { CollaborationDiscussionCommentNotificationBuilder } from './services/domain/builders/collaboration-discussion-comment/collaboration.discussion.comment.notification.builder';

@Module({
imports: [
Expand Down Expand Up @@ -60,8 +62,10 @@ import {
CollaborationContextReviewSubmittedNotificationBuilder,
CommunityNewMemberNotificationBuilder,
CollaborationInterestNotificationBuilder,
CollaborationCanvasCreatedNotificationBuilder,
CollaborationCardCreatedNotificationBuilder,
CollaborationCardCommentNotificationBuilder,
CollaborationDiscussionCommentNotificationBuilder,
CollaborationCalloutPublishedNotificationBuilder,
NotificationService,
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { BaseJourneyEmailPayload } from './base.journey.email.payload';

export interface CollaborationCanvasCreatedEmailPayload
extends BaseJourneyEmailPayload {
createdBy: {
firstName: string;
email: string;
};
callout: {
displayName: string;
url: string;
};
canvas: {
displayName: string;
url: string;
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { BaseJourneyEmailPayload } from './base.journey.email.payload';
// @ts-
export interface CollaborationDiscussionCommentEmailPayload
extends BaseJourneyEmailPayload {
callout: {
displayName: string;
url: string;
};
createdBy: {
firstName: string;
email: string;
};
message: string;
}
7 changes: 5 additions & 2 deletions service/src/common/email-template-payload/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
export * from './base.email.payload';
export * from './base.journey.email.payload';
export * from './community.application.created.email.payload';
export * from './collaboration.canvas.created.email.payload';
export * from './collaboration.card.comment.email.payload';
export * from './collaboration.card.created.email.payload';
export * from './collaboration.callout.published.email.payload';
export * from './communication.discussion.created.email.payload';
export * from './communication.update.created.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 './community.new.member.email.payload';
export * from './platform.user.registered.email.payload';
5 changes: 4 additions & 1 deletion service/src/common/enums/email.template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ export enum EmailTemplate {
COLLABORATION_INTEREST_ADMIN = 'collaboration.interest.admin',
COLLABORATION_CARD_CREATED_ADMIN = 'collaboration.card.created.admin',
COLLABORATION_CARD_CREATED_MEMBER = 'collaboration.card.created.member',
COLLABORATION_CARD_COMMENT_MEMBER = 'collaboration.card.comment.member',
COLLABORATION_CARD_COMMENT_OWNER = 'collaboration.card.comment.owner',
COLLABORATION_CANVAS_CREATED_ADMIN = 'collaboration.canvas.created.admin',
COLLABORATION_CANVAS_CREATED_MEMBER = 'collaboration.canvas.created.member',
COLLABORATION_CALLOUT_PUBLISHED_MEMBER = 'collaboration.callout.published.member',
COLLABORATION_DISCUSSION_COMMENT_MEMBER = 'collaboration.discussion.comment.member',
PLATFORM_USER_REGISTRATION_REGISTRANT = 'platform.user.registration.registrant',
PLATFORM_USER_REGISTRATION_ADMIN = 'platform.user.registration.admin',
PLATFORM_USER_REMOVED_ADMIN = 'platform.user.removed.admin',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ export type TemplateConfig = {
community_new_member?: TemplateRuleSet[];
communication_update_sent?: TemplateRuleSet[];
communication_discussion_created?: TemplateRuleSet[];
collaboration_canvas_created?: TemplateRuleSet[];
collaboration_card_created?: TemplateRuleSet[];
collaboration_card_comment?: TemplateRuleSet[];
collaboration_discussion_comment?: TemplateRuleSet[];
collaboration_review_submitted?: TemplateRuleSet[];
collaboration_interest?: TemplateRuleSet[];
collaboration_callout_published?: TemplateRuleSet[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ export class AlkemioUrlGenerator {
return `${journeyURL}/explore/callouts/${calloutNameID}/aspects/${cardNameID}`;
}

createCanvasURL(
journeyURL: string,
calloutNameID: string,
canvasNameID: string
): string {
return `${journeyURL}/explore/callouts/${calloutNameID}/canvases/${canvasNameID}`;
}

createOrganizationURL(orgNameID: string): string {
return `${this.webclientEndpoint}/organization/${orgNameID}`;
}
Expand Down
Loading

0 comments on commit 75fc4d2

Please sign in to comment.