From a8e3d19c5cfb6ff034f6a47371d76ca01d4122d6 Mon Sep 17 00:00:00 2001 From: Hazelnoot Date: Wed, 22 Oct 2025 16:32:31 -0400 Subject: [PATCH] fix moderation notes not saving --- .../api/endpoints/admin/update-user-note.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/admin/update-user-note.ts b/packages/backend/src/server/api/endpoints/admin/update-user-note.ts index e9930422c0..2d65940578 100644 --- a/packages/backend/src/server/api/endpoints/admin/update-user-note.ts +++ b/packages/backend/src/server/api/endpoints/admin/update-user-note.ts @@ -8,6 +8,8 @@ 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'; +import { InternalEventService } from '@/global/InternalEventService.js'; +import { CacheService } from '@/core/CacheService.js'; export const meta = { tags: ['admin'], @@ -34,23 +36,23 @@ export default class extends Endpoint { // eslint- @Inject(DI.userProfilesRepository) private userProfilesRepository: UserProfilesRepository, + private readonly internalEventService: InternalEventService, + private readonly cacheService: CacheService, 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'); - } - - const currentProfile = await this.userProfilesRepository.findOneByOrFail({ userId: user.id }); + const [user, currentProfile] = await Promise.all([ + this.cacheService.findUserById(ps.userId), + this.cacheService.userProfileCache.fetch(ps.userId), + ]); await this.userProfilesRepository.update({ userId: user.id }, { moderationNote: ps.text, }); + await this.internalEventService.emit('updateUserProfile', { userId: user.id }); - this.moderationLogService.log(me, 'updateUserNote', { + await this.moderationLogService.log(me, 'updateUserNote', { userId: user.id, userUsername: user.username, userHost: user.host,