forked from mirror/misskey
notification
This commit is contained in:
parent
02f6142d01
commit
295ad35210
@ -2,15 +2,13 @@ import { EntityRepository, In, Repository } from 'typeorm';
|
|||||||
import { Users, Notes, UserGroupInvitations, AccessTokens, NoteReactions } from '../index';
|
import { Users, Notes, UserGroupInvitations, AccessTokens, NoteReactions } from '../index';
|
||||||
import { Notification } from '@/models/entities/notification';
|
import { Notification } from '@/models/entities/notification';
|
||||||
import { awaitAll } from '@/prelude/await-all';
|
import { awaitAll } from '@/prelude/await-all';
|
||||||
import { SchemaType } from '@/misc/schema';
|
import { Packed } from '@/misc/schema';
|
||||||
import { Note } from '@/models/entities/note';
|
import { Note } from '@/models/entities/note';
|
||||||
import { NoteReaction } from '@/models/entities/note-reaction';
|
import { NoteReaction } from '@/models/entities/note-reaction';
|
||||||
import { User } from '@/models/entities/user';
|
import { User } from '@/models/entities/user';
|
||||||
import { aggregateNoteEmojis, prefetchEmojis } from '@/misc/populate-emojis';
|
import { aggregateNoteEmojis, prefetchEmojis } from '@/misc/populate-emojis';
|
||||||
import { notificationTypes } from '@/types';
|
import { notificationTypes } from '@/types';
|
||||||
|
|
||||||
export type PackedNotification = SchemaType<typeof packedNotificationSchema>;
|
|
||||||
|
|
||||||
@EntityRepository(Notification)
|
@EntityRepository(Notification)
|
||||||
export class NotificationRepository extends Repository<Notification> {
|
export class NotificationRepository extends Repository<Notification> {
|
||||||
public async pack(
|
public async pack(
|
||||||
@ -20,7 +18,7 @@ export class NotificationRepository extends Repository<Notification> {
|
|||||||
myReactions: Map<Note['id'], NoteReaction | null>;
|
myReactions: Map<Note['id'], NoteReaction | null>;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
): Promise<PackedNotification> {
|
): Promise<Packed<'Notification'>> {
|
||||||
const notification = typeof src === 'object' ? src : await this.findOneOrFail(src);
|
const notification = typeof src === 'object' ? src : await this.findOneOrFail(src);
|
||||||
const token = notification.appAccessTokenId ? await AccessTokens.findOneOrFail(notification.appAccessTokenId) : null;
|
const token = notification.appAccessTokenId ? await AccessTokens.findOneOrFail(notification.appAccessTokenId) : null;
|
||||||
|
|
||||||
|
@ -2,11 +2,10 @@ import * as push from 'web-push';
|
|||||||
import config from '@/config/index';
|
import config from '@/config/index';
|
||||||
import { SwSubscriptions } from '@/models/index';
|
import { SwSubscriptions } from '@/models/index';
|
||||||
import { fetchMeta } from '@/misc/fetch-meta';
|
import { fetchMeta } from '@/misc/fetch-meta';
|
||||||
import { PackedNotification } from '../models/repositories/notification';
|
|
||||||
import { Packed } from '@/misc/schema';
|
import { Packed } from '@/misc/schema';
|
||||||
|
|
||||||
type notificationType = 'notification' | 'unreadMessagingMessage';
|
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) {
|
export default async function(userId: string, type: notificationType, body: notificationBody) {
|
||||||
const meta = await fetchMeta();
|
const meta = await fetchMeta();
|
||||||
|
Loading…
Reference in New Issue
Block a user