Skip to content

Commit

Permalink
Merge pull request #363 from alkem-io/develop
Browse files Browse the repository at this point in the history
In-app notifications
  • Loading branch information
valentinyanakiev authored Dec 16, 2024
2 parents 4454c33 + 934c3a6 commit 4d54b46
Show file tree
Hide file tree
Showing 52 changed files with 898 additions and 122 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
dist: focal
language: node_js
node_js:
- v16.15.0
- v20.15.1
cache:
directories:
- node_modules
Expand All @@ -10,6 +11,6 @@ services:
- mysql
before_install:
- cd service
- npm i -g npm@8.5.5
- npm i -g npm@10.5.0
script:
- npm run test:ci:coverage
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.

5 changes: 4 additions & 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.9.6",
"version": "0.10.1",
"description": "Library for interacting with Alkemio notifications service",
"author": "Alkemio Foundation",
"private": false,
Expand Down Expand Up @@ -50,6 +50,9 @@
"node": ">=16.15.0",
"npm": ">=8.5.5"
},
"volta": {
"node": "20.15.1"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
Expand Down
5 changes: 5 additions & 0 deletions lib/src/common/enums/in.app.notification.category.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export enum InAppNotificationCategory {
SELF = 'self',
MEMBER = 'member',
ADMIN = 'admin',
}
2 changes: 2 additions & 0 deletions lib/src/common/enums/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./role.change.type";
export * from "./in.app.notification.category";
1 change: 0 additions & 1 deletion lib/src/dto/collaboration.post.created.event.payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export interface CollaborationPostCreatedEventPayload extends SpaceBaseEventPayl
createdBy: string;
displayName: string;
nameID: string;
type: string;
url: string;
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { InAppNotificationPayloadBase } from "./in.app.notification.payload.base";
import { NotificationEventType } from '../../notification.event.type';

export interface InAppNotificationCalloutPublishedPayload extends InAppNotificationPayloadBase {
type: NotificationEventType.COLLABORATION_CALLOUT_PUBLISHED;
calloutID: string;
spaceID: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { CommunityContributorType } from '@alkemio/client-lib';
import { InAppNotificationPayloadBase } from './in.app.notification.payload.base';
import { NotificationEventType } from '../../notification.event.type';

export interface InAppNotificationCommunityNewMemberPayload extends InAppNotificationPayloadBase {
type: NotificationEventType.COMMUNITY_NEW_MEMBER;
contributorType: CommunityContributorType;
newMemberID: string;
spaceID: string;
}
9 changes: 9 additions & 0 deletions lib/src/dto/in-app/in.app.notification.compessed.payload.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { InAppNotificationPayloadBase } from "./in.app.notification.payload.base";

/**
* The compressed version of an In-App Notifications.
* It is the same payload but with multiple receivers.
*/
export type CompressedInAppNotificationPayload<T extends InAppNotificationPayloadBase> = Exclude<T, 'receiverID'> & {
receiverIDs: string[];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { CommunityContributorType } from "@alkemio/client-lib";
import { InAppNotificationPayloadBase } from "./in.app.notification.payload.base";
import { NotificationEventType } from '../../notification.event.type';

export interface InAppNotificationContributorMentionedPayload extends InAppNotificationPayloadBase {
type: NotificationEventType.COMMUNICATION_USER_MENTION;
comment: string; // probably will be removed; can be too large; can be replaced with roomID, commentID
contributorType: CommunityContributorType
commentOrigin: {
displayName: string;
url: string;
}
}
11 changes: 11 additions & 0 deletions lib/src/dto/in-app/in.app.notification.payload.base.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { InAppNotificationCategory } from "../../common/enums";
import { NotificationEventType } from "../../notification.event.type";

export interface InAppNotificationPayloadBase {
receiverID: string;
/** UTC */
triggeredAt: Date;
type: NotificationEventType;
triggeredByID: string;
category: InAppNotificationCategory;
}
8 changes: 8 additions & 0 deletions lib/src/dto/in-app/in.app.notification.payload.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { InAppNotificationCalloutPublishedPayload } from "./in.app.notification.callout.published.payload";
import { InAppNotificationCommunityNewMemberPayload } from "./in.app.notification.community.new.member.payload";
import { InAppNotificationContributorMentionedPayload } from "./in.app.notification.contributor.mentioned.payload";

export type InAppNotificationPayload =
| InAppNotificationCalloutPublishedPayload
| InAppNotificationCommunityNewMemberPayload
| InAppNotificationContributorMentionedPayload;
9 changes: 9 additions & 0 deletions lib/src/dto/in-app/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export * from "./in.app.notification.payload.base";

export * from "./in.app.notification.payload";

export * from "./in.app.notification.compessed.payload";

export * from "./in.app.notification.callout.published.payload";
export * from "./in.app.notification.community.new.member.payload";
export * from "./in.app.notification.contributor.mentioned.payload";
1 change: 1 addition & 0 deletions lib/src/dto/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ export * from './platform.forum.discussion.created.event.payload';
export * from './comment.reply.event.payload';
export * from './community.invitation.virtual.contributor.created.event.payload';
export * from './space.created.event.payload';

4 changes: 2 additions & 2 deletions lib/src/dto/platform.global.role.change.event.payload.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RoleChangeType } from "@src/common/enums/role.change.type";
import { RoleChangeType } from "../common/enums";
import { BaseEventPayload } from "./base.event.payload";
import { ContributorPayload } from "./contributor.payload";

Expand All @@ -8,4 +8,4 @@ export interface PlatformGlobalRoleChangeEventPayload
user: ContributorPayload
role: string;
actor: ContributorPayload;
};
}
3 changes: 2 additions & 1 deletion lib/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './notification.event.type';
export * from './dto';
export * from './common/enums/role.change.type';
export * from './dto/in-app';
export * from './common/enums';
5 changes: 5 additions & 0 deletions service/notifications.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ rabbitmq:

# RabbitMQ password
password: ${RABBITMQ_PASSWORD}:alkemio!
# heartbeat
heartbeat: ${RABBITMQ_HEARTBEAT}:30

## MONITORING ##
# This section defines settings used for DevOps - MONITORING providers, endpoints, logging configuration.
Expand Down Expand Up @@ -65,6 +67,9 @@ notification_providers:
pass: ${EMAIL_SMTP_PASSWORD}:test
tls:
rejectUnauthorized: ${EMAIL_SMTP_REJECT_UNAUTHORIZED}:false
in_app:
# The name of the queue used for sending in-app notifications
queue: ${IN_APP_QUEUE_NAME}:alkemio-in-app-notifications

## hosting ##
# The hosting configuration for the Alkemio Server
Expand Down
20 changes: 10 additions & 10 deletions service/package-lock.json

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

11 changes: 7 additions & 4 deletions service/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "alkemio-notifications",
"version": "0.19.1",
"version": "0.20.0",
"description": "Alkemio notifications service",
"author": "Alkemio Foundation",
"private": false,
Expand All @@ -18,7 +18,7 @@
"start-nodemon-local": "nodemon -w src --ext ts --exec ts-node -r dotenv/config src/main.ts",
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:debug": "nest start --debug=0.0.0.0:9230 --watch",
"start:prod": "node dist/main",
"start:services": "docker-compose -f quickstart-mailslurper.yml up --build --force-recreate",
"lint": "tsc --noEmit && eslint src/**/*.ts{,x}",
Expand All @@ -36,7 +36,7 @@
},
"dependencies": {
"@alkemio/client-lib": "^0.32.0",
"@alkemio/notifications-lib": "^0.9.6",
"@alkemio/notifications-lib": "0.10.1",
"@nestjs/common": "^8.0.5",
"@nestjs/config": "^1.0.1",
"@nestjs/core": "^8.0.5",
Expand Down Expand Up @@ -95,7 +95,10 @@
}
},
"engines": {
"node": ">=16.15.0",
"node": ">=20.15.0",
"npm": ">=8.5.5"
},
"volta": {
"node": "20.15.1"
}
}
Loading

0 comments on commit 4d54b46

Please sign in to comment.