1
0
forked from mirror/misskey
This commit is contained in:
tamaina 2021-09-12 23:06:04 +09:00
parent df10aa40f4
commit 3bf7e4bf02

View File

@ -1,15 +1,13 @@
import { EntityRepository, Repository } from 'typeorm'; import { EntityRepository, Repository } from 'typeorm';
import { Antenna } from '@/models/entities/antenna'; import { Antenna } from '@/models/entities/antenna';
import { SchemaType } from '@/misc/schema'; import { Packed } from '@/misc/schema';
import { AntennaNotes, UserGroupJoinings } from '../index'; import { AntennaNotes, UserGroupJoinings } from '../index';
export type PackedAntenna = SchemaType<typeof packedAntennaSchema>;
@EntityRepository(Antenna) @EntityRepository(Antenna)
export class AntennaRepository extends Repository<Antenna> { export class AntennaRepository extends Repository<Antenna> {
public async pack( public async pack(
src: Antenna['id'] | Antenna, src: Antenna['id'] | Antenna,
): Promise<PackedAntenna> { ): Promise<Packed<'Antenna'>> {
const antenna = typeof src === 'object' ? src : await this.findOneOrFail(src); const antenna = typeof src === 'object' ? src : await this.findOneOrFail(src);
const hasUnreadNote = (await AntennaNotes.findOne({ antennaId: antenna.id, read: false })) != null; const hasUnreadNote = (await AntennaNotes.findOne({ antennaId: antenna.id, read: false })) != null;