From 7d896c3155d9561e3733a56f192020006cd8079d Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 7 Mar 2024 18:40:45 +0100 Subject: [PATCH] Add bucketId and fileId to image data --- app/controllers/api/messaging.php | 12 ++++++++++-- src/Appwrite/Platform/Workers/Messaging.php | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/messaging.php b/app/controllers/api/messaging.php index 8a15de5173..50128cbb00 100644 --- a/app/controllers/api/messaging.php +++ b/app/controllers/api/messaging.php @@ -2945,7 +2945,11 @@ App::post('/v1/messaging/messages/push') throw new Exception(Exception::STORAGE_FILE_NOT_PUBLIC); } - $image = "{$protocol}://{$host}/v1/storage/buckets/{$bucket->getId()}/files/{$file->getId()}/view?project={$project->getId()}"; + $image = [ + 'bucketId' => $bucket->getId(), + 'fileId' => $file->getId(), + 'url' => "{$protocol}://{$host}/v1/storage/buckets/{$bucket->getId()}/files/{$file->getId()}/view?project={$project->getId()}", + ]; } $pushData = []; @@ -3770,7 +3774,11 @@ App::patch('/v1/messaging/messages/push/:messageId') throw new Exception(Exception::STORAGE_FILE_NOT_PUBLIC); } - $pushData['image'] = "{$protocol}://{$host}/v1/storage/buckets/{$bucket->getId()}/files/{$file->getId()}/view?project={$project->getId()}"; + $pushData['image'] = [ + 'bucketId' => $bucket->getId(), + 'fileId' => $file->getId(), + 'url' => "{$protocol}://{$host}/v1/storage/buckets/{$bucket->getId()}/files/{$file->getId()}/view?project={$project->getId()}" + ]; } $message->setAttribute('data', $pushData); diff --git a/src/Appwrite/Platform/Workers/Messaging.php b/src/Appwrite/Platform/Workers/Messaging.php index 6ebedd41a3..0f1503b3e5 100644 --- a/src/Appwrite/Platform/Workers/Messaging.php +++ b/src/Appwrite/Platform/Workers/Messaging.php @@ -627,7 +627,7 @@ class Messaging extends Action $body = $message['data']['body']; $data = $message['data']['data'] ?? null; $action = $message['data']['action'] ?? null; - $image = $message['data']['image'] ?? null; + $image = $message['data']['image']['url'] ?? null; $sound = $message['data']['sound'] ?? null; $icon = $message['data']['icon'] ?? null; $color = $message['data']['color'] ?? null;