Skip to content

Commit

Permalink
Merge pull request #3813 from novuhq/v0.16.x
Browse files Browse the repository at this point in the history
v0.16.4
  • Loading branch information
scopsy authored Jul 18, 2023
2 parents e6bac1c + 11d5ee7 commit 2a0d0f4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/node/src/lib/subscribers/subscriber.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export interface ISubscribers {
);
getUnseenCount(subscriberId: string, seen: boolean);
markMessageSeen(subscriberId: string, messageId: string);
markMessageRead(subscriberId: string, messageId: string);
markMessageActionSeen(subscriberId: string, messageId: string, type: string);
}

Expand Down
15 changes: 14 additions & 1 deletion packages/node/src/lib/subscribers/subscribers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,20 @@ describe('test use of novus node package - Subscribers class', () => {

expect(mockedAxios.post).toHaveBeenCalled();
expect(mockedAxios.post).toHaveBeenCalledWith(
'/subscribers/test-message-seen/messages/message-123/seen'
'/subscribers/test-message-seen/messages/markAs',
{ mark: { seen: true }, messageId: 'message-123' }
);
});

test('should mark subscriber feed message as read', async () => {
mockedAxios.post.mockResolvedValue({});

await novu.subscribers.markMessageRead('test-message-read', 'message-123');

expect(mockedAxios.post).toHaveBeenCalled();
expect(mockedAxios.post).toHaveBeenCalledWith(
'/subscribers/test-message-read/messages/markAs',
{ mark: { read: true }, messageId: 'message-123' }
);
});

Expand Down
10 changes: 9 additions & 1 deletion packages/node/src/lib/subscribers/subscribers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,15 @@ export class Subscribers extends WithHttp implements ISubscribers {

async markMessageSeen(subscriberId: string, messageId: string) {
return await this.http.post(
`/subscribers/${subscriberId}/messages/${messageId}/seen`
`/subscribers/${subscriberId}/messages/markAs`,
{ messageId, mark: { seen: true } }
);
}

async markMessageRead(subscriberId: string, messageId: string) {
return await this.http.post(
`/subscribers/${subscriberId}/messages/markAs`,
{ messageId, mark: { read: true } }
);
}

Expand Down

0 comments on commit 2a0d0f4

Please sign in to comment.