mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-14 13:23:09 +02:00
23 lines
684 B
TypeScript
23 lines
684 B
TypeScript
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,
|
|
) {
|
|
const invitation = typeof src === 'object' ? src : await this.findOneOrFail(src);
|
|
|
|
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)));
|
|
}
|
|
}
|