notification

This commit is contained in:
tamaina 2021-09-12 22:53:06 +09:00
parent 02f6142d01
commit 295ad35210
2 changed files with 3 additions and 6 deletions

View file

@ -2,15 +2,13 @@ import { EntityRepository, In, Repository } from 'typeorm';
import { Users, Notes, UserGroupInvitations, AccessTokens, NoteReactions } from '../index';
import { Notification } from '@/models/entities/notification';
import { awaitAll } from '@/prelude/await-all';
import { SchemaType } from '@/misc/schema';
import { Packed } from '@/misc/schema';
import { Note } from '@/models/entities/note';
import { NoteReaction } from '@/models/entities/note-reaction';
import { User } from '@/models/entities/user';
import { aggregateNoteEmojis, prefetchEmojis } from '@/misc/populate-emojis';
import { notificationTypes } from '@/types';
export type PackedNotification = SchemaType<typeof packedNotificationSchema>;
@EntityRepository(Notification)
export class NotificationRepository extends Repository<Notification> {
public async pack(
@ -20,7 +18,7 @@ export class NotificationRepository extends Repository<Notification> {
myReactions: Map<Note['id'], NoteReaction | null>;
};
}
): Promise<PackedNotification> {
): Promise<Packed<'Notification'>> {
const notification = typeof src === 'object' ? src : await this.findOneOrFail(src);
const token = notification.appAccessTokenId ? await AccessTokens.findOneOrFail(notification.appAccessTokenId) : null;

View file

@ -2,11 +2,10 @@ import * as push from 'web-push';
import config from '@/config/index';
import { SwSubscriptions } from '@/models/index';
import { fetchMeta } from '@/misc/fetch-meta';
import { PackedNotification } from '../models/repositories/notification';
import { Packed } from '@/misc/schema';
type notificationType = 'notification' | 'unreadMessagingMessage';
type notificationBody = PackedNotification | Packed<'MessagingMessage'>;
type notificationBody = Packed<'Notification'> | Packed<'MessagingMessage'>;
export default async function(userId: string, type: notificationType, body: notificationBody) {
const meta = await fetchMeta();