2020-02-12 09:17:54 -08:00
|
|
|
import { EntityRepository, Repository } from 'typeorm';
|
|
|
|
import { UserGroupInvitation } from '../entities/user-group-invitation';
|
|
|
|
import { UserGroups } from '..';
|
|
|
|
|
|
|
|
@EntityRepository(UserGroupInvitation)
|
|
|
|
export class UserGroupInvitationRepository extends Repository<UserGroupInvitation> {
|
|
|
|
public async pack(
|
|
|
|
src: UserGroupInvitation['id'] | UserGroupInvitation,
|
|
|
|
) {
|
2021-02-12 22:33:38 -08:00
|
|
|
const invitation = typeof src === 'object' ? src : await this.findOneOrFail(src);
|
2020-02-12 09:17:54 -08:00
|
|
|
|
|
|
|
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)));
|
|
|
|
}
|
|
|
|
}
|