diff --git a/lib/Chat/Parser/SystemMessage.php b/lib/Chat/Parser/SystemMessage.php index d70bb56bfa1..30ceaba620d 100644 --- a/lib/Chat/Parser/SystemMessage.php +++ b/lib/Chat/Parser/SystemMessage.php @@ -800,11 +800,11 @@ protected function getFileFromShare(?Participant $participant, string $shareId): 'type' => 'file', 'id' => (string) $fileId, 'name' => $name, - 'size' => $size, + 'size' => (string) $size, 'path' => $path, 'link' => $url, 'etag' => $node->getEtag(), - 'permissions' => $node->getPermissions(), + 'permissions' => (string) $node->getPermissions(), 'mimetype' => $node->getMimeType(), 'preview-available' => $isPreviewAvailable ? 'yes' : 'no', ]; @@ -814,8 +814,8 @@ protected function getFileFromShare(?Participant $participant, string $shareId): try { $sizeMetadata = $this->metadataCache->getMetadataPhotosSizeForFileId($fileId); if (isset($sizeMetadata['width'], $sizeMetadata['height'])) { - $data['width'] = $sizeMetadata['width']; - $data['height'] = $sizeMetadata['height']; + $data['width'] = (string) $sizeMetadata['width']; + $data['height'] = (string) $sizeMetadata['height']; } } catch (FilesMetadataNotFoundException) { } diff --git a/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue b/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue index 08865087388..da9f4ac00e2 100644 --- a/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue +++ b/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue @@ -153,8 +153,8 @@ export default { * File size in bytes */ size: { - type: Number, - default: -1, + type: String, + default: '-1', }, /** * Download link @@ -181,8 +181,8 @@ export default { * File ETag */ permissions: { - type: Number, - default: 0, + type: String, + default: '0', }, /** * Whether a preview is available, string "yes" for yes @@ -198,7 +198,7 @@ export default { * If preview and metadata are available, return width */ width: { - type: Number, + type: String, default: null, }, @@ -206,7 +206,7 @@ export default { * If preview and metadata are available, return height */ height: { - type: Number, + type: String, default: null, }, @@ -407,12 +407,12 @@ export default { } const sizeMultiplicator = Math.min( - (heightConstraint > this.height ? 1 : (heightConstraint / this.height)), - (widthConstraint > this.width ? 1 : (widthConstraint / this.width)) + (heightConstraint > parseInt(this.height, 10) ? 1 : (heightConstraint / parseInt(this.height, 10))), + (widthConstraint > parseInt(this.width, 10) ? 1 : (widthConstraint / parseInt(this.width, 10))) ) return { - width: this.width * sizeMultiplicator + 'px', + width: parseInt(this.width, 10) * sizeMultiplicator + 'px', aspectRatio: this.width + '/' + this.height, } }, @@ -426,7 +426,7 @@ export default { return PREVIEW_TYPE.MIME_ICON } const maxGifSize = getCapabilities()?.spreed?.config?.previews?.['max-gif-size'] || 3145728 - if (this.mimetype === 'image/gif' && this.size <= maxGifSize) { + if (this.mimetype === 'image/gif' && parseInt(this.size, 10) <= maxGifSize) { return PREVIEW_TYPE.DIRECT } diff --git a/src/types/index.ts b/src/types/index.ts index 02c31e34125..4f40e6e4a80 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -43,9 +43,9 @@ export type Participant = components['schemas']['Participant'] export type Mention = RichObject<'server'|'call-type'|'icon-url'> export type File = RichObject<'size'|'path'|'link'|'mimetype'|'preview-available'> & { 'etag': string, - 'permissions': number, - 'width': number, - 'height': number, + 'permissions': string, + 'width': string, + 'height': string, } export type ChatMessage = components['schemas']['ChatMessageWithParent'] export type receiveMessagesParams = ApiOptions['params'] diff --git a/tests/php/Chat/Parser/SystemMessageTest.php b/tests/php/Chat/Parser/SystemMessageTest.php index ae4ea08058a..269643705c9 100644 --- a/tests/php/Chat/Parser/SystemMessageTest.php +++ b/tests/php/Chat/Parser/SystemMessageTest.php @@ -679,15 +679,15 @@ public function testGetFileFromShareForGuest() { 'type' => 'file', 'id' => '54', 'name' => 'name', - 'size' => 65530, + 'size' => '65530', 'path' => 'name', 'link' => 'absolute-link', 'etag' => '1872ade88f3013edeb33decd74a4f947', - 'permissions' => 27, + 'permissions' => '27', 'mimetype' => 'image/png', 'preview-available' => 'yes', - 'width' => 1234, - 'height' => 4567, + 'width' => '1234', + 'height' => '4567', ], self::invokePrivate($parser, 'getFileFromShare', [$participant, '23'])); } @@ -760,11 +760,11 @@ public function testGetFileFromShareForOwner() { 'type' => 'file', 'id' => '54', 'name' => 'name', - 'size' => 65520, + 'size' => '65520', 'path' => 'path/to/file/name', 'link' => 'absolute-link-owner', 'etag' => '1872ade88f3013edeb33decd74a4f947', - 'permissions' => 27, + 'permissions' => '27', 'mimetype' => 'httpd/unix-directory', 'preview-available' => 'no', ], self::invokePrivate($parser, 'getFileFromShare', [$participant, '23'])); @@ -847,11 +847,11 @@ public function testGetFileFromShareForRecipient() { 'type' => 'file', 'id' => '54', 'name' => 'different', - 'size' => 65515, + 'size' => '65515', 'path' => 'Shared/different', 'link' => 'absolute-link-owner', 'etag' => '1872ade88f3013edeb33decd74a4f947', - 'permissions' => 27, + 'permissions' => '27', 'mimetype' => 'application/octet-stream', 'preview-available' => 'no', ], self::invokePrivate($parser, 'getFileFromShare', [$participant, '23']));