N
Novu14mo ago
Nitin

Delete Multiple Transactions not working.

If I am triggering an event to for example 3 users (not a topic), then there are 3 events with same transactionId. Now if I try to delete the transaction using: 1. this.novu.events.cancel(transactionId); OR 2. /v1/events/trigger/${transactionId} (https://docs.novu.co/api-reference/events/cancel-triggered-event) Then only 1 event is getting deleted with that transactionId and rest of the 2 events are getting delivered.
16 Replies
Pawan Jain
Pawan Jain14mo ago
Hi @Nitin Could you please share the trigger code snippet?
Nitin
NitinOP14mo ago
Hey @Pawan Jain .
public async removeNotificationFromNovu(transactionId: string) {
try {
console.log('To delete transaction Id: ', transactionId);
// const API_URL = `${this.BACKEND_URL}/v1/events/trigger/${transactionId}`;
// const headers = {
// 'Content-Type': 'application/json',
// Authorization: `ApiKey ${this.API_KEY}`,
// };
// const resp = await axios.delete(API_URL, { headers });
const resp = await this.novu.events.cancel(transactionId);
console.log('API RESP: ', resp.status, resp.data);
if (resp.status !== 200) {
throw new Error(`Error while deleting notification: ${resp.statusText}`);
}
if (resp.data?.data) {
return {
message: 'success',
};
}
return {
message: 'Failure. No notification found for the given transactionId',
};
} catch (e: any) {
throw new Error(`Error while calling delete notification API: ${e.message}`);
}
}
public async removeNotificationFromNovu(transactionId: string) {
try {
console.log('To delete transaction Id: ', transactionId);
// const API_URL = `${this.BACKEND_URL}/v1/events/trigger/${transactionId}`;
// const headers = {
// 'Content-Type': 'application/json',
// Authorization: `ApiKey ${this.API_KEY}`,
// };
// const resp = await axios.delete(API_URL, { headers });
const resp = await this.novu.events.cancel(transactionId);
console.log('API RESP: ', resp.status, resp.data);
if (resp.status !== 200) {
throw new Error(`Error while deleting notification: ${resp.statusText}`);
}
if (resp.data?.data) {
return {
message: 'success',
};
}
return {
message: 'Failure. No notification found for the given transactionId',
};
} catch (e: any) {
throw new Error(`Error while calling delete notification API: ${e.message}`);
}
}
Pawan Jain
Pawan Jain14mo ago
@Nitin Thanks Could you please share the code snippet you used to trigger the workflow? In above code, I could find only cancel trigger code. My intention is to check how you are triggering in loop with one subscriberId? or subscriberId array as to field of trigger
Nitin
NitinOP14mo ago
I am triggering notification as subscriberId array, like this:
public async triggerNotificationToNovu({ triggerId, sendTo, payload: notificationPayload }: NovuRepoParams) {
const { payload } = notificationPayload;
if (sendTo.length === 0) {
throw new Error('No users found to send notification to');
}
const subscribers = sendTo.map((s) => ({ subscriberId: s }));
try {
const novuResponse = await this.novu.trigger(triggerId, {
to: subscribers,
payload: payload,
});
const { acknowledged, status, transactionId } = novuResponse.data.data;
return {
acknowledged,
status,
transactionId,
};
} catch (e) {
throw new Error(`Error while sending notification to Novu: ${e.message}`);
}
}
public async triggerNotificationToNovu({ triggerId, sendTo, payload: notificationPayload }: NovuRepoParams) {
const { payload } = notificationPayload;
if (sendTo.length === 0) {
throw new Error('No users found to send notification to');
}
const subscribers = sendTo.map((s) => ({ subscriberId: s }));
try {
const novuResponse = await this.novu.trigger(triggerId, {
to: subscribers,
payload: payload,
});
const { acknowledged, status, transactionId } = novuResponse.data.data;
return {
acknowledged,
status,
transactionId,
};
} catch (e) {
throw new Error(`Error while sending notification to Novu: ${e.message}`);
}
}
Pawan Jain
Pawan Jain14mo ago
I just saw you have added self host tag. Could you please share the novu version you are using?
Nitin
NitinOP14mo ago
Hosted version is 0.13. I just checked and realised that someone else from the team has updated the package version to 0.18. But the hosted version is not changed and is still on 0.13 Do you think this might be because of that?
Pawan Jain
Pawan Jain14mo ago
>> updated the package version to 0.18
Where did you change?
Nitin
NitinOP14mo ago
Hey @Pawan Jain , thanks for helping out here. Do let me know whenever the fix is live. @Pawan Jain any updates here?
Pawan Jain
Pawan Jain14mo ago
@Nitin let me update you about this when it will be fixed
Pawan Jain
Pawan Jain14mo ago
@Nitin Above issue is fixed in this PR https://github.com/novuhq/novu/pull/4616 Fix will be available in next release
GitHub
fix(api): Cancel all jobs related to a transactionId from the 'canc...
What change does this PR introduce? Why was this change needed? Closes NV-3019 Other information (Screenshots)
Nitin
NitinOP14mo ago
Hey @Pawan Jain thanks for the update and fixing this 🙏 . Any idea when will be the next release made?
Pawan Jain
Pawan Jain14mo ago
We will do patch release probably tomorrow
Nitin
NitinOP14mo ago
Okay, please let me know whenever this is merged.
Nitin
NitinOP14mo ago
Hey @jainpawan21 , I cannot find the mention of this issue's fix in the release docs: https://github.com/novuhq/novu/releases/tag/v0.20.0 Can you please once confirm if it went live or not?
GitHub
Release v0.20.0 · novuhq/novu
What’s new in Novu 0.20? TL;DR: All you need to know about the latest Novu 0.20.0 release. Global User Preferences, Integrations conditions, Digest and delay filters and more! 0.20 Release Updates ...
Pawan Jain
Pawan Jain14mo ago
@nitingupta__7 Above release notes is for 0.20.0 Fix will be available in patch release 0.20.1 @Nitin We just released 0.21.0 version and this issue was included in that release we published 0.21.0 docker images as well. You will need to upgrade to latest version
Nitin
NitinOP14mo ago
Thanks @Pawan Jain for the help and resolution 🙏
Want results from more Discord servers?
Add your server