import { Inject, Injectable } from '@nestjs/common'; import type { UserProfilesRepository, UsersRepository } from '@/models/index.js'; import { Endpoint } from '@/server/api/endpoint-base.js'; import { DI } from '@/di-symbols.js'; // eslint-disable-next-line import/no-default-export @Injectable() export default class extends Endpoint<'admin/update-user-note'> { name = 'admin/update-user-note' as const; constructor( @Inject(DI.usersRepository) private usersRepository: UsersRepository, @Inject(DI.userProfilesRepository) private userProfilesRepository: UserProfilesRepository, ) { super(async (ps, me) => { const user = await this.usersRepository.findOneBy({ id: ps.userId }); if (user == null) { throw new Error('user not found'); } await this.userProfilesRepository.update({ userId: user.id }, { moderationNote: ps.text, }); }); } }