fix: ensure we dont bloat notification table with any other notification than app

This commit is contained in:
Carl-Gerhard Lindesvärd
2025-09-03 21:39:21 +02:00
parent e5cacb73df
commit 52b86682e2
5 changed files with 33 additions and 31 deletions

View File

@@ -117,21 +117,28 @@ function getIntegration(integrationId: string | null) {
}
export async function createNotification(notification: ICreateNotification) {
const res = await db.notification.create({
data: {
title: notification.title,
message: notification.message,
projectId: notification.projectId,
payload: notification.payload || Prisma.DbNull,
...getIntegration(notification.integrationId),
notificationRuleId: notification.notificationRuleId,
},
});
const data: Prisma.NotificationUncheckedCreateInput = {
title: notification.title,
message: notification.message,
projectId: notification.projectId,
payload: notification.payload || Prisma.DbNull,
...getIntegration(notification.integrationId),
notificationRuleId: notification.notificationRuleId,
};
return triggerNotification(res);
// Only create notifications for app
if (data.sendToApp) {
await db.notification.create({
data,
});
}
return triggerNotification(data);
}
export function triggerNotification(notification: Notification) {
export function triggerNotification(
notification: Prisma.NotificationUncheckedCreateInput,
) {
return notificationQueue.add('sendNotification', {
type: 'sendNotification',
payload: {