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