minimal fixes, thanks tests

This commit is contained in:
dakkar 2024-05-31 11:36:47 +01:00
parent f412a074ff
commit ad8d916775
2 changed files with 3 additions and 2 deletions

View file

@ -632,8 +632,8 @@ export class DriveService {
@bindThis
public async updateFile(file: MiDriveFile, values: Partial<MiDriveFile>, updater: MiUser) {
const profile = await this.userProfilesRepository.findOneBy({ userId: file.userId });
const alwaysMarkNsfw = (await this.roleService.getUserPolicies(file.userId)).alwaysMarkNsfw || (profile !== null && profile!.alwaysMarkNsfw);
const profile = file.userId ? await this.userProfilesRepository.findOneBy({ userId: file.userId }) : null;
const alwaysMarkNsfw = file.userId ? (await this.roleService.getUserPolicies(file.userId)).alwaysMarkNsfw || (profile !== null && profile!.alwaysMarkNsfw) : false;
if (values.name != null && !this.driveFileEntityService.validateFileName(values.name)) {
throw new DriveService.InvalidFileNameError();

View file

@ -16,6 +16,7 @@ import { MetaService } from '@/core/MetaService.js';
import { FanoutTimelineEndpointService } from '@/core/FanoutTimelineEndpointService.js';
import { MiLocalUser } from '@/models/User.js';
import { ApiError } from '../../error.js';
import { Brackets } from 'typeorm';
export const meta = {
tags: ['notes', 'channels'],