Skip to content

Commit

Permalink
fix(attachments): use getRelativePath from userFolder for davPath
Browse files Browse the repository at this point in the history
Also don't set any davPath at all in public share. We probably don't
have DAV access there anyway.

Signed-off-by: Jonas <jonas@freesources.org>
  • Loading branch information
mejo- committed Nov 28, 2023
1 parent e6f54b0 commit c893b43
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/Service/AttachmentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ public function getAttachmentList(int $documentId, ?string $userId = null, ?Sess
: '?documentId=' . $documentId . $shareTokenUrlString;

$attachments = [];
$userFolder = $userId ? $this->rootFolder->getUserFolder($userId) : null;
foreach ($attachmentDir->getDirectoryListing() as $node) {
if (!($node instanceof File)) {
// Ignore anything but files
Expand All @@ -251,8 +252,7 @@ public function getAttachmentList(int $documentId, ?string $userId = null, ?Sess
'mimetype' => $node->getMimeType(),
'mtime' => $node->getMTime(),
'isImage' => $isImage,
'shareToken' => $shareToken,
'davPath' => '/' . implode('/', array_slice(explode('/', $node->getPath()), 3)),
'davPath' => $userFolder?->getRelativePath($node->getPath()),
'fullUrl' => $isImage
? $this->urlGenerator->linkToRouteAbsolute('text.Attachment.getImageFile') . $urlParamsBase . '&imageFileName=' . urlencode($name) . '&preferRawImage=1'
: $this->urlGenerator->linkToRouteAbsolute('text.Attachment.getMediaFile') . $urlParamsBase . '&mediaFileName=' . urlencode($name),
Expand Down
7 changes: 3 additions & 4 deletions src/nodes/ImageView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,9 @@ export default {
&& !OCA.Viewer.file
// Viewer supports mimetype
&& OCA.Viewer.mimetypes.indexOf(this.attachment.mimetype) !== -1
// Attachment has davPath (i.e. is native attachment)
&& this.attachment.davPath
// Not in share (in public share we probably don't have DAV access)
&& !this.attachment.shareToken) {
// Attachment has davPath, i.e. is native attachment and not in public share
// (in public share we probably don't have DAV access)
&& this.attachment.davPath) {
// Viewer exists, is not in use and supports mimetype
OCA.Viewer.open({ path: this.attachment.davPath })
return
Expand Down

0 comments on commit c893b43

Please sign in to comment.