mirror of
https://iceshrimp.dev/iceshrimp/iceshrimp
synced 2024-12-21 01:58:10 +09:00
3df95ca7e4
Resolve #5880 Resolve #5927
25 lines
738 B
TypeScript
25 lines
738 B
TypeScript
import { EntityRepository, Repository } from 'typeorm';
|
|
import { UserGroupInvitation } from '../entities/user-group-invitation';
|
|
import { UserGroups } from '..';
|
|
import { ensure } from '../../prelude/ensure';
|
|
|
|
@EntityRepository(UserGroupInvitation)
|
|
export class UserGroupInvitationRepository extends Repository<UserGroupInvitation> {
|
|
public async pack(
|
|
src: UserGroupInvitation['id'] | UserGroupInvitation,
|
|
) {
|
|
const invitation = typeof src === 'object' ? src : await this.findOne(src).then(ensure);
|
|
|
|
return {
|
|
id: invitation.id,
|
|
group: await UserGroups.pack(invitation.userGroup || invitation.userGroupId),
|
|
};
|
|
}
|
|
|
|
public packMany(
|
|
invitations: any[],
|
|
) {
|
|
return Promise.all(invitations.map(x => this.pack(x)));
|
|
}
|
|
}
|