This commit is contained in:
tamaina 2021-01-30 19:56:36 +09:00
parent 6b11344b16
commit 3ce28b706a
3 changed files with 14 additions and 5 deletions

View file

@ -5,10 +5,14 @@ import { fetchMeta } from '../misc/fetch-meta';
import { PackedNotification } from '../models/repositories/notification';
import { PackedMessagingMessage } from '../models/repositories/messaging-message';
type notificationType = 'notification' | 'unreadMessagingMessage';
type notificationBody = PackedNotification | PackedMessagingMessage;
type pushNotificationsTypes = {
'notification': PackedNotification;
'unreadMessagingMessage': PackedMessagingMessage;
'readNotifications': { notificationIds: string[] };
'readAllNotifications': undefined;
};
export default async function(userId: string, type: notificationType, body: notificationBody) {
export default async function<T extends keyof pushNotificationsTypes>(userId: string, type: T, body: pushNotificationsTypes[T]) {
const meta = await fetchMeta();
if (!meta.enableServiceWorker || meta.swPublicKey == null || meta.swPrivateKey == null) return;