diff --git a/lib/Chat/Parser/SystemMessage.php b/lib/Chat/Parser/SystemMessage.php index 9cd88747ff8..d09f1a7a681 100644 --- a/lib/Chat/Parser/SystemMessage.php +++ b/lib/Chat/Parser/SystemMessage.php @@ -629,6 +629,8 @@ protected function getFileFromShare(Participant $participant, string $shareId): 'size' => $size, 'path' => $path, 'link' => $url, + 'etag' => $node->getEtag(), + 'permissions' => $node->getPermissions(), 'mimetype' => $node->getMimeType(), 'preview-available' => $this->previewManager->isAvailable($node) ? 'yes' : 'no', ]; diff --git a/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.spec.js b/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.spec.js index 5161febdd91..cc70f38dc75 100644 --- a/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.spec.js +++ b/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.spec.js @@ -48,6 +48,8 @@ describe('FilePreview.vue', () => { name: 'test.jpg', path: 'path/to/test.jpg', size: 128, + etag: '1872ade88f3013edeb33decd74a4f947', + permissions: 15, mimetype: 'image/jpeg', previewAvailable: 'yes', } @@ -370,10 +372,12 @@ describe('FilePreview.vue', () => { expect(OCA.Viewer.open).toHaveBeenCalledWith({ list: [{ basename: 'test.jpg', + etag: '1872ade88f3013edeb33decd74a4f947', fileid: 123, filename: '/path/to/test.jpg', hasPreview: true, mime: 'image/jpeg', + permissions: 'CKGWD', }], path: '/path/to/test.jpg', }) diff --git a/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue b/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue index b0c0e09fa71..7a2c4bb0656 100644 --- a/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue +++ b/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue @@ -145,6 +145,20 @@ export default { type: String, default: '', }, + /** + * File ETag + */ + etag: { + type: String, + default: '', + }, + /** + * File ETag + */ + permissions: { + type: Number, + default: 0, + }, /** * Whether a preview is available, string "yes" for yes * otherwise the string "no" @@ -448,6 +462,25 @@ export default { OCA.Files.Sidebar.state.file = this.internalAbsolutePath } + let permissions = '' + if (this.permissions) { + if (this.permissions & OC.PERMISSION_CREATE) { + permissions += 'CK' + } + if (this.permissions & OC.PERMISSION_READ) { + permissions += 'G' + } + if (this.permissions & OC.PERMISSION_UPDATE) { + permissions += 'W' + } + if (this.permissions & OC.PERMISSION_DELETE) { + permissions += 'D' + } + if (this.permissions & OC.PERMISSION_SHARE) { + permissions += 'R' + } + } + OCA.Viewer.open({ // Viewer expects an internal absolute path starting with "/". path: this.internalAbsolutePath, @@ -458,6 +491,8 @@ export default { basename: this.name, mime: this.mimetype, hasPreview: this.previewAvailable === 'yes', + etag: this.etag, + permissions, }, ], }) diff --git a/src/test-setup.js b/src/test-setup.js index f6c6b1f99d2..dfec2c4f98b 100644 --- a/src/test-setup.js +++ b/src/test-setup.js @@ -59,6 +59,14 @@ global.OC = { MimeType: { getIconUrl: jest.fn(), }, + + PERMISSION_NONE: 0, + PERMISSION_READ: 1, + PERMISSION_UPDATE: 2, + PERMISSION_CREATE: 4, + PERMISSION_DELETE: 8, + PERMISSION_SHARE: 16, + PERMISSION_ALL: 31, } global.OCA = { Talk: { diff --git a/tests/php/Chat/Parser/SystemMessageTest.php b/tests/php/Chat/Parser/SystemMessageTest.php index 6a74d2d62ce..5f0bce5f125 100644 --- a/tests/php/Chat/Parser/SystemMessageTest.php +++ b/tests/php/Chat/Parser/SystemMessageTest.php @@ -586,6 +586,12 @@ public function testGetFileFromShareForGuest() { $node->expects($this->once()) ->method('getSize') ->willReturn(65530); + $node->expects($this->once()) + ->method('getEtag') + ->willReturn(md5('etag')); + $node->expects($this->once()) + ->method('getPermissions') + ->willReturn(27); $share = $this->createMock(IShare::class); $share->expects($this->once()) @@ -625,6 +631,8 @@ public function testGetFileFromShareForGuest() { 'size' => 65530, 'path' => 'name', 'link' => 'absolute-link', + 'etag' => '1872ade88f3013edeb33decd74a4f947', + 'permissions' => 27, 'mimetype' => 'text/plain', 'preview-available' => 'yes', ], self::invokePrivate($parser, 'getFileFromShare', [$participant, '23'])); @@ -647,6 +655,12 @@ public function testGetFileFromShareForOwner() { $node->expects($this->once()) ->method('getSize') ->willReturn(65520); + $node->expects($this->once()) + ->method('getEtag') + ->willReturn(md5('etag')); + $node->expects($this->once()) + ->method('getPermissions') + ->willReturn(27); $share = $this->createMock(IShare::class); $share->expects($this->once()) @@ -693,6 +707,8 @@ public function testGetFileFromShareForOwner() { 'size' => 65520, 'path' => 'path/to/file/name', 'link' => 'absolute-link-owner', + 'etag' => '1872ade88f3013edeb33decd74a4f947', + 'permissions' => 27, 'mimetype' => 'httpd/unix-directory', 'preview-available' => 'no', ], self::invokePrivate($parser, 'getFileFromShare', [$participant, '23'])); @@ -734,6 +750,12 @@ public function testGetFileFromShareForRecipient() { $file->expects($this->once()) ->method('getSize') ->willReturn(65515); + $file->expects($this->once()) + ->method('getEtag') + ->willReturn(md5('etag')); + $file->expects($this->once()) + ->method('getPermissions') + ->willReturn(27); $file->expects($this->atLeastOnce()) ->method('getMimeType') ->willReturn('application/octet-stream'); @@ -769,6 +791,8 @@ public function testGetFileFromShareForRecipient() { 'size' => 65515, 'path' => 'Shared/different', 'link' => 'absolute-link-owner', + 'etag' => '1872ade88f3013edeb33decd74a4f947', + 'permissions' => 27, 'mimetype' => 'application/octet-stream', 'preview-available' => 'no', ], self::invokePrivate($parser, 'getFileFromShare', [$participant, '23']));