This commit is contained in:
tamaina 2021-02-10 01:54:07 +09:00
parent c44a29ebb7
commit f95ca164d6
11 changed files with 259 additions and 176 deletions

View file

@ -1,5 +1,5 @@
import { publishMainStream } from './stream';
import pushSw from './push-notification';
import { pushNotification } from './push-notification';
import { Notifications, Mutings, UserProfiles } from '../models';
import { genId } from '../misc/gen-id';
import { User } from '../models/entities/user';
@ -50,7 +50,7 @@ export async function createNotification(
publishMainStream(notifieeId, 'unreadNotification', packed);
pushSw(notifieeId, 'notification', packed);
pushNotification(notifieeId, 'notification', packed);
}
}, 2000);

View file

@ -5,7 +5,7 @@ import { MessagingMessages, UserGroupJoinings, Mutings, Users } from '../../mode
import { genId } from '../../misc/gen-id';
import { MessagingMessage } from '../../models/entities/messaging-message';
import { publishMessagingStream, publishMessagingIndexStream, publishMainStream, publishGroupMessagingStream } from '../stream';
import pushNotification from '../push-notification';
import { pushNotification } from '../push-notification';
import { Not } from 'typeorm';
import { Note } from '../../models/entities/note';
import renderNote from '../../remote/activitypub/renderer/note';

View file

@ -12,7 +12,7 @@ type pushNotificationsTypes = {
'readAllNotifications': undefined;
};
export default async function<T extends keyof pushNotificationsTypes>(userId: string, type: T, body: pushNotificationsTypes[T]) {
export async function pushNotification<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;