Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
271a59a
refactor(AttachmentService): Some code style cleanup
mejo- Oct 25, 2023
df3e4df
chore(attachments): Remove support for obsolete `text://` format
mejo- Oct 31, 2023
8c1c6e8
feat(attachments): API endpoint to get list of attachments for a docu…
mejo- Oct 25, 2023
73cb49b
chore(attachments): Remove obsolete metadata API endpoint
mejo- Nov 15, 2023
153a85f
feat(attachments): Use getAttachmentList API endpoint in resolver
mejo- Oct 31, 2023
680ca1d
fix(attachment): Remove candidate logic from ImageView node
mejo- Nov 15, 2023
86e2b97
fix(attachments): Fix some issues with the showimage modal
mejo- Nov 21, 2023
b274e37
chore(attachments): Remove obsolete code
mejo- Nov 21, 2023
a2813ae
feat(editor): Allow to pass fileId to MarkdownContentEditor
mejo- Nov 21, 2023
bd54a68
feat(attachments): Allow to get attachments without document session
mejo- Nov 22, 2023
d15781c
chore(attachments): Remove special-handling for preview URLs
mejo- Nov 22, 2023
e4108d4
fix(attachments): Open non-image attachments in viewer or download
mejo- Nov 22, 2023
98ba0de
fix(AttachmentController): Set fileName of returned attachments
mejo- Nov 27, 2023
dade37e
chore(composer): Update autoloader maps
mejo- Nov 27, 2023
7743591
fix(attachments): Fix encoding of attachment URI component
mejo- Nov 27, 2023
ec91074
test(cy): Test to open image in modal and download attachment
mejo- Nov 28, 2023
b01c547
chore(middleware): Rename to RequireDocumentSessionOrUserOrShareToken
mejo- Nov 28, 2023
a1f8308
fix(attachments): use `getRelativePath` from userFolder for `davPath`
mejo- Nov 28, 2023
3ce2e44
test(AttachmentResolver): Refactor jest tests after parent class refa…
mejo- Nov 28, 2023
6796170
fix(attachments): Show all loaded images in ShowImageModal
mejo- Nov 28, 2023
c7e0cf0
fix(SessionMiddleware): Check if user/share have access to document
mejo- Nov 29, 2023
978cbc6
fix(AttachmentResolver): Require either fileId or session
mejo- Nov 29, 2023
77a0d4a
reactor(ImageView): Simplify attachmentType/isMediaAttachment logic
mejo- Nov 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore(attachments): Remove obsolete metadata API endpoint
Signed-off-by: Jonas <[email protected]>
  • Loading branch information
mejo- committed Nov 29, 2023
commit 73cb49b61718e39f0ea3d5d02e03128ee54b9e2f
2 changes: 0 additions & 2 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
['name' => 'Attachment#getMediaFile', 'url' => '/media', 'verb' => 'GET'],
/** @see Controller\AttachmentController::getMediaFilePreview() */
['name' => 'Attachment#getMediaFilePreview', 'url' => '/mediaPreview', 'verb' => 'GET'],
/** @see Controller\AttachmentController::getMediaFileMetadata() */
['name' => 'Attachment#getMediaFileMetadata', 'url' => '/mediaMetadata', 'verb' => 'GET'],

/** @see Controller\SessionController::create() */
['name' => 'Session#create', 'url' => '/session/{documentId}/create', 'verb' => 'PUT'],
Expand Down
26 changes: 0 additions & 26 deletions lib/Controller/AttachmentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,32 +278,6 @@ public function getMediaFilePreview(string $mediaFileName, ?string $shareToken =
return new DataResponse('', Http::STATUS_NOT_FOUND);
}

/**
* Serve the media files metadata in the editor
*/
#[NoAdminRequired]
#[PublicPage]
#[NoCSRFRequired]
#[RequireDocumentSession]
public function getMediaFileMetadata(string $mediaFileName, ?string $shareToken = null): DataResponse {
$documentId = $this->getSession()->getDocumentId();
try {
if ($shareToken) {
$metadata = $this->attachmentService->getMediaFileMetadataPublic($documentId, $mediaFileName, $shareToken);
} else {
$userId = $this->getSession()->getUserId();
$metadata = $this->attachmentService->getMediaFileMetadataPrivate($documentId, $mediaFileName, $userId);
}
if ($metadata === null) {
return new DataResponse('', Http::STATUS_NOT_FOUND);
}
return new DataResponse($metadata);
} catch (Exception $e) {
$this->logger->error('getMediaFileMetadata error', ['exception' => $e]);
return new DataResponse('', Http::STATUS_NOT_FOUND);
}
}

/**
* Allow all supported mimetypes
* Use mimetype detector for the other ones
Expand Down
54 changes: 0 additions & 54 deletions lib/Service/AttachmentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,60 +202,6 @@ private function getMediaFilePreviewFile(string $mediaFileName, File $textFile):
return null;
}

/**
* @param int $documentId
* @param string $mediaFileName
* @param string $userId
*
* @return array|null
* @throws NotFoundException
* @throws NotPermittedException
* @throws InvalidPathException
* @throws NoUserException
*/
public function getMediaFileMetadataPrivate(int $documentId, string $mediaFileName, string $userId): ?array {
$textFile = $this->getTextFile($documentId, $userId);
return $this->getMediaFileMetadata($mediaFileName, $textFile);
}

/**
* @param int $documentId
* @param string $mediaFileName
* @param string $shareToken
*
* @return array|null
* @throws NotFoundException
* @throws NotPermittedException
* @throws InvalidPathException
* @throws NoUserException
*/
public function getMediaFileMetadataPublic(int $documentId, string $mediaFileName, string $shareToken): ?array {
$textFile = $this->getTextFilePublic($documentId, $shareToken);
return $this->getMediaFileMetadata($mediaFileName, $textFile);
}

/**
* @param string $mediaFileName
* @param File $textFile
*
* @return array|null
* @throws NotFoundException
* @throws NotPermittedException
* @throws InvalidPathException
* @throws NoUserException
*/
private function getMediaFileMetadata(string $mediaFileName, File $textFile): ?array {
$attachmentFolder = $this->getAttachmentDirectoryForFile($textFile, true);
$mediaFile = $attachmentFolder->get($mediaFileName);
if ($mediaFile instanceof File) {
return [
'size' => Util::humanFileSize($mediaFile->getSize()),
'mtime' => $mediaFile->getMTime(),
];
}
return null;
}

/**
* @param int $documentId
* @param string|null $userId
Expand Down