yumechi-no-kuni/packages/backend/src/models/repositories/follow-request.ts
syuilo 0e4a111f81 refactoring
Resolve #7779
2021-11-12 02:02:25 +09:00

20 lines
656 B
TypeScript

import { EntityRepository, Repository } from 'typeorm';
import { FollowRequest } from '@/models/entities/follow-request';
import { Users } from '../index';
import { User } from '@/models/entities/user';
@EntityRepository(FollowRequest)
export class FollowRequestRepository extends Repository<FollowRequest> {
public async pack(
src: FollowRequest['id'] | FollowRequest,
me?: { id: User['id'] } | null | undefined
) {
const request = typeof src === 'object' ? src : await this.findOneOrFail(src);
return {
id: request.id,
follower: await Users.pack(request.followerId, me),
followee: await Users.pack(request.followeeId, me),
};
}
}