mirror of
https://github.com/hotomoe/hotomoe
synced 2024-12-16 15:48:09 +09:00
2470afaa2e
* wip * Update CHANGELOG.md * wip * wip * wip * Update create.ts * wip * wip * Update CHANGELOG.md * wip * wip * wip * wip * wip * wip * wip * Update CHANGELOG.md * wip * wip * Update delete.ts * Update delete.ts * wip * wip * wip * Update account-info.vue * wip * wip * Update settings.vue * Update user-info.vue * wip * Update show-file.ts * Update show-user.ts * wip * wip * Update delete.ts * wip * wip * Update overview.moderators.vue * Create 1673500412259-Role.js * wip * wip * Update roles.vue * 色 * Update roles.vue * integrate silence * wip * wip
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import { Inject, Injectable } from '@nestjs/common';
|
|
import type { UsersRepository } from '@/models/index.js';
|
|
import { QueueService } from '@/core/QueueService.js';
|
|
import { UserSuspendService } from '@/core/UserSuspendService.js';
|
|
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
|
import { DI } from '@/di-symbols.js';
|
|
import { bindThis } from '@/decorators.js';
|
|
|
|
@Injectable()
|
|
export class DeleteAccountService {
|
|
constructor(
|
|
@Inject(DI.usersRepository)
|
|
private usersRepository: UsersRepository,
|
|
|
|
private userSuspendService: UserSuspendService,
|
|
private queueService: QueueService,
|
|
private globalEventServie: GlobalEventService,
|
|
) {
|
|
}
|
|
|
|
@bindThis
|
|
public async deleteAccount(user: {
|
|
id: string;
|
|
host: string | null;
|
|
}): Promise<void> {
|
|
const _user = await this.usersRepository.findOneByOrFail({ id: user.id });
|
|
if (_user.isRoot) throw new Error('cannot delete a root account');
|
|
|
|
// 物理削除する前にDelete activityを送信する
|
|
await this.userSuspendService.doPostSuspend(user).catch(e => {});
|
|
|
|
this.queueService.createDeleteAccountJob(user, {
|
|
soft: false,
|
|
});
|
|
|
|
await this.usersRepository.update(user.id, {
|
|
isDeleted: true,
|
|
});
|
|
|
|
// Terminate streaming
|
|
this.globalEventServie.publishUserEvent(user.id, 'terminate', {});
|
|
}
|
|
}
|