Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ws): performance improvements #4142

Merged
merged 3 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -250,40 +250,19 @@ export class SendMessageInApp extends SendMessageBase {
);

await this.webSocketsQueueService.bullMqService.add(
'sendMessage-received-' + message._id,
message._id,
{
event: WebSocketEventEnum.RECEIVED,
userId: command._subscriberId,
_environmentId: command.environmentId,
payload: {
message,
messageId: message._id,
},
},
{},
command.organizationId
);

await this.webSocketsQueueService.bullMqService.add(
'sendMessage-unseen-' + message._id,
{
event: WebSocketEventEnum.UNSEEN,
userId: command._subscriberId,
_environmentId: command.environmentId,
},
{},
command.organizationId
);

await this.webSocketsQueueService.bullMqService.add(
'sendMessage-unread-' + message._id,
{
event: WebSocketEventEnum.UNREAD,
userId: command._subscriberId,
_environmentId: command.environmentId,
},
{},
command.organizationId
);

await this.createExecutionDetails.execute(
CreateExecutionDetailsCommand.create({
...CreateExecutionDetailsCommand.getDetailsFromJob(command.job),
Expand Down
2 changes: 1 addition & 1 deletion apps/ws/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/src/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "cross-env TS_NODE_COMPILER_OPTIONS='{\"strictNullChecks\": false}' TZ=UTC NODE_ENV=test E2E_RUNNER=true mocha --timeout 10000 --require ts-node/register --exit --file e2e/setup.ts src/**/**/*.spec.ts"
"test": "cross-env TS_NODE_COMPILER_OPTIONS='{\"strictNullChecks\": false}' TZ=UTC NODE_ENV=test E2E_RUNNER=true mocha --timeout 10000 --require ts-node/register --exit --file e2e/setup.ts './src/**/*.spec.ts'"
},
"dependencies": {
"@godaddy/terminus": "^4.3.1",
Expand Down
2 changes: 2 additions & 0 deletions apps/ws/src/.env.test
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ NODE_ENV=test

GLOBAL_CONTEXT_PATH=
WS_CONTEXT_PATH=

LOGGING_LEVEL=error
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { IsDefined, IsOptional, IsString } from 'class-validator';

import { BaseCommand } from '@novu/application-generic';
import { MessageEntity } from '@novu/dal';

export class ExternalServicesRouteCommand extends BaseCommand {
@IsDefined()
Expand All @@ -12,7 +13,16 @@ export class ExternalServicesRouteCommand extends BaseCommand {
event: string;

@IsOptional()
payload: Record<string, unknown>;
payload?: {
/*
* TODO: We shouldn't import DAL here but this is temporary as we will remove
* the ability of send full message
*/
message?: MessageEntity;
messageId?: string;
unreadCount?: number;
unseenCount?: number;
};

@IsString()
@IsOptional()
Expand Down
Loading
Loading