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

View File

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