fix(UserEntityService): meProfile fetch problem

This commit is contained in:
オスカー、 2024-08-28 01:42:10 +09:00
parent 9319fa3bc7
commit 6bc715847d
Signed by: SWREI
GPG Key ID: 139D6573F92DA9F7

View File

@ -412,13 +412,13 @@ export class UserEntityService implements OnModuleInit {
}, options);
const user = typeof src === 'object' ? src : await this.usersRepository.findOneByOrFail({ id: src });
const meObject = await this.usersRepository.findOneByOrFail({ id: me?.id });
const meProfile = await this.userProfilesRepository.findOneByOrFail({ userId: user.id });
const isDetailed = opts.schema !== 'UserLite';
const meId = me ? me.id : null;
const isMe = meId === user.id;
const iAmModerator = me ? (await this.roleService.isModerator(me as MiUser)) && !meObject.isVacation && meProfile.twoFactorEnabled : false;
const meObject = await this.usersRepository.findOneBy({ id: me?.id });
const meProfile = await this.userProfilesRepository.findOneBy({ userId: me?.id });
const iAmModerator = me ? (await this.roleService.isModerator(me as MiUser)) && !meObject?.isVacation && meProfile?.twoFactorEnabled : false;
if (user.isSuspended && !iAmModerator) throw new IdentifiableError('85ab9bd7-3a41-4530-959d-f07073900109', `User ${user.id} has been suspended.`);
const profile = isDetailed