Skip to content

Commit

Permalink
fix: fixed importing types in userCanUploadPolicy
Browse files Browse the repository at this point in the history
  • Loading branch information
slaveeks committed Apr 3, 2024
1 parent 6db0ae8 commit 075a9e8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/presentation/http/policies/userCanUpload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { isEmpty, notEmpty } from '@infrastructure/utils/empty.js';
import type { PolicyContext } from '../types/PolicyContext.js';
import { MemberRole } from '@domain/entities/team.js';
import hasProperty from '@infrastructure/utils/hasProperty.js';
import type { Location } from '@domain/entities/file.js';
import { FileTypes } from '@domain/entities/file.js';
import type { FileLocation } from '@domain/entities/file.js';
import { FileType } from '@domain/entities/file.js';
import type { Note, NotePublicId } from '@domain/entities/note.js';

/**
Expand All @@ -16,8 +16,8 @@ export default async function userCanUploadFile(context: PolicyContext): Promise
const { request, reply, domainServices } = context;
const { userId } = request;

let fileType: FileTypes;
let location: Location;
let fileType: FileType;
let location: FileLocation;

/**
* User must be authorized to upload files
Expand All @@ -30,16 +30,16 @@ export default async function userCanUploadFile(context: PolicyContext): Promise
* Check that key and type are provided
*/
if (hasProperty(request.body, 'type') && notEmpty(request.body.type) && hasProperty(request.body, 'location') && notEmpty(request.body.location)) {
fileType = request.body.type as FileTypes;
location = request.body.location as Location;
fileType = request.body.type as FileType;
location = request.body.location as FileLocation;
} else {
return await reply.notAcceptable('File type or location not provided');
}

/**
* If file type is note attachement, check user permission for editing note
*/
if (fileType === FileTypes.NoteAttachment) {
if (fileType === FileType.NoteAttachment) {
if (hasProperty(location, 'noteId')) {
let note: Note;

Expand Down

0 comments on commit 075a9e8

Please sign in to comment.