Skip to content

Commit

Permalink
Merge pull request #4126 from novuhq/nv-2823-ws-reduce-the-payload-si…
Browse files Browse the repository at this point in the history
…ze-of-the-jobs

feat(ws): reduce the ws payload size
  • Loading branch information
Pablo Fernández authored Sep 13, 2023
2 parents 4466e50 + 9de7dc3 commit e3bd728
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 102 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,20 +247,21 @@ export class SendMessageInApp extends SendMessageBase {
);

await this.webSocketsQueueService.bullMqService.add(
'sendMessage-received-' + message._id,
`sendMessage-received-${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,
`sendMessage-unseen-${message._id}`,
{
event: WebSocketEventEnum.UNSEEN,
userId: command._subscriberId,
Expand All @@ -271,7 +272,7 @@ export class SendMessageInApp extends SendMessageBase {
);

await this.webSocketsQueueService.bullMqService.add(
'sendMessage-unread-' + message._id,
`sendMessage-unread-${message._id}`,
{
event: WebSocketEventEnum.UNREAD,
userId: command._subscriberId,
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

0 comments on commit e3bd728

Please sign in to comment.