From 338e811dae3c0b618c3b986555826e64e0948a43 Mon Sep 17 00:00:00 2001 From: provokateurin Date: Sat, 6 Apr 2024 23:45:32 +0200 Subject: [PATCH] fix: Set all rich object parameter values to string Signed-off-by: provokateurin --- lib/Chat/Parser/SystemMessage.php | 8 ++++---- src/types/index.ts | 6 +++--- tests/php/Chat/Parser/SystemMessageTest.php | 16 ++++++++-------- 3 files changed, 15 insertions(+), 15 deletions(-) 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/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']));