Skip to content
Snippets Groups Projects
Commit ed47bfee authored by Aaron Dötsch's avatar Aaron Dötsch
Browse files

Increase type specitifity in notification handler

parent f57464df
No related branches found
No related tags found
No related merge requests found
import { db } from "$lib/server/database";
import { ChannelType } from "./channelTypes";
import type { HandlerReturnType, NotificationChannel, NotificationData, NotificationType, PossibleNotificationType } from "../../notifications/types";
import type { HandlerReturnError, HandlerReturnIgnored, HandlerReturnType, NotificationChannel, NotificationData, NotificationType, PossibleNotificationType } from "../../notifications/types";
export async function sendNotification<T extends PossibleNotificationType>(user: { id: number, notificationChannels: NotificationChannel[] | undefined } | number, type: NotificationType<T>, data: NotificationData<T>): Promise<HandlerReturnType[]>{
let notificationChannels: NotificationChannel[];
......@@ -23,7 +23,7 @@ export async function sendNotification<T extends PossibleNotificationType>(user:
status: "error",
channel,
error: err
} as HandlerReturnType;
} as HandlerReturnError;
});
}
case ChannelType.WEBHOOK.key: {
......@@ -33,7 +33,7 @@ export async function sendNotification<T extends PossibleNotificationType>(user:
status: "error",
channel,
error: err
} as HandlerReturnType;
} as HandlerReturnError;
});
}
default: {
......@@ -41,7 +41,7 @@ export async function sendNotification<T extends PossibleNotificationType>(user:
return {
status: "ignored",
channel
} as HandlerReturnType;
} as HandlerReturnIgnored;
}
};
}));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment