From 7083bbc04fde33bdfad11e80cb7d43d86a562c39 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Mon, 26 Oct 2020 16:03:01 +0100 Subject: [PATCH 1/5] Chat previews now expanded with aspect ratio Instead of cropping the previews in the conversation to a square, they are now using a limited height but their width is computed based on aspect ratio. This is done by passing different arguments to the previews endpoint so it delivers a preview with the matching size. Adjusted styles around the preview to make it look better. Expanded image preview height to 384 as it looks better. Signed-off-by: Vincent Petry --- .../Message/MessagePart/FilePreview.vue | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue b/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue index 2d4f5844bd1..a8e2a904540 100644 --- a/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue +++ b/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue @@ -28,7 +28,7 @@ :class="{ 'file-preview--viewer-available': isViewerAvailable, 'file-preview--upload-editor': isUploadEditor }" @click="handleClick" @keydown.enter="handleClick"> - Date: Mon, 26 Oct 2020 20:10:42 +0100 Subject: [PATCH 2/5] Add size to system message from shared file Signed-off-by: Vincent Petry --- lib/Chat/Parser/SystemMessage.php | 3 +++ tests/php/Chat/Parser/SystemMessageTest.php | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/lib/Chat/Parser/SystemMessage.php b/lib/Chat/Parser/SystemMessage.php index 1b892c410f1..c69aeaf9598 100644 --- a/lib/Chat/Parser/SystemMessage.php +++ b/lib/Chat/Parser/SystemMessage.php @@ -323,6 +323,7 @@ protected function getFileFromShare(Participant $participant, string $shareId): $share = $this->shareProvider->getShareById($shareId); $node = $share->getNode(); $name = $node->getName(); + $size = $node->getSize(); $path = $name; if (!$participant->isGuest()) { @@ -349,6 +350,7 @@ protected function getFileFromShare(Participant $participant, string $shareId): $fullPath = $userNode->getPath(); $pathSegments = explode('/', $fullPath, 4); $name = $userNode->getName(); + $size = $userNode->getSize(); $path = $pathSegments[3] ?? $path; } } else { @@ -370,6 +372,7 @@ protected function getFileFromShare(Participant $participant, string $shareId): 'type' => 'file', 'id' => (string) $node->getId(), 'name' => $name, + 'size' => $size, 'path' => $path, 'link' => $url, 'mimetype' => $node->getMimeType(), diff --git a/tests/php/Chat/Parser/SystemMessageTest.php b/tests/php/Chat/Parser/SystemMessageTest.php index 955cfaf3c8e..3231c45c3ac 100644 --- a/tests/php/Chat/Parser/SystemMessageTest.php +++ b/tests/php/Chat/Parser/SystemMessageTest.php @@ -433,6 +433,9 @@ public function testGetFileFromShareForGuest() { $node->expects($this->once()) ->method('getMimeType') ->willReturn('text/plain'); + $node->expects($this->once()) + ->method('getSize') + ->willReturn(65530); $share = $this->createMock(IShare::class); $share->expects($this->once()) @@ -469,6 +472,7 @@ public function testGetFileFromShareForGuest() { 'type' => 'file', 'id' => '54', 'name' => 'name', + 'size' => 65530, 'path' => 'name', 'link' => 'absolute-link', 'mimetype' => 'text/plain', @@ -490,6 +494,9 @@ public function testGetFileFromShareForOwner() { $node->expects($this->once()) ->method('getMimeType') ->willReturn('httpd/unix-directory'); + $node->expects($this->once()) + ->method('getSize') + ->willReturn(65520); $share = $this->createMock(IShare::class); $share->expects($this->once()) @@ -529,6 +536,7 @@ public function testGetFileFromShareForOwner() { 'type' => 'file', 'id' => '54', 'name' => 'name', + 'size' => 65520, 'path' => 'path/to/file/name', 'link' => 'absolute-link-owner', 'mimetype' => 'httpd/unix-directory', @@ -547,6 +555,9 @@ public function testGetFileFromShareForRecipient() { $node->expects($this->once()) ->method('getMimeType') ->willReturn('application/octet-stream'); + $node->expects($this->once()) + ->method('getSize') + ->willReturn(65510); $share = $this->createMock(IShare::class); $share->expects($this->once()) @@ -573,6 +584,9 @@ public function testGetFileFromShareForRecipient() { $file->expects($this->once()) ->method('getPath') ->willReturn('/user/files/Shared/different'); + $file->expects($this->once()) + ->method('getSize') + ->willReturn(65515); $userFolder = $this->createMock(Folder::class); $userFolder->expects($this->once()) @@ -602,6 +616,7 @@ public function testGetFileFromShareForRecipient() { 'type' => 'file', 'id' => '54', 'name' => 'different', + 'size' => 65515, 'path' => 'Shared/different', 'link' => 'absolute-link-owner', 'mimetype' => 'application/octet-stream', From 549d8902c6b86e80162a9fddb00fa03e66e6417b Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Mon, 26 Oct 2020 20:58:58 +0100 Subject: [PATCH 3/5] Direct preview for GIFs + guest mode previews Use direct URL for small GIFS. Added preview support for guest mode. Signed-off-by: Vincent Petry --- .../Message/MessagePart/FilePreview.vue | 40 +++++++++++++++---- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue b/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue index a8e2a904540..7364ae4fe82 100644 --- a/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue +++ b/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue @@ -51,7 +51,7 @@