mirror of
https://github.com/paricafe/misskey.git
synced 2024-11-29 12:26:43 -06:00
1c67c26bd8
* wip * wip * wip * Update following.ts * wip * wip * wip * Update resolve-user.ts * maxQueryExecutionTime * wip * wip
24 lines
715 B
TypeScript
24 lines
715 B
TypeScript
import { db } from '@/db/postgre.js';
|
|
import { UserGroup } from '@/models/entities/user-group.js';
|
|
import { UserGroupJoinings } from '../index.js';
|
|
import { Packed } from '@/misc/schema.js';
|
|
|
|
export const UserGroupRepository = db.getRepository(UserGroup).extend({
|
|
async pack(
|
|
src: UserGroup['id'] | UserGroup,
|
|
): Promise<Packed<'UserGroup'>> {
|
|
const userGroup = typeof src === 'object' ? src : await this.findOneByOrFail({ id: src });
|
|
|
|
const users = await UserGroupJoinings.findBy({
|
|
userGroupId: userGroup.id,
|
|
});
|
|
|
|
return {
|
|
id: userGroup.id,
|
|
createdAt: userGroup.createdAt.toISOString(),
|
|
name: userGroup.name,
|
|
ownerId: userGroup.userId,
|
|
userIds: users.map(x => x.userId),
|
|
};
|
|
},
|
|
});
|