なんかもうめっちゃ変えた
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import define from '../../define.js';
|
||||
import { Users } from '@/models/index.js';
|
||||
import { insertModerationLog } from '@/services/insert-moderation-log.js';
|
||||
import { doPostUnsuspend } from '@/services/unsuspend-user.js';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||
import { UsersRepository } from '@/models/index.js';
|
||||
import { ModerationLogService } from '@/core/ModerationLogService.js';
|
||||
import { UserSuspendService } from '@/core/UserSuspendService.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
|
||||
export const meta = {
|
||||
tags: ['admin'],
|
||||
@@ -19,20 +21,31 @@ export const paramDef = {
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, paramDef, async (ps, me) => {
|
||||
const user = await Users.findOneBy({ id: ps.userId });
|
||||
@Injectable()
|
||||
export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||
constructor(
|
||||
@Inject(DI.usersRepository)
|
||||
private usersRepository: UsersRepository,
|
||||
|
||||
if (user == null) {
|
||||
throw new Error('user not found');
|
||||
private userSuspendService: UserSuspendService,
|
||||
private moderationLogService: ModerationLogService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
const user = await this.usersRepository.findOneBy({ id: ps.userId });
|
||||
|
||||
if (user == null) {
|
||||
throw new Error('user not found');
|
||||
}
|
||||
|
||||
await this.usersRepository.update(user.id, {
|
||||
isSuspended: false,
|
||||
});
|
||||
|
||||
this.moderationLogService.insertModerationLog(me, 'unsuspend', {
|
||||
targetId: user.id,
|
||||
});
|
||||
|
||||
this.userSuspendService.doPostUnsuspend(user);
|
||||
});
|
||||
}
|
||||
|
||||
await Users.update(user.id, {
|
||||
isSuspended: false,
|
||||
});
|
||||
|
||||
insertModerationLog(me, 'unsuspend', {
|
||||
targetId: user.id,
|
||||
});
|
||||
|
||||
doPostUnsuspend(user);
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user