From f2b202aa52548dfd034cd5d078b1570e93dbba13 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 10 Dec 2024 22:53:40 +1300 Subject: [PATCH] Update push message builder --- src/Appwrite/Platform/Workers/Messaging.php | 24 +++++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Messaging.php b/src/Appwrite/Platform/Workers/Messaging.php index 1de503cd9a..8e60425da3 100644 --- a/src/Appwrite/Platform/Workers/Messaging.php +++ b/src/Appwrite/Platform/Workers/Messaging.php @@ -676,8 +676,8 @@ class Messaging extends Action private function buildPushMessage(Document $message): Push { $to = $message['to']; - $title = ($message['data']['title'] ?? null) === '' ? null : $message['data']['title']; - $body = ($message['data']['body'] ?? null) === '' ? null : $message['data']['body']; + $title = $message['data']['title'] ?? null; + $body = $message['data']['body'] ?? null; $data = $message['data']['data'] ?? null; $action = $message['data']['action'] ?? null; $image = $message['data']['image']['url'] ?? null; @@ -686,11 +686,21 @@ class Messaging extends Action $color = $message['data']['color'] ?? null; $tag = $message['data']['tag'] ?? null; $badge = $message['data']['badge'] ?? null; - $contentAvailable = $message['data']['contentAvailable'] ?? false; - $critical = $message['data']['critical'] ?? false; - $priority = $message['data']['priority'] === 'high' - ? Priority::HIGH - : Priority::NORMAL; + $contentAvailable = $message['data']['contentAvailable'] ?? null; + $critical = $message['data']['critical'] ?? null; + $priority = $message['data']['priority'] ?? null; + + if ($title === '') { + $title = null; + } + if ($body === '') { + $body = null; + } + if ($priority !== null) { + $priority = $priority === 'high' + ? Priority::HIGH + : Priority::NORMAL; + } return new Push( $to,