mirror of
https://activitypub.software/TransFem-org/Sharkey.git
synced 2024-11-16 08:36:27 +01:00
24 lines
686 B
TypeScript
24 lines
686 B
TypeScript
import { EntityRepository, Repository } from 'typeorm';
|
|
import { UserGroupInvite } from '../entities/user-group-invite';
|
|
import { UserGroups } from '..';
|
|
import { ensure } from '../../prelude/ensure';
|
|
|
|
@EntityRepository(UserGroupInvite)
|
|
export class UserGroupInviteRepository extends Repository<UserGroupInvite> {
|
|
public async pack(
|
|
src: UserGroupInvite['id'] | UserGroupInvite,
|
|
) {
|
|
const invite = typeof src === 'object' ? src : await this.findOne(src).then(ensure);
|
|
|
|
return {
|
|
id: invite.id,
|
|
group: await UserGroups.pack(invite.userGroup || invite.userGroupId),
|
|
};
|
|
}
|
|
|
|
public packMany(
|
|
invites: any[],
|
|
) {
|
|
return Promise.all(invites.map(x => this.pack(x)));
|
|
}
|
|
}
|