mirror of
https://github.com/paricafe/misskey.git
synced 2024-11-24 11:46:43 -06:00
improve moderation log
This commit is contained in:
parent
ed53b5f9bc
commit
2ad3b1fd74
5 changed files with 22 additions and 9 deletions
3
locales/index.d.ts
vendored
3
locales/index.d.ts
vendored
|
@ -2262,6 +2262,9 @@ export interface Locale {
|
|||
"deleteNote": string;
|
||||
"createGlobalAnnouncement": string;
|
||||
"createUserAnnouncement": string;
|
||||
"resetPassword": string;
|
||||
"suspendRemoteInstance": string;
|
||||
"unsuspendRemoteInstance": string;
|
||||
};
|
||||
}
|
||||
declare const locales: {
|
||||
|
|
|
@ -493,6 +493,19 @@ export class RoleService implements OnApplicationShutdown {
|
|||
}
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public async delete(role: MiRole, moderator?: MiUser): Promise<void> {
|
||||
await this.rolesRepository.delete({ id: role.id });
|
||||
this.globalEventService.publishInternalEvent('roleDeleted', role);
|
||||
|
||||
if (moderator) {
|
||||
this.moderationLogService.log(moderator, 'deleteRole', {
|
||||
roleId: role.id,
|
||||
role: role,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public dispose(): void {
|
||||
this.redisForSub.off('message', this.onMessage);
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||
import type { RolesRepository } from '@/models/_.js';
|
||||
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { ApiError } from '@/server/api/error.js';
|
||||
import { RoleService } from '@/core/RoleService.js';
|
||||
|
||||
export const meta = {
|
||||
tags: ['admin', 'role'],
|
||||
|
@ -41,17 +41,14 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
@Inject(DI.rolesRepository)
|
||||
private rolesRepository: RolesRepository,
|
||||
|
||||
private globalEventService: GlobalEventService,
|
||||
private roleService: RoleService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps) => {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
const role = await this.rolesRepository.findOneBy({ id: ps.roleId });
|
||||
if (role == null) {
|
||||
throw new ApiError(meta.errors.noSuchRole);
|
||||
}
|
||||
await this.rolesRepository.delete({
|
||||
id: ps.roleId,
|
||||
});
|
||||
this.globalEventService.publishInternalEvent('roleDeleted', role);
|
||||
await this.roleService.delete(role, me);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ export type ModerationLogPayloads = {
|
|||
};
|
||||
deleteRole: {
|
||||
roleId: string;
|
||||
roleName: string;
|
||||
role: any;
|
||||
};
|
||||
clearQueue: Record<string, never>;
|
||||
promoteQueue: Record<string, never>;
|
||||
|
|
|
@ -103,7 +103,7 @@ export type ModerationLogPayloads = {
|
|||
};
|
||||
deleteRole: {
|
||||
roleId: string;
|
||||
roleName: string;
|
||||
role: any;
|
||||
};
|
||||
clearQueue: Record<string, never>;
|
||||
promoteQueue: Record<string, never>;
|
||||
|
|
Loading…
Reference in a new issue