mirror of
https://github.com/paricafe/misskey.git
synced 2024-11-24 14:06:44 -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;
|
"deleteNote": string;
|
||||||
"createGlobalAnnouncement": string;
|
"createGlobalAnnouncement": string;
|
||||||
"createUserAnnouncement": string;
|
"createUserAnnouncement": string;
|
||||||
|
"resetPassword": string;
|
||||||
|
"suspendRemoteInstance": string;
|
||||||
|
"unsuspendRemoteInstance": string;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
declare const locales: {
|
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
|
@bindThis
|
||||||
public dispose(): void {
|
public dispose(): void {
|
||||||
this.redisForSub.off('message', this.onMessage);
|
this.redisForSub.off('message', this.onMessage);
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import type { RolesRepository } from '@/models/_.js';
|
import type { RolesRepository } from '@/models/_.js';
|
||||||
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import { ApiError } from '@/server/api/error.js';
|
import { ApiError } from '@/server/api/error.js';
|
||||||
|
import { RoleService } from '@/core/RoleService.js';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['admin', 'role'],
|
tags: ['admin', 'role'],
|
||||||
|
@ -41,17 +41,14 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
@Inject(DI.rolesRepository)
|
@Inject(DI.rolesRepository)
|
||||||
private rolesRepository: 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 });
|
const role = await this.rolesRepository.findOneBy({ id: ps.roleId });
|
||||||
if (role == null) {
|
if (role == null) {
|
||||||
throw new ApiError(meta.errors.noSuchRole);
|
throw new ApiError(meta.errors.noSuchRole);
|
||||||
}
|
}
|
||||||
await this.rolesRepository.delete({
|
await this.roleService.delete(role, me);
|
||||||
id: ps.roleId,
|
|
||||||
});
|
|
||||||
this.globalEventService.publishInternalEvent('roleDeleted', role);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ export type ModerationLogPayloads = {
|
||||||
};
|
};
|
||||||
deleteRole: {
|
deleteRole: {
|
||||||
roleId: string;
|
roleId: string;
|
||||||
roleName: string;
|
role: any;
|
||||||
};
|
};
|
||||||
clearQueue: Record<string, never>;
|
clearQueue: Record<string, never>;
|
||||||
promoteQueue: Record<string, never>;
|
promoteQueue: Record<string, never>;
|
||||||
|
|
|
@ -103,7 +103,7 @@ export type ModerationLogPayloads = {
|
||||||
};
|
};
|
||||||
deleteRole: {
|
deleteRole: {
|
||||||
roleId: string;
|
roleId: string;
|
||||||
roleName: string;
|
role: any;
|
||||||
};
|
};
|
||||||
clearQueue: Record<string, never>;
|
clearQueue: Record<string, never>;
|
||||||
promoteQueue: Record<string, never>;
|
promoteQueue: Record<string, never>;
|
||||||
|
|
Loading…
Reference in a new issue