app, messaging-message

This commit is contained in:
tamaina 2021-09-12 22:52:16 +09:00
parent 677a6aae2a
commit 02f6142d01
3 changed files with 6 additions and 10 deletions

View File

@ -1,9 +1,7 @@
import { EntityRepository, Repository } from 'typeorm'; import { EntityRepository, Repository } from 'typeorm';
import { App } from '@/models/entities/app'; import { App } from '@/models/entities/app';
import { AccessTokens } from '../index'; import { AccessTokens } from '../index';
import { SchemaType } from '@/misc/schema'; import { Packed } from '@/misc/schema';
export type PackedApp = SchemaType<typeof packedAppSchema>;
@EntityRepository(App) @EntityRepository(App)
export class AppRepository extends Repository<App> { export class AppRepository extends Repository<App> {
@ -15,7 +13,7 @@ export class AppRepository extends Repository<App> {
includeSecret?: boolean, includeSecret?: boolean,
includeProfileImageIds?: boolean includeProfileImageIds?: boolean
} }
): Promise<PackedApp> { ): Promise<Packed<'App'>> {
const opts = Object.assign({ const opts = Object.assign({
detail: false, detail: false,
includeSecret: false, includeSecret: false,

View File

@ -1,11 +1,9 @@
import { EntityRepository, Repository } from 'typeorm'; import { EntityRepository, Repository } from 'typeorm';
import { MessagingMessage } from '@/models/entities/messaging-message'; import { MessagingMessage } from '@/models/entities/messaging-message';
import { Users, DriveFiles, UserGroups } from '../index'; import { Users, DriveFiles, UserGroups } from '../index';
import { SchemaType } from '@/misc/schema'; import { Packed } from '@/misc/schema';
import { User } from '@/models/entities/user'; import { User } from '@/models/entities/user';
export type PackedMessagingMessage = SchemaType<typeof packedMessagingMessageSchema>;
@EntityRepository(MessagingMessage) @EntityRepository(MessagingMessage)
export class MessagingMessageRepository extends Repository<MessagingMessage> { export class MessagingMessageRepository extends Repository<MessagingMessage> {
public validateText(text: string): boolean { public validateText(text: string): boolean {
@ -19,7 +17,7 @@ export class MessagingMessageRepository extends Repository<MessagingMessage> {
populateRecipient?: boolean, populateRecipient?: boolean,
populateGroup?: boolean, populateGroup?: boolean,
} }
): Promise<PackedMessagingMessage> { ): Promise<Packed<'MessagingMessage'>> {
const opts = options || { const opts = options || {
populateRecipient: true, populateRecipient: true,
populateGroup: true, populateGroup: true,

View File

@ -3,10 +3,10 @@ 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 { PackedNotification } from '../models/repositories/notification';
import { PackedMessagingMessage } from '../models/repositories/messaging-message'; import { Packed } from '@/misc/schema';
type notificationType = 'notification' | 'unreadMessagingMessage'; type notificationType = 'notification' | 'unreadMessagingMessage';
type notificationBody = PackedNotification | PackedMessagingMessage; type notificationBody = PackedNotification | 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();