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(node): add deleteByTransactionId method #6980

Merged
merged 1 commit into from
Nov 13, 2024
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
1 change: 1 addition & 0 deletions packages/node/src/lib/messages/messages.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ChannelTypeEnum } from '@novu/shared';
export interface IMessages {
deleteById(messageId: string);
list(data?: IMessagesPayload);
deleteByTransactionId(transactionId: string);
}

export interface IMessagesPayload {
Expand Down
14 changes: 14 additions & 0 deletions packages/node/src/lib/messages/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,21 @@ export class Messages extends WithHttp implements IMessages {
});
}

/**
* Deletes a single message notification by messageId.
*
* @param {string} messageId - The MongoDB ID of the message to delete.
*/
async deleteById(messageId: string) {
return await this.http.delete(`${BASE_PATH}/${messageId}`);
}

/**
* Deletes multiple message notifications by transactionId.
*
* @param {string} transactionId - The unique identifier of the event whose notifications will be deleted.
*/
async deleteByTransactionId(transactionId: string) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall I rename this method to deleteMessagesBytTransactionId to highlight that all messages related to this transactionId will be deleted?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's already on the messaged domain. So I think it's totally fine

return await this.http.delete(`${BASE_PATH}/transaction/${transactionId}`);
}
}
Loading