mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-21 00:15:08 +01:00
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import { Inject, Injectable } from '@nestjs/common';
|
|
import { DI } from '@/di-symbols.js';
|
|
import type { UserGroupInvitationsRepository } from '@/models/index.js';
|
|
import { awaitAll } from '@/misc/prelude/await-all.js';
|
|
import type { Packed } from '@/misc/schema.js';
|
|
import type { } from '@/models/entities/Blocking.js';
|
|
import type { User } from '@/models/entities/User.js';
|
|
import type { UserGroupInvitation } from '@/models/entities/UserGroupInvitation.js';
|
|
import { UserEntityService } from './UserEntityService.js';
|
|
import { UserGroupEntityService } from './UserGroupEntityService.js';
|
|
import { bindThis } from '@/decorators.js';
|
|
|
|
@Injectable()
|
|
export class UserGroupInvitationEntityService {
|
|
constructor(
|
|
@Inject(DI.userGroupInvitationsRepository)
|
|
private userGroupInvitationsRepository: UserGroupInvitationsRepository,
|
|
|
|
private userGroupEntityService: UserGroupEntityService,
|
|
) {
|
|
}
|
|
|
|
@bindThis
|
|
public async pack(
|
|
src: UserGroupInvitation['id'] | UserGroupInvitation,
|
|
) {
|
|
const invitation = typeof src === 'object' ? src : await this.userGroupInvitationsRepository.findOneByOrFail({ id: src });
|
|
|
|
return {
|
|
id: invitation.id,
|
|
group: await this.userGroupEntityService.pack(invitation.userGroup ?? invitation.userGroupId),
|
|
};
|
|
}
|
|
|
|
@bindThis
|
|
public packMany(
|
|
invitations: any[],
|
|
) {
|
|
return Promise.all(invitations.map(x => this.pack(x)));
|
|
}
|
|
}
|
|
|