This commit is contained in:
syuilo 2023-09-23 14:22:43 +09:00
parent 7c96d4a611
commit 7c6d6d698a
2 changed files with 12 additions and 0 deletions

View File

@ -445,6 +445,7 @@ export class RoleService implements OnApplicationShutdown {
this.globalEventService.publishInternalEvent('userRoleUnassigned', existing);
if (moderator) {
const role = await this.rolesRepository.findOneByOrFail({ id: roleId });
this.moderationLogService.log(moderator, 'roleUnassigned', {
roleId: roleId,
roleName: role.name,

View File

@ -7,6 +7,7 @@ import { Inject, Injectable } from '@nestjs/common';
import type { UserProfilesRepository, UsersRepository } from '@/models/_.js';
import { Endpoint } from '@/server/api/endpoint-base.js';
import { DI } from '@/di-symbols.js';
import { ModerationLogService } from '@/core/ModerationLogService.js';
export const meta = {
tags: ['admin'],
@ -32,6 +33,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
@Inject(DI.userProfilesRepository)
private userProfilesRepository: UserProfilesRepository,
private moderationLogService: ModerationLogService,
) {
super(meta, paramDef, async (ps, me) => {
const user = await this.usersRepository.findOneBy({ id: ps.userId });
@ -40,9 +43,17 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
throw new Error('user not found');
}
const currentProfile = await this.userProfilesRepository.findOneBy({ userId: user.id });
await this.userProfilesRepository.update({ userId: user.id }, {
moderationNote: ps.text,
});
this.moderationLogService.log(me, 'userNoteUpdated', {
userId: user.id,
before: currentProfile?.moderationNote,
after: ps.text,
});
});
}
}