wip
This commit is contained in:
parent
7c96d4a611
commit
7c6d6d698a
|
@ -445,6 +445,7 @@ export class RoleService implements OnApplicationShutdown {
|
||||||
this.globalEventService.publishInternalEvent('userRoleUnassigned', existing);
|
this.globalEventService.publishInternalEvent('userRoleUnassigned', existing);
|
||||||
|
|
||||||
if (moderator) {
|
if (moderator) {
|
||||||
|
const role = await this.rolesRepository.findOneByOrFail({ id: roleId });
|
||||||
this.moderationLogService.log(moderator, 'roleUnassigned', {
|
this.moderationLogService.log(moderator, 'roleUnassigned', {
|
||||||
roleId: roleId,
|
roleId: roleId,
|
||||||
roleName: role.name,
|
roleName: role.name,
|
||||||
|
|
|
@ -7,6 +7,7 @@ import { Inject, Injectable } from '@nestjs/common';
|
||||||
import type { UserProfilesRepository, UsersRepository } from '@/models/_.js';
|
import type { UserProfilesRepository, UsersRepository } from '@/models/_.js';
|
||||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
|
import { ModerationLogService } from '@/core/ModerationLogService.js';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['admin'],
|
tags: ['admin'],
|
||||||
|
@ -32,6 +33,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
|
|
||||||
@Inject(DI.userProfilesRepository)
|
@Inject(DI.userProfilesRepository)
|
||||||
private userProfilesRepository: UserProfilesRepository,
|
private userProfilesRepository: UserProfilesRepository,
|
||||||
|
|
||||||
|
private moderationLogService: ModerationLogService,
|
||||||
) {
|
) {
|
||||||
super(meta, paramDef, async (ps, me) => {
|
super(meta, paramDef, async (ps, me) => {
|
||||||
const user = await this.usersRepository.findOneBy({ id: ps.userId });
|
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');
|
throw new Error('user not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const currentProfile = await this.userProfilesRepository.findOneBy({ userId: user.id });
|
||||||
|
|
||||||
await this.userProfilesRepository.update({ userId: user.id }, {
|
await this.userProfilesRepository.update({ userId: user.id }, {
|
||||||
moderationNote: ps.text,
|
moderationNote: ps.text,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.moderationLogService.log(me, 'userNoteUpdated', {
|
||||||
|
userId: user.id,
|
||||||
|
before: currentProfile?.moderationNote,
|
||||||
|
after: ps.text,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue