1
0
mirror of https://github.com/hotomoe/hotomoe synced 2024-12-17 16:18:13 +09:00
hotomoe/src/models/repositories/follow-request.ts
syuilo 987168b863
strictNullChecks (#4666)
* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip
2019-04-13 01:43:22 +09:00

21 lines
617 B
TypeScript

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