From ab900d16d45d81c5677b62d1851c5ce0b5e9424f Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 3 Dec 2024 17:19:06 +1300 Subject: [PATCH 01/47] Allow apns content available --- app/controllers/api/messaging.php | 9 +++--- composer.json | 2 +- composer.lock | 33 +++++++++++++-------- src/Appwrite/Platform/Workers/Messaging.php | 4 ++- 4 files changed, 30 insertions(+), 18 deletions(-) diff --git a/app/controllers/api/messaging.php b/app/controllers/api/messaging.php index e4a627d027..7116d31ba7 100644 --- a/app/controllers/api/messaging.php +++ b/app/controllers/api/messaging.php @@ -2915,10 +2915,11 @@ App::post('/v1/messaging/messages/push') ->param('action', '', new Text(256), 'Action for push notification.', true) ->param('image', '', new CompoundUID(), 'Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as :.', true) ->param('icon', '', new Text(256), 'Icon for push notification. Available only for Android and Web Platform.', true) - ->param('sound', '', new Text(256), 'Sound for push notification. Available only for Android and IOS Platform.', true) + ->param('sound', '', new Text(256), 'Sound for push notification. Available only for Android and iOS Platform.', true) ->param('color', '', new Text(256), 'Color for push notification. Available only for Android Platform.', true) ->param('tag', '', new Text(256), 'Tag for push notification. Available only for Android Platform.', true) - ->param('badge', '', new Text(256), 'Badge for push notification. Available only for IOS Platform.', true) + ->param('badge', '', new Text(256), 'Badge for push notification. Available only for iOS Platform.', true) + ->param('contentAvailable', false, new Boolean(), 'Content available for push notification. Available only for iOS Platform.', true) ->param('draft', false, new Boolean(), 'Is message a draft', true) ->param('scheduledAt', null, new DatetimeValidator(requireDateInFuture: true), 'Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future.', true) ->inject('queueForEvents') @@ -2927,7 +2928,7 @@ App::post('/v1/messaging/messages/push') ->inject('project') ->inject('queueForMessaging') ->inject('response') - ->action(function (string $messageId, string $title, string $body, array $topics, array $users, array $targets, ?array $data, string $action, string $image, string $icon, string $sound, string $color, string $tag, string $badge, bool $draft, ?string $scheduledAt, Event $queueForEvents, Database $dbForProject, Database $dbForConsole, Document $project, Messaging $queueForMessaging, Response $response) { + ->action(function (string $messageId, string $title, string $body, array $topics, array $users, array $targets, ?array $data, string $action, string $image, string $icon, string $sound, string $color, string $tag, string $badge, bool $contentAvailable, bool $draft, ?string $scheduledAt, Event $queueForEvents, Database $dbForProject, Database $dbForConsole, Document $project, Messaging $queueForMessaging, Response $response) { $messageId = $messageId == 'unique()' ? ID::unique() : $messageId; @@ -3010,7 +3011,7 @@ App::post('/v1/messaging/messages/push') $pushData = []; - $keys = ['title', 'body', 'data', 'action', 'image', 'icon', 'sound', 'color', 'tag', 'badge']; + $keys = ['title', 'body', 'data', 'action', 'image', 'icon', 'sound', 'color', 'tag', 'badge', 'contentAvailable']; foreach ($keys as $key) { if (!empty($$key)) { diff --git a/composer.json b/composer.json index 512e203a5e..7ecf079125 100644 --- a/composer.json +++ b/composer.json @@ -59,7 +59,7 @@ "utopia-php/image": "0.7.*", "utopia-php/locale": "0.4.*", "utopia-php/logger": "0.6.*", - "utopia-php/messaging": "0.12.*", + "utopia-php/messaging": "dev-feat-apns-content-available as 0.12.2", "utopia-php/migration": "0.6.*", "utopia-php/orchestration": "0.9.*", "utopia-php/platform": "0.7.*", diff --git a/composer.lock b/composer.lock index e5aacef40c..b6e84656b6 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "fae350df93342992edd8f639948e1570", + "content-hash": "04b9739820be8136d62de48c6325e763", "packages": [ { "name": "adhocore/jwt", @@ -3878,16 +3878,16 @@ }, { "name": "utopia-php/messaging", - "version": "0.12.2", + "version": "dev-feat-apns-content-available", "source": { "type": "git", "url": "https://github.com/utopia-php/messaging.git", - "reference": "f6790fba1fcee12163d51c65d2c226a7856295d9" + "reference": "2580b8357d2dde6ed567a52e5164cfe58fb9b6dd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/messaging/zipball/f6790fba1fcee12163d51c65d2c226a7856295d9", - "reference": "f6790fba1fcee12163d51c65d2c226a7856295d9", + "url": "https://api.github.com/repos/utopia-php/messaging/zipball/2580b8357d2dde6ed567a52e5164cfe58fb9b6dd", + "reference": "2580b8357d2dde6ed567a52e5164cfe58fb9b6dd", "shasum": "" }, "require": { @@ -3898,9 +3898,9 @@ "phpmailer/phpmailer": "6.9.1" }, "require-dev": { - "laravel/pint": "1.13.11", - "phpstan/phpstan": "1.10.58", - "phpunit/phpunit": "10.5.10" + "laravel/pint": "1.*", + "phpstan/phpstan": "1.*", + "phpunit/phpunit": "11.*" }, "type": "library", "autoload": { @@ -3923,9 +3923,9 @@ ], "support": { "issues": "https://github.com/utopia-php/messaging/issues", - "source": "https://github.com/utopia-php/messaging/tree/0.12.2" + "source": "https://github.com/utopia-php/messaging/tree/feat-apns-content-available" }, - "time": "2024-10-22T01:02:20+00:00" + "time": "2024-12-03T04:09:05+00:00" }, { "name": "utopia-php/migration", @@ -8556,9 +8556,18 @@ "time": "2024-03-07T20:33:40+00:00" } ], - "aliases": [], + "aliases": [ + { + "package": "utopia-php/messaging", + "version": "dev-feat-apns-content-available", + "alias": "0.12.2", + "alias_normalized": "0.12.2.0" + } + ], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "utopia-php/messaging": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { diff --git a/src/Appwrite/Platform/Workers/Messaging.php b/src/Appwrite/Platform/Workers/Messaging.php index 58f6265ff4..5dee0fa72f 100644 --- a/src/Appwrite/Platform/Workers/Messaging.php +++ b/src/Appwrite/Platform/Workers/Messaging.php @@ -686,6 +686,7 @@ class Messaging extends Action $color = $message['data']['color'] ?? null; $tag = $message['data']['tag'] ?? null; $badge = $message['data']['badge'] ?? null; + $contentAvailable = $message['data']['contentAvailable'] ?? false; return new Push( $to, @@ -698,7 +699,8 @@ class Messaging extends Action $icon, $color, $tag, - $badge + $badge, + $contentAvailable ); } From fa49244b4b9ea481af6f61d8dfeeefdcd6e9c965 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 3 Dec 2024 22:50:40 +1300 Subject: [PATCH 02/47] Fix param type --- app/controllers/api/messaging.php | 2 +- src/Appwrite/Platform/Workers/Messaging.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/api/messaging.php b/app/controllers/api/messaging.php index 7116d31ba7..54b3eb83cb 100644 --- a/app/controllers/api/messaging.php +++ b/app/controllers/api/messaging.php @@ -2918,7 +2918,7 @@ App::post('/v1/messaging/messages/push') ->param('sound', '', new Text(256), 'Sound for push notification. Available only for Android and iOS Platform.', true) ->param('color', '', new Text(256), 'Color for push notification. Available only for Android Platform.', true) ->param('tag', '', new Text(256), 'Tag for push notification. Available only for Android Platform.', true) - ->param('badge', '', new Text(256), 'Badge for push notification. Available only for iOS Platform.', true) + ->param('badge', 0, new Integer(), 'Badge for push notification. Available only for iOS Platform.', true) ->param('contentAvailable', false, new Boolean(), 'Content available for push notification. Available only for iOS Platform.', true) ->param('draft', false, new Boolean(), 'Is message a draft', true) ->param('scheduledAt', null, new DatetimeValidator(requireDateInFuture: true), 'Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future.', true) diff --git a/src/Appwrite/Platform/Workers/Messaging.php b/src/Appwrite/Platform/Workers/Messaging.php index 5dee0fa72f..3edb0c2aed 100644 --- a/src/Appwrite/Platform/Workers/Messaging.php +++ b/src/Appwrite/Platform/Workers/Messaging.php @@ -333,7 +333,6 @@ class Messaging extends Action $message->setAttribute('status', MessageStatus::SENT); } - $message->removeAttribute('to'); foreach ($providers as $provider) { From a4611985476c5b8129f92bd3f66dcfc84e241705 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 4 Dec 2024 19:27:55 +1300 Subject: [PATCH 03/47] Add critical and priority params --- app/controllers/api/messaging.php | 25 +++++++++++++++++---- composer.lock | 8 +++---- src/Appwrite/Platform/Workers/Messaging.php | 10 ++++++++- 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/app/controllers/api/messaging.php b/app/controllers/api/messaging.php index 54b3eb83cb..45eba6e434 100644 --- a/app/controllers/api/messaging.php +++ b/app/controllers/api/messaging.php @@ -2919,7 +2919,9 @@ App::post('/v1/messaging/messages/push') ->param('color', '', new Text(256), 'Color for push notification. Available only for Android Platform.', true) ->param('tag', '', new Text(256), 'Tag for push notification. Available only for Android Platform.', true) ->param('badge', 0, new Integer(), 'Badge for push notification. Available only for iOS Platform.', true) - ->param('contentAvailable', false, new Boolean(), 'Content available for push notification. Available only for iOS Platform.', true) + ->param('contentAvailable', false, new Boolean(), 'If set to true, the notification will be delivered in the background. Available only for iOS Platform.', true) + ->param('critical', false, new Boolean(), 'If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform.', true) + ->param('priority', 'high', new WhiteList(['normal', 'high']), 'Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification.', true) ->param('draft', false, new Boolean(), 'Is message a draft', true) ->param('scheduledAt', null, new DatetimeValidator(requireDateInFuture: true), 'Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future.', true) ->inject('queueForEvents') @@ -2928,7 +2930,7 @@ App::post('/v1/messaging/messages/push') ->inject('project') ->inject('queueForMessaging') ->inject('response') - ->action(function (string $messageId, string $title, string $body, array $topics, array $users, array $targets, ?array $data, string $action, string $image, string $icon, string $sound, string $color, string $tag, string $badge, bool $contentAvailable, bool $draft, ?string $scheduledAt, Event $queueForEvents, Database $dbForProject, Database $dbForConsole, Document $project, Messaging $queueForMessaging, Response $response) { + ->action(function (string $messageId, string $title, string $body, array $topics, array $users, array $targets, ?array $data, string $action, string $image, string $icon, string $sound, string $color, string $tag, string $badge, bool $contentAvailable, bool $critical, string $priority, bool $draft, ?string $scheduledAt, Event $queueForEvents, Database $dbForProject, Database $dbForConsole, Document $project, Messaging $queueForMessaging, Response $response) { $messageId = $messageId == 'unique()' ? ID::unique() : $messageId; @@ -3011,7 +3013,7 @@ App::post('/v1/messaging/messages/push') $pushData = []; - $keys = ['title', 'body', 'data', 'action', 'image', 'icon', 'sound', 'color', 'tag', 'badge', 'contentAvailable']; + $keys = ['title', 'body', 'data', 'action', 'image', 'icon', 'sound', 'color', 'tag', 'badge', 'contentAvailable', 'critical', 'priority']; foreach ($keys as $key) { if (!empty($$key)) { @@ -3697,6 +3699,9 @@ App::patch('/v1/messaging/messages/push/:messageId') ->param('color', null, new Text(256), 'Color for push notification. Available only for Android platforms.', true) ->param('tag', null, new Text(256), 'Tag for push notification. Available only for Android platforms.', true) ->param('badge', null, new Integer(), 'Badge for push notification. Available only for iOS platforms.', true) + ->param('contentAvailable', null, new Boolean(), 'If set to true, the notification will be delivered in the background. Available only for iOS Platform.', true) + ->param('critical', null, new Boolean(), 'If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform.', true) + ->param('priority', null, new WhiteList(['normal', 'high']), 'Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification.', true) ->param('draft', null, new Boolean(), 'Is message a draft', true) ->param('scheduledAt', null, new DatetimeValidator(requireDateInFuture: true), 'Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future.', true) ->inject('queueForEvents') @@ -3705,7 +3710,7 @@ App::patch('/v1/messaging/messages/push/:messageId') ->inject('project') ->inject('queueForMessaging') ->inject('response') - ->action(function (string $messageId, ?array $topics, ?array $users, ?array $targets, ?string $title, ?string $body, ?array $data, ?string $action, ?string $image, ?string $icon, ?string $sound, ?string $color, ?string $tag, ?int $badge, ?bool $draft, ?string $scheduledAt, Event $queueForEvents, Database $dbForProject, Database $dbForConsole, Document $project, Messaging $queueForMessaging, Response $response) { + ->action(function (string $messageId, ?array $topics, ?array $users, ?array $targets, ?string $title, ?string $body, ?array $data, ?string $action, ?string $image, ?string $icon, ?string $sound, ?string $color, ?string $tag, ?int $badge, ?bool $contentAvailable, ?bool $critical, ?string $priority, ?bool $draft, ?string $scheduledAt, Event $queueForEvents, Database $dbForProject, Database $dbForConsole, Document $project, Messaging $queueForMessaging, Response $response) { $message = $dbForProject->getDocument('messages', $messageId); if ($message->isEmpty()) { @@ -3844,6 +3849,18 @@ App::patch('/v1/messaging/messages/push/:messageId') $pushData['badge'] = $badge; } + if (!\is_null($contentAvailable)) { + $pushData['contentAvailable'] = $contentAvailable; + } + + if (!\is_null($critical)) { + $pushData['critical'] = $critical; + } + + if (!\is_null($priority)) { + $pushData['priority'] = $priority; + } + if (!\is_null($image)) { [$bucketId, $fileId] = CompoundUID::parse($image); diff --git a/composer.lock b/composer.lock index b6e84656b6..8cddc64940 100644 --- a/composer.lock +++ b/composer.lock @@ -3882,12 +3882,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/messaging.git", - "reference": "2580b8357d2dde6ed567a52e5164cfe58fb9b6dd" + "reference": "02ccc85424eabb680b5a2f1458a471f19bac56c0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/messaging/zipball/2580b8357d2dde6ed567a52e5164cfe58fb9b6dd", - "reference": "2580b8357d2dde6ed567a52e5164cfe58fb9b6dd", + "url": "https://api.github.com/repos/utopia-php/messaging/zipball/02ccc85424eabb680b5a2f1458a471f19bac56c0", + "reference": "02ccc85424eabb680b5a2f1458a471f19bac56c0", "shasum": "" }, "require": { @@ -3925,7 +3925,7 @@ "issues": "https://github.com/utopia-php/messaging/issues", "source": "https://github.com/utopia-php/messaging/tree/feat-apns-content-available" }, - "time": "2024-12-03T04:09:05+00:00" + "time": "2024-12-03T09:44:33+00:00" }, { "name": "utopia-php/migration", diff --git a/src/Appwrite/Platform/Workers/Messaging.php b/src/Appwrite/Platform/Workers/Messaging.php index 3edb0c2aed..a5339c3764 100644 --- a/src/Appwrite/Platform/Workers/Messaging.php +++ b/src/Appwrite/Platform/Workers/Messaging.php @@ -32,6 +32,7 @@ use Utopia\Messaging\Messages\Email; use Utopia\Messaging\Messages\Email\Attachment; use Utopia\Messaging\Messages\Push; use Utopia\Messaging\Messages\SMS; +use Utopia\Messaging\Priority; use Utopia\Platform\Action; use Utopia\Queue\Message; use Utopia\Storage\Device; @@ -686,6 +687,11 @@ class Messaging extends Action $tag = $message['data']['tag'] ?? null; $badge = $message['data']['badge'] ?? null; $contentAvailable = $message['data']['contentAvailable'] ?? false; + $critical = $message['data']['critical'] ?? false; + + $priority = $message['data']['priority'] === 'normal' + ? Priority::NORMAL + : Priority::HIGH; return new Push( $to, @@ -699,7 +705,9 @@ class Messaging extends Action $color, $tag, $badge, - $contentAvailable + $contentAvailable, + $critical, + $priority ); } From 2934bdbd3ba7b223a90f5ca93d9711f69eba5832 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 4 Dec 2024 20:16:13 +1300 Subject: [PATCH 04/47] Update messaging --- composer.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.lock b/composer.lock index 8cddc64940..dadea47a55 100644 --- a/composer.lock +++ b/composer.lock @@ -3882,12 +3882,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/messaging.git", - "reference": "02ccc85424eabb680b5a2f1458a471f19bac56c0" + "reference": "4947ee3819a28aea303456a462051601e4d12ec9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/messaging/zipball/02ccc85424eabb680b5a2f1458a471f19bac56c0", - "reference": "02ccc85424eabb680b5a2f1458a471f19bac56c0", + "url": "https://api.github.com/repos/utopia-php/messaging/zipball/4947ee3819a28aea303456a462051601e4d12ec9", + "reference": "4947ee3819a28aea303456a462051601e4d12ec9", "shasum": "" }, "require": { @@ -3925,7 +3925,7 @@ "issues": "https://github.com/utopia-php/messaging/issues", "source": "https://github.com/utopia-php/messaging/tree/feat-apns-content-available" }, - "time": "2024-12-03T09:44:33+00:00" + "time": "2024-12-04T07:10:23+00:00" }, { "name": "utopia-php/migration", From f4917f7bc6a18e98d71a036bc68734855623cded Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 5 Dec 2024 17:04:11 +1300 Subject: [PATCH 05/47] Reorder params --- app/controllers/api/messaging.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/controllers/api/messaging.php b/app/controllers/api/messaging.php index 45eba6e434..394f836164 100644 --- a/app/controllers/api/messaging.php +++ b/app/controllers/api/messaging.php @@ -2906,12 +2906,12 @@ App::post('/v1/messaging/messages/push') ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_MESSAGE) ->param('messageId', '', new CustomId(), 'Message ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.') - ->param('title', '', new Text(256), 'Title for push notification.') - ->param('body', '', new Text(64230), 'Body for push notification.') + ->param('title', null, new Text(256), 'Title for push notification.', true) + ->param('body', null, new Text(64230), 'Body for push notification.', true) ->param('topics', [], new ArrayList(new UID()), 'List of Topic IDs.', true) ->param('users', [], new ArrayList(new UID()), 'List of User IDs.', true) ->param('targets', [], new ArrayList(new UID()), 'List of Targets IDs.', true) - ->param('data', null, new JSON(), 'Additional Data for push notification.', true) + ->param('data', null, new JSON(), 'Additional key-value pair data for push notification.', true) ->param('action', '', new Text(256), 'Action for push notification.', true) ->param('image', '', new CompoundUID(), 'Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as :.', true) ->param('icon', '', new Text(256), 'Icon for push notification. Available only for Android and Web Platform.', true) @@ -2919,18 +2919,18 @@ App::post('/v1/messaging/messages/push') ->param('color', '', new Text(256), 'Color for push notification. Available only for Android Platform.', true) ->param('tag', '', new Text(256), 'Tag for push notification. Available only for Android Platform.', true) ->param('badge', 0, new Integer(), 'Badge for push notification. Available only for iOS Platform.', true) + ->param('draft', false, new Boolean(), 'Is message a draft', true) + ->param('scheduledAt', null, new DatetimeValidator(requireDateInFuture: true), 'Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future.', true) ->param('contentAvailable', false, new Boolean(), 'If set to true, the notification will be delivered in the background. Available only for iOS Platform.', true) ->param('critical', false, new Boolean(), 'If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform.', true) ->param('priority', 'high', new WhiteList(['normal', 'high']), 'Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification.', true) - ->param('draft', false, new Boolean(), 'Is message a draft', true) - ->param('scheduledAt', null, new DatetimeValidator(requireDateInFuture: true), 'Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future.', true) ->inject('queueForEvents') ->inject('dbForProject') ->inject('dbForConsole') ->inject('project') ->inject('queueForMessaging') ->inject('response') - ->action(function (string $messageId, string $title, string $body, array $topics, array $users, array $targets, ?array $data, string $action, string $image, string $icon, string $sound, string $color, string $tag, string $badge, bool $contentAvailable, bool $critical, string $priority, bool $draft, ?string $scheduledAt, Event $queueForEvents, Database $dbForProject, Database $dbForConsole, Document $project, Messaging $queueForMessaging, Response $response) { + ->action(function (string $messageId, ?string $title, ?string $body, array $topics, array $users, array $targets, ?array $data, string $action, string $image, string $icon, string $sound, string $color, string $tag, string $badge, bool $draft, ?string $scheduledAt, bool $contentAvailable, bool $critical, string $priority, Event $queueForEvents, Database $dbForProject, Database $dbForConsole, Document $project, Messaging $queueForMessaging, Response $response) { $messageId = $messageId == 'unique()' ? ID::unique() : $messageId; @@ -3699,18 +3699,18 @@ App::patch('/v1/messaging/messages/push/:messageId') ->param('color', null, new Text(256), 'Color for push notification. Available only for Android platforms.', true) ->param('tag', null, new Text(256), 'Tag for push notification. Available only for Android platforms.', true) ->param('badge', null, new Integer(), 'Badge for push notification. Available only for iOS platforms.', true) + ->param('draft', null, new Boolean(), 'Is message a draft', true) + ->param('scheduledAt', null, new DatetimeValidator(requireDateInFuture: true), 'Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future.', true) ->param('contentAvailable', null, new Boolean(), 'If set to true, the notification will be delivered in the background. Available only for iOS Platform.', true) ->param('critical', null, new Boolean(), 'If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform.', true) ->param('priority', null, new WhiteList(['normal', 'high']), 'Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification.', true) - ->param('draft', null, new Boolean(), 'Is message a draft', true) - ->param('scheduledAt', null, new DatetimeValidator(requireDateInFuture: true), 'Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future.', true) ->inject('queueForEvents') ->inject('dbForProject') ->inject('dbForConsole') ->inject('project') ->inject('queueForMessaging') ->inject('response') - ->action(function (string $messageId, ?array $topics, ?array $users, ?array $targets, ?string $title, ?string $body, ?array $data, ?string $action, ?string $image, ?string $icon, ?string $sound, ?string $color, ?string $tag, ?int $badge, ?bool $contentAvailable, ?bool $critical, ?string $priority, ?bool $draft, ?string $scheduledAt, Event $queueForEvents, Database $dbForProject, Database $dbForConsole, Document $project, Messaging $queueForMessaging, Response $response) { + ->action(function (string $messageId, ?array $topics, ?array $users, ?array $targets, ?string $title, ?string $body, ?array $data, ?string $action, ?string $image, ?string $icon, ?string $sound, ?string $color, ?string $tag, ?int $badge, ?bool $draft, ?string $scheduledAt, ?bool $contentAvailable, ?bool $critical, ?string $priority, Event $queueForEvents, Database $dbForProject, Database $dbForConsole, Document $project, Messaging $queueForMessaging, Response $response) { $message = $dbForProject->getDocument('messages', $messageId); if ($message->isEmpty()) { From 98149f56b51e85a56746ca6ecaf808d525fc2359 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 5 Dec 2024 17:20:20 +1300 Subject: [PATCH 06/47] Default empty title and body --- app/controllers/api/messaging.php | 6 +++--- src/Appwrite/Platform/Workers/Messaging.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/api/messaging.php b/app/controllers/api/messaging.php index 394f836164..dea43add26 100644 --- a/app/controllers/api/messaging.php +++ b/app/controllers/api/messaging.php @@ -2906,8 +2906,8 @@ App::post('/v1/messaging/messages/push') ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_MESSAGE) ->param('messageId', '', new CustomId(), 'Message ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.') - ->param('title', null, new Text(256), 'Title for push notification.', true) - ->param('body', null, new Text(64230), 'Body for push notification.', true) + ->param('title', '', new Text(256), 'Title for push notification.', true) + ->param('body', '', new Text(64230), 'Body for push notification.', true) ->param('topics', [], new ArrayList(new UID()), 'List of Topic IDs.', true) ->param('users', [], new ArrayList(new UID()), 'List of User IDs.', true) ->param('targets', [], new ArrayList(new UID()), 'List of Targets IDs.', true) @@ -2930,7 +2930,7 @@ App::post('/v1/messaging/messages/push') ->inject('project') ->inject('queueForMessaging') ->inject('response') - ->action(function (string $messageId, ?string $title, ?string $body, array $topics, array $users, array $targets, ?array $data, string $action, string $image, string $icon, string $sound, string $color, string $tag, string $badge, bool $draft, ?string $scheduledAt, bool $contentAvailable, bool $critical, string $priority, Event $queueForEvents, Database $dbForProject, Database $dbForConsole, Document $project, Messaging $queueForMessaging, Response $response) { + ->action(function (string $messageId, string $title, string $body, array $topics, array $users, array $targets, ?array $data, string $action, string $image, string $icon, string $sound, string $color, string $tag, string $badge, bool $draft, ?string $scheduledAt, bool $contentAvailable, bool $critical, string $priority, Event $queueForEvents, Database $dbForProject, Database $dbForConsole, Document $project, Messaging $queueForMessaging, Response $response) { $messageId = $messageId == 'unique()' ? ID::unique() : $messageId; diff --git a/src/Appwrite/Platform/Workers/Messaging.php b/src/Appwrite/Platform/Workers/Messaging.php index a5339c3764..e3febc72d6 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']; - $body = $message['data']['body']; + $title = $message['data']['title'] === '' ? null : $message['data']['title']; + $body = $message['data']['body'] === '' ? null : $message['data']['body']; $data = $message['data']['data'] ?? null; $action = $message['data']['action'] ?? null; $image = $message['data']['image']['url'] ?? null; From 526f54cf06515b1eeff4aad5d6c73e284a277671 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 5 Dec 2024 21:09:52 +1300 Subject: [PATCH 07/47] Update src/Appwrite/Platform/Workers/Messaging.php Co-authored-by: Damodar Lohani --- src/Appwrite/Platform/Workers/Messaging.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Messaging.php b/src/Appwrite/Platform/Workers/Messaging.php index e3febc72d6..76e1ad3572 100644 --- a/src/Appwrite/Platform/Workers/Messaging.php +++ b/src/Appwrite/Platform/Workers/Messaging.php @@ -689,9 +689,9 @@ class Messaging extends Action $contentAvailable = $message['data']['contentAvailable'] ?? false; $critical = $message['data']['critical'] ?? false; - $priority = $message['data']['priority'] === 'normal' - ? Priority::NORMAL - : Priority::HIGH; + $priority = $message['data']['priority'] === 'high' + ? Priority::HIGH + : Priority::NORMAL; return new Push( $to, From 5b75fcc39814bfdd9b2e3f9d46ea28a953431663 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 5 Dec 2024 21:39:43 +1300 Subject: [PATCH 08/47] Update lock --- composer.json | 2 +- composer.lock | 27 +++++++++------------------ 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/composer.json b/composer.json index 7ecf079125..71fcb358f6 100644 --- a/composer.json +++ b/composer.json @@ -59,7 +59,7 @@ "utopia-php/image": "0.7.*", "utopia-php/locale": "0.4.*", "utopia-php/logger": "0.6.*", - "utopia-php/messaging": "dev-feat-apns-content-available as 0.12.2", + "utopia-php/messaging": "0.13.*", "utopia-php/migration": "0.6.*", "utopia-php/orchestration": "0.9.*", "utopia-php/platform": "0.7.*", diff --git a/composer.lock b/composer.lock index dadea47a55..5d84cfb223 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "04b9739820be8136d62de48c6325e763", + "content-hash": "d54809ddf7cd4b318f4606b56827037e", "packages": [ { "name": "adhocore/jwt", @@ -3878,16 +3878,16 @@ }, { "name": "utopia-php/messaging", - "version": "dev-feat-apns-content-available", + "version": "0.13.0", "source": { "type": "git", "url": "https://github.com/utopia-php/messaging.git", - "reference": "4947ee3819a28aea303456a462051601e4d12ec9" + "reference": "0e3e57351fe4fe875ef3ab9a01a7fff5f022de90" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/messaging/zipball/4947ee3819a28aea303456a462051601e4d12ec9", - "reference": "4947ee3819a28aea303456a462051601e4d12ec9", + "url": "https://api.github.com/repos/utopia-php/messaging/zipball/0e3e57351fe4fe875ef3ab9a01a7fff5f022de90", + "reference": "0e3e57351fe4fe875ef3ab9a01a7fff5f022de90", "shasum": "" }, "require": { @@ -3923,9 +3923,9 @@ ], "support": { "issues": "https://github.com/utopia-php/messaging/issues", - "source": "https://github.com/utopia-php/messaging/tree/feat-apns-content-available" + "source": "https://github.com/utopia-php/messaging/tree/0.13.0" }, - "time": "2024-12-04T07:10:23+00:00" + "time": "2024-12-05T08:36:07+00:00" }, { "name": "utopia-php/migration", @@ -8556,18 +8556,9 @@ "time": "2024-03-07T20:33:40+00:00" } ], - "aliases": [ - { - "package": "utopia-php/messaging", - "version": "dev-feat-apns-content-available", - "alias": "0.12.2", - "alias_normalized": "0.12.2.0" - } - ], + "aliases": [], "minimum-stability": "stable", - "stability-flags": { - "utopia-php/messaging": 20 - }, + "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, "platform": { From 45f6d9c0b9c18058b7204dd19d7f6626054ba08c Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 5 Dec 2024 23:12:06 +1300 Subject: [PATCH 09/47] Specs --- app/config/specs/open-api3-latest-client.json | 2 +- .../specs/open-api3-latest-console.json | 66 +++++++++++++--- app/config/specs/open-api3-latest-server.json | 66 +++++++++++++--- app/config/specs/swagger2-latest-client.json | 2 +- app/config/specs/swagger2-latest-console.json | 78 +++++++++++++++---- app/config/specs/swagger2-latest-server.json | 78 +++++++++++++++---- 6 files changed, 236 insertions(+), 56 deletions(-) diff --git a/app/config/specs/open-api3-latest-client.json b/app/config/specs/open-api3-latest-client.json index d948a101f2..1013698073 100644 --- a/app/config/specs/open-api3-latest-client.json +++ b/app/config/specs/open-api3-latest-client.json @@ -1,7 +1,7 @@ { "openapi": "3.0.0", "info": { - "version": "1.6.0", + "version": "1.6.1", "title": "Appwrite", "description": "Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https:\/\/appwrite.io\/docs](https:\/\/appwrite.io\/docs)", "termsOfService": "https:\/\/appwrite.io\/policy\/terms", diff --git a/app/config/specs/open-api3-latest-console.json b/app/config/specs/open-api3-latest-console.json index fb01509ecd..32985d9c58 100644 --- a/app/config/specs/open-api3-latest-console.json +++ b/app/config/specs/open-api3-latest-console.json @@ -1,7 +1,7 @@ { "openapi": "3.0.0", "info": { - "version": "1.6.0", + "version": "1.6.1", "title": "Appwrite", "description": "Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https:\/\/appwrite.io\/docs](https:\/\/appwrite.io\/docs)", "termsOfService": "https:\/\/appwrite.io\/policy\/terms", @@ -9488,7 +9488,8 @@ "bun-1.0", "bun-1.1", "go-1.23", - "static-1" + "static-1", + "flutter-3.24" ], "x-enum-name": null, "x-enum-keys": [] @@ -10145,7 +10146,8 @@ "bun-1.0", "bun-1.1", "go-1.23", - "static-1" + "static-1", + "flutter-3.24" ], "x-enum-name": null, "x-enum-keys": [] @@ -14120,7 +14122,7 @@ }, "data": { "type": "object", - "description": "Additional Data for push notification.", + "description": "Additional key-value pair data for push notification.", "x-example": "{}" }, "action": { @@ -14140,7 +14142,7 @@ }, "sound": { "type": "string", - "description": "Sound for push notification. Available only for Android and IOS Platform.", + "description": "Sound for push notification. Available only for Android and iOS Platform.", "x-example": "" }, "color": { @@ -14154,9 +14156,9 @@ "x-example": "" }, "badge": { - "type": "string", - "description": "Badge for push notification. Available only for IOS Platform.", - "x-example": "" + "type": "integer", + "description": "Badge for push notification. Available only for iOS Platform.", + "x-example": null }, "draft": { "type": "boolean", @@ -14167,12 +14169,31 @@ "type": "string", "description": "Scheduled delivery time for message in [ISO 8601](https:\/\/www.iso.org\/iso-8601-date-and-time-format.html) format. DateTime value must be in future.", "x-example": null + }, + "contentAvailable": { + "type": "boolean", + "description": "If set to true, the notification will be delivered in the background. Available only for iOS Platform.", + "x-example": false + }, + "critical": { + "type": "boolean", + "description": "If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform.", + "x-example": false + }, + "priority": { + "type": "string", + "description": "Set the notification priority. \"normal\" will consider device battery state and may send notifications later. \"high\" will always attempt to immediately deliver the notification.", + "x-example": "normal", + "enum": [ + "normal", + "high" + ], + "x-enum-name": null, + "x-enum-keys": [] } }, "required": [ - "messageId", - "title", - "body" + "messageId" ] } } @@ -14331,6 +14352,27 @@ "type": "string", "description": "Scheduled delivery time for message in [ISO 8601](https:\/\/www.iso.org\/iso-8601-date-and-time-format.html) format. DateTime value must be in future.", "x-example": null + }, + "contentAvailable": { + "type": "boolean", + "description": "If set to true, the notification will be delivered in the background. Available only for iOS Platform.", + "x-example": false + }, + "critical": { + "type": "boolean", + "description": "If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform.", + "x-example": false + }, + "priority": { + "type": "string", + "description": "Set the notification priority. \"normal\" will consider device battery state and may send notifications later. \"high\" will always attempt to immediately deliver the notification.", + "x-example": "normal", + "enum": [ + "normal", + "high" + ], + "x-enum-name": null, + "x-enum-keys": [] } } } @@ -35109,7 +35151,7 @@ }, "schedule": { "type": "string", - "description": "Function execution schedult in CRON format.", + "description": "Function execution schedule in CRON format.", "x-example": "5 4 * * *" }, "timeout": { diff --git a/app/config/specs/open-api3-latest-server.json b/app/config/specs/open-api3-latest-server.json index 1504322456..12d1337c5e 100644 --- a/app/config/specs/open-api3-latest-server.json +++ b/app/config/specs/open-api3-latest-server.json @@ -1,7 +1,7 @@ { "openapi": "3.0.0", "info": { - "version": "1.6.0", + "version": "1.6.1", "title": "Appwrite", "description": "Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https:\/\/appwrite.io\/docs](https:\/\/appwrite.io\/docs)", "termsOfService": "https:\/\/appwrite.io\/policy\/terms", @@ -8596,7 +8596,8 @@ "bun-1.0", "bun-1.1", "go-1.23", - "static-1" + "static-1", + "flutter-3.24" ], "x-enum-name": null, "x-enum-keys": [] @@ -9019,7 +9020,8 @@ "bun-1.0", "bun-1.1", "go-1.23", - "static-1" + "static-1", + "flutter-3.24" ], "x-enum-name": null, "x-enum-keys": [] @@ -12978,7 +12980,7 @@ }, "data": { "type": "object", - "description": "Additional Data for push notification.", + "description": "Additional key-value pair data for push notification.", "x-example": "{}" }, "action": { @@ -12998,7 +13000,7 @@ }, "sound": { "type": "string", - "description": "Sound for push notification. Available only for Android and IOS Platform.", + "description": "Sound for push notification. Available only for Android and iOS Platform.", "x-example": "" }, "color": { @@ -13012,9 +13014,9 @@ "x-example": "" }, "badge": { - "type": "string", - "description": "Badge for push notification. Available only for IOS Platform.", - "x-example": "" + "type": "integer", + "description": "Badge for push notification. Available only for iOS Platform.", + "x-example": null }, "draft": { "type": "boolean", @@ -13025,12 +13027,31 @@ "type": "string", "description": "Scheduled delivery time for message in [ISO 8601](https:\/\/www.iso.org\/iso-8601-date-and-time-format.html) format. DateTime value must be in future.", "x-example": null + }, + "contentAvailable": { + "type": "boolean", + "description": "If set to true, the notification will be delivered in the background. Available only for iOS Platform.", + "x-example": false + }, + "critical": { + "type": "boolean", + "description": "If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform.", + "x-example": false + }, + "priority": { + "type": "string", + "description": "Set the notification priority. \"normal\" will consider device battery state and may send notifications later. \"high\" will always attempt to immediately deliver the notification.", + "x-example": "normal", + "enum": [ + "normal", + "high" + ], + "x-enum-name": null, + "x-enum-keys": [] } }, "required": [ - "messageId", - "title", - "body" + "messageId" ] } } @@ -13190,6 +13211,27 @@ "type": "string", "description": "Scheduled delivery time for message in [ISO 8601](https:\/\/www.iso.org\/iso-8601-date-and-time-format.html) format. DateTime value must be in future.", "x-example": null + }, + "contentAvailable": { + "type": "boolean", + "description": "If set to true, the notification will be delivered in the background. Available only for iOS Platform.", + "x-example": false + }, + "critical": { + "type": "boolean", + "description": "If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform.", + "x-example": false + }, + "priority": { + "type": "string", + "description": "Set the notification priority. \"normal\" will consider device battery state and may send notifications later. \"high\" will always attempt to immediately deliver the notification.", + "x-example": "normal", + "enum": [ + "normal", + "high" + ], + "x-enum-name": null, + "x-enum-keys": [] } } } @@ -25746,7 +25788,7 @@ }, "schedule": { "type": "string", - "description": "Function execution schedult in CRON format.", + "description": "Function execution schedule in CRON format.", "x-example": "5 4 * * *" }, "timeout": { diff --git a/app/config/specs/swagger2-latest-client.json b/app/config/specs/swagger2-latest-client.json index 3ac70ffe28..4b6366f2bf 100644 --- a/app/config/specs/swagger2-latest-client.json +++ b/app/config/specs/swagger2-latest-client.json @@ -1,7 +1,7 @@ { "swagger": "2.0", "info": { - "version": "1.6.0", + "version": "1.6.1", "title": "Appwrite", "description": "Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https:\/\/appwrite.io\/docs](https:\/\/appwrite.io\/docs)", "termsOfService": "https:\/\/appwrite.io\/policy\/terms", diff --git a/app/config/specs/swagger2-latest-console.json b/app/config/specs/swagger2-latest-console.json index 25c0c289b3..a51fc316cb 100644 --- a/app/config/specs/swagger2-latest-console.json +++ b/app/config/specs/swagger2-latest-console.json @@ -1,7 +1,7 @@ { "swagger": "2.0", "info": { - "version": "1.6.0", + "version": "1.6.1", "title": "Appwrite", "description": "Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https:\/\/appwrite.io\/docs](https:\/\/appwrite.io\/docs)", "termsOfService": "https:\/\/appwrite.io\/policy\/terms", @@ -9610,7 +9610,8 @@ "bun-1.0", "bun-1.1", "go-1.23", - "static-1" + "static-1", + "flutter-3.24" ], "x-enum-name": null, "x-enum-keys": [] @@ -10286,7 +10287,8 @@ "bun-1.0", "bun-1.1", "go-1.23", - "static-1" + "static-1", + "flutter-3.24" ], "x-enum-name": null, "x-enum-keys": [] @@ -14328,13 +14330,13 @@ "title": { "type": "string", "description": "Title for push notification.", - "default": null, + "default": "", "x-example": "" }, "body": { "type": "string", "description": "Body for push notification.", - "default": null, + "default": "", "x-example": "<BODY>" }, "topics": { @@ -14366,7 +14368,7 @@ }, "data": { "type": "object", - "description": "Additional Data for push notification.", + "description": "Additional key-value pair data for push notification.", "default": {}, "x-example": "{}" }, @@ -14390,7 +14392,7 @@ }, "sound": { "type": "string", - "description": "Sound for push notification. Available only for Android and IOS Platform.", + "description": "Sound for push notification. Available only for Android and iOS Platform.", "default": "", "x-example": "<SOUND>" }, @@ -14407,10 +14409,10 @@ "x-example": "<TAG>" }, "badge": { - "type": "string", - "description": "Badge for push notification. Available only for IOS Platform.", - "default": "", - "x-example": "<BADGE>" + "type": "integer", + "description": "Badge for push notification. Available only for iOS Platform.", + "default": 0, + "x-example": null }, "draft": { "type": "boolean", @@ -14423,12 +14425,34 @@ "description": "Scheduled delivery time for message in [ISO 8601](https:\/\/www.iso.org\/iso-8601-date-and-time-format.html) format. DateTime value must be in future.", "default": null, "x-example": null + }, + "contentAvailable": { + "type": "boolean", + "description": "If set to true, the notification will be delivered in the background. Available only for iOS Platform.", + "default": false, + "x-example": false + }, + "critical": { + "type": "boolean", + "description": "If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform.", + "default": false, + "x-example": false + }, + "priority": { + "type": "string", + "description": "Set the notification priority. \"normal\" will consider device battery state and may send notifications later. \"high\" will always attempt to immediately deliver the notification.", + "default": "high", + "x-example": "normal", + "enum": [ + "normal", + "high" + ], + "x-enum-name": null, + "x-enum-keys": [] } }, "required": [ - "messageId", - "title", - "body" + "messageId" ] } } @@ -14600,6 +14624,30 @@ "description": "Scheduled delivery time for message in [ISO 8601](https:\/\/www.iso.org\/iso-8601-date-and-time-format.html) format. DateTime value must be in future.", "default": null, "x-example": null + }, + "contentAvailable": { + "type": "boolean", + "description": "If set to true, the notification will be delivered in the background. Available only for iOS Platform.", + "default": null, + "x-example": false + }, + "critical": { + "type": "boolean", + "description": "If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform.", + "default": null, + "x-example": false + }, + "priority": { + "type": "string", + "description": "Set the notification priority. \"normal\" will consider device battery state and may send notifications later. \"high\" will always attempt to immediately deliver the notification.", + "default": null, + "x-example": "normal", + "enum": [ + "normal", + "high" + ], + "x-enum-name": null, + "x-enum-keys": [] } } } @@ -35618,7 +35666,7 @@ }, "schedule": { "type": "string", - "description": "Function execution schedult in CRON format.", + "description": "Function execution schedule in CRON format.", "x-example": "5 4 * * *" }, "timeout": { diff --git a/app/config/specs/swagger2-latest-server.json b/app/config/specs/swagger2-latest-server.json index 68bcf268fb..5a06a27a63 100644 --- a/app/config/specs/swagger2-latest-server.json +++ b/app/config/specs/swagger2-latest-server.json @@ -1,7 +1,7 @@ { "swagger": "2.0", "info": { - "version": "1.6.0", + "version": "1.6.1", "title": "Appwrite", "description": "Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https:\/\/appwrite.io\/docs](https:\/\/appwrite.io\/docs)", "termsOfService": "https:\/\/appwrite.io\/policy\/terms", @@ -8720,7 +8720,8 @@ "bun-1.0", "bun-1.1", "go-1.23", - "static-1" + "static-1", + "flutter-3.24" ], "x-enum-name": null, "x-enum-keys": [] @@ -9166,7 +9167,8 @@ "bun-1.0", "bun-1.1", "go-1.23", - "static-1" + "static-1", + "flutter-3.24" ], "x-enum-name": null, "x-enum-keys": [] @@ -13194,13 +13196,13 @@ "title": { "type": "string", "description": "Title for push notification.", - "default": null, + "default": "", "x-example": "<TITLE>" }, "body": { "type": "string", "description": "Body for push notification.", - "default": null, + "default": "", "x-example": "<BODY>" }, "topics": { @@ -13232,7 +13234,7 @@ }, "data": { "type": "object", - "description": "Additional Data for push notification.", + "description": "Additional key-value pair data for push notification.", "default": {}, "x-example": "{}" }, @@ -13256,7 +13258,7 @@ }, "sound": { "type": "string", - "description": "Sound for push notification. Available only for Android and IOS Platform.", + "description": "Sound for push notification. Available only for Android and iOS Platform.", "default": "", "x-example": "<SOUND>" }, @@ -13273,10 +13275,10 @@ "x-example": "<TAG>" }, "badge": { - "type": "string", - "description": "Badge for push notification. Available only for IOS Platform.", - "default": "", - "x-example": "<BADGE>" + "type": "integer", + "description": "Badge for push notification. Available only for iOS Platform.", + "default": 0, + "x-example": null }, "draft": { "type": "boolean", @@ -13289,12 +13291,34 @@ "description": "Scheduled delivery time for message in [ISO 8601](https:\/\/www.iso.org\/iso-8601-date-and-time-format.html) format. DateTime value must be in future.", "default": null, "x-example": null + }, + "contentAvailable": { + "type": "boolean", + "description": "If set to true, the notification will be delivered in the background. Available only for iOS Platform.", + "default": false, + "x-example": false + }, + "critical": { + "type": "boolean", + "description": "If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform.", + "default": false, + "x-example": false + }, + "priority": { + "type": "string", + "description": "Set the notification priority. \"normal\" will consider device battery state and may send notifications later. \"high\" will always attempt to immediately deliver the notification.", + "default": "high", + "x-example": "normal", + "enum": [ + "normal", + "high" + ], + "x-enum-name": null, + "x-enum-keys": [] } }, "required": [ - "messageId", - "title", - "body" + "messageId" ] } } @@ -13467,6 +13491,30 @@ "description": "Scheduled delivery time for message in [ISO 8601](https:\/\/www.iso.org\/iso-8601-date-and-time-format.html) format. DateTime value must be in future.", "default": null, "x-example": null + }, + "contentAvailable": { + "type": "boolean", + "description": "If set to true, the notification will be delivered in the background. Available only for iOS Platform.", + "default": null, + "x-example": false + }, + "critical": { + "type": "boolean", + "description": "If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform.", + "default": null, + "x-example": false + }, + "priority": { + "type": "string", + "description": "Set the notification priority. \"normal\" will consider device battery state and may send notifications later. \"high\" will always attempt to immediately deliver the notification.", + "default": null, + "x-example": "normal", + "enum": [ + "normal", + "high" + ], + "x-enum-name": null, + "x-enum-keys": [] } } } @@ -26233,7 +26281,7 @@ }, "schedule": { "type": "string", - "description": "Function execution schedult in CRON format.", + "description": "Function execution schedule in CRON format.", "x-example": "5 4 * * *" }, "timeout": { From 44d3a4f22349a8fdc8958abcbe2d2bc0b8651a37 Mon Sep 17 00:00:00 2001 From: Jake Barnby <jakeb994@gmail.com> Date: Mon, 9 Dec 2024 15:42:20 +1300 Subject: [PATCH 10/47] Update specs --- app/config/specs/open-api3-1.6.x-client.json | 4 +- app/config/specs/open-api3-1.6.x-console.json | 68 +++++++++++++--- app/config/specs/open-api3-1.6.x-server.json | 68 +++++++++++++--- app/config/specs/swagger2-1.6.x-client.json | 4 +- app/config/specs/swagger2-1.6.x-console.json | 80 +++++++++++++++---- app/config/specs/swagger2-1.6.x-server.json | 80 +++++++++++++++---- src/Appwrite/Platform/Workers/Messaging.php | 9 +-- 7 files changed, 246 insertions(+), 67 deletions(-) diff --git a/app/config/specs/open-api3-1.6.x-client.json b/app/config/specs/open-api3-1.6.x-client.json index e3cd909b4e..1013698073 100644 --- a/app/config/specs/open-api3-1.6.x-client.json +++ b/app/config/specs/open-api3-1.6.x-client.json @@ -1,7 +1,7 @@ { "openapi": "3.0.0", "info": { - "version": "1.6.0", + "version": "1.6.1", "title": "Appwrite", "description": "Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https:\/\/appwrite.io\/docs](https:\/\/appwrite.io\/docs)", "termsOfService": "https:\/\/appwrite.io\/policy\/terms", @@ -2784,7 +2784,7 @@ "tags": [ "account" ], - "description": "Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST \/v1\/account\/sessions\/token](https:\/\/appwrite.io\/docs\/references\/cloud\/client-web\/account#createSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. If you are on a mobile device you can leave the URL parameter empty, so that the login completion will be handled by your Appwrite instance by default.\n\nA user is limited to 10 active sessions at a time by default. [Learn more about session limits](https:\/\/appwrite.io\/docs\/authentication-security#limits).\n", + "description": "Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST \/v1\/account\/sessions\/token](https:\/\/appwrite.io\/docs\/references\/cloud\/client-web\/account#createSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour.\n\nA user is limited to 10 active sessions at a time by default. [Learn more about session limits](https:\/\/appwrite.io\/docs\/authentication-security#limits).\n", "responses": { "201": { "description": "Token", diff --git a/app/config/specs/open-api3-1.6.x-console.json b/app/config/specs/open-api3-1.6.x-console.json index 369fea741a..32985d9c58 100644 --- a/app/config/specs/open-api3-1.6.x-console.json +++ b/app/config/specs/open-api3-1.6.x-console.json @@ -1,7 +1,7 @@ { "openapi": "3.0.0", "info": { - "version": "1.6.0", + "version": "1.6.1", "title": "Appwrite", "description": "Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https:\/\/appwrite.io\/docs](https:\/\/appwrite.io\/docs)", "termsOfService": "https:\/\/appwrite.io\/policy\/terms", @@ -2795,7 +2795,7 @@ "tags": [ "account" ], - "description": "Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST \/v1\/account\/sessions\/token](https:\/\/appwrite.io\/docs\/references\/cloud\/client-web\/account#createSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. If you are on a mobile device you can leave the URL parameter empty, so that the login completion will be handled by your Appwrite instance by default.\n\nA user is limited to 10 active sessions at a time by default. [Learn more about session limits](https:\/\/appwrite.io\/docs\/authentication-security#limits).\n", + "description": "Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST \/v1\/account\/sessions\/token](https:\/\/appwrite.io\/docs\/references\/cloud\/client-web\/account#createSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour.\n\nA user is limited to 10 active sessions at a time by default. [Learn more about session limits](https:\/\/appwrite.io\/docs\/authentication-security#limits).\n", "responses": { "201": { "description": "Token", @@ -9488,7 +9488,8 @@ "bun-1.0", "bun-1.1", "go-1.23", - "static-1" + "static-1", + "flutter-3.24" ], "x-enum-name": null, "x-enum-keys": [] @@ -10145,7 +10146,8 @@ "bun-1.0", "bun-1.1", "go-1.23", - "static-1" + "static-1", + "flutter-3.24" ], "x-enum-name": null, "x-enum-keys": [] @@ -14120,7 +14122,7 @@ }, "data": { "type": "object", - "description": "Additional Data for push notification.", + "description": "Additional key-value pair data for push notification.", "x-example": "{}" }, "action": { @@ -14140,7 +14142,7 @@ }, "sound": { "type": "string", - "description": "Sound for push notification. Available only for Android and IOS Platform.", + "description": "Sound for push notification. Available only for Android and iOS Platform.", "x-example": "<SOUND>" }, "color": { @@ -14154,9 +14156,9 @@ "x-example": "<TAG>" }, "badge": { - "type": "string", - "description": "Badge for push notification. Available only for IOS Platform.", - "x-example": "<BADGE>" + "type": "integer", + "description": "Badge for push notification. Available only for iOS Platform.", + "x-example": null }, "draft": { "type": "boolean", @@ -14167,12 +14169,31 @@ "type": "string", "description": "Scheduled delivery time for message in [ISO 8601](https:\/\/www.iso.org\/iso-8601-date-and-time-format.html) format. DateTime value must be in future.", "x-example": null + }, + "contentAvailable": { + "type": "boolean", + "description": "If set to true, the notification will be delivered in the background. Available only for iOS Platform.", + "x-example": false + }, + "critical": { + "type": "boolean", + "description": "If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform.", + "x-example": false + }, + "priority": { + "type": "string", + "description": "Set the notification priority. \"normal\" will consider device battery state and may send notifications later. \"high\" will always attempt to immediately deliver the notification.", + "x-example": "normal", + "enum": [ + "normal", + "high" + ], + "x-enum-name": null, + "x-enum-keys": [] } }, "required": [ - "messageId", - "title", - "body" + "messageId" ] } } @@ -14331,6 +14352,27 @@ "type": "string", "description": "Scheduled delivery time for message in [ISO 8601](https:\/\/www.iso.org\/iso-8601-date-and-time-format.html) format. DateTime value must be in future.", "x-example": null + }, + "contentAvailable": { + "type": "boolean", + "description": "If set to true, the notification will be delivered in the background. Available only for iOS Platform.", + "x-example": false + }, + "critical": { + "type": "boolean", + "description": "If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform.", + "x-example": false + }, + "priority": { + "type": "string", + "description": "Set the notification priority. \"normal\" will consider device battery state and may send notifications later. \"high\" will always attempt to immediately deliver the notification.", + "x-example": "normal", + "enum": [ + "normal", + "high" + ], + "x-enum-name": null, + "x-enum-keys": [] } } } @@ -35109,7 +35151,7 @@ }, "schedule": { "type": "string", - "description": "Function execution schedult in CRON format.", + "description": "Function execution schedule in CRON format.", "x-example": "5 4 * * *" }, "timeout": { diff --git a/app/config/specs/open-api3-1.6.x-server.json b/app/config/specs/open-api3-1.6.x-server.json index e84b751743..12d1337c5e 100644 --- a/app/config/specs/open-api3-1.6.x-server.json +++ b/app/config/specs/open-api3-1.6.x-server.json @@ -1,7 +1,7 @@ { "openapi": "3.0.0", "info": { - "version": "1.6.0", + "version": "1.6.1", "title": "Appwrite", "description": "Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https:\/\/appwrite.io\/docs](https:\/\/appwrite.io\/docs)", "termsOfService": "https:\/\/appwrite.io\/policy\/terms", @@ -2451,7 +2451,7 @@ "tags": [ "account" ], - "description": "Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST \/v1\/account\/sessions\/token](https:\/\/appwrite.io\/docs\/references\/cloud\/client-web\/account#createSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. If you are on a mobile device you can leave the URL parameter empty, so that the login completion will be handled by your Appwrite instance by default.\n\nA user is limited to 10 active sessions at a time by default. [Learn more about session limits](https:\/\/appwrite.io\/docs\/authentication-security#limits).\n", + "description": "Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST \/v1\/account\/sessions\/token](https:\/\/appwrite.io\/docs\/references\/cloud\/client-web\/account#createSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour.\n\nA user is limited to 10 active sessions at a time by default. [Learn more about session limits](https:\/\/appwrite.io\/docs\/authentication-security#limits).\n", "responses": { "201": { "description": "Token", @@ -8596,7 +8596,8 @@ "bun-1.0", "bun-1.1", "go-1.23", - "static-1" + "static-1", + "flutter-3.24" ], "x-enum-name": null, "x-enum-keys": [] @@ -9019,7 +9020,8 @@ "bun-1.0", "bun-1.1", "go-1.23", - "static-1" + "static-1", + "flutter-3.24" ], "x-enum-name": null, "x-enum-keys": [] @@ -12978,7 +12980,7 @@ }, "data": { "type": "object", - "description": "Additional Data for push notification.", + "description": "Additional key-value pair data for push notification.", "x-example": "{}" }, "action": { @@ -12998,7 +13000,7 @@ }, "sound": { "type": "string", - "description": "Sound for push notification. Available only for Android and IOS Platform.", + "description": "Sound for push notification. Available only for Android and iOS Platform.", "x-example": "<SOUND>" }, "color": { @@ -13012,9 +13014,9 @@ "x-example": "<TAG>" }, "badge": { - "type": "string", - "description": "Badge for push notification. Available only for IOS Platform.", - "x-example": "<BADGE>" + "type": "integer", + "description": "Badge for push notification. Available only for iOS Platform.", + "x-example": null }, "draft": { "type": "boolean", @@ -13025,12 +13027,31 @@ "type": "string", "description": "Scheduled delivery time for message in [ISO 8601](https:\/\/www.iso.org\/iso-8601-date-and-time-format.html) format. DateTime value must be in future.", "x-example": null + }, + "contentAvailable": { + "type": "boolean", + "description": "If set to true, the notification will be delivered in the background. Available only for iOS Platform.", + "x-example": false + }, + "critical": { + "type": "boolean", + "description": "If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform.", + "x-example": false + }, + "priority": { + "type": "string", + "description": "Set the notification priority. \"normal\" will consider device battery state and may send notifications later. \"high\" will always attempt to immediately deliver the notification.", + "x-example": "normal", + "enum": [ + "normal", + "high" + ], + "x-enum-name": null, + "x-enum-keys": [] } }, "required": [ - "messageId", - "title", - "body" + "messageId" ] } } @@ -13190,6 +13211,27 @@ "type": "string", "description": "Scheduled delivery time for message in [ISO 8601](https:\/\/www.iso.org\/iso-8601-date-and-time-format.html) format. DateTime value must be in future.", "x-example": null + }, + "contentAvailable": { + "type": "boolean", + "description": "If set to true, the notification will be delivered in the background. Available only for iOS Platform.", + "x-example": false + }, + "critical": { + "type": "boolean", + "description": "If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform.", + "x-example": false + }, + "priority": { + "type": "string", + "description": "Set the notification priority. \"normal\" will consider device battery state and may send notifications later. \"high\" will always attempt to immediately deliver the notification.", + "x-example": "normal", + "enum": [ + "normal", + "high" + ], + "x-enum-name": null, + "x-enum-keys": [] } } } @@ -25746,7 +25788,7 @@ }, "schedule": { "type": "string", - "description": "Function execution schedult in CRON format.", + "description": "Function execution schedule in CRON format.", "x-example": "5 4 * * *" }, "timeout": { diff --git a/app/config/specs/swagger2-1.6.x-client.json b/app/config/specs/swagger2-1.6.x-client.json index b1b9ce8dca..4b6366f2bf 100644 --- a/app/config/specs/swagger2-1.6.x-client.json +++ b/app/config/specs/swagger2-1.6.x-client.json @@ -1,7 +1,7 @@ { "swagger": "2.0", "info": { - "version": "1.6.0", + "version": "1.6.1", "title": "Appwrite", "description": "Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https:\/\/appwrite.io\/docs](https:\/\/appwrite.io\/docs)", "termsOfService": "https:\/\/appwrite.io\/policy\/terms", @@ -2922,7 +2922,7 @@ "tags": [ "account" ], - "description": "Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST \/v1\/account\/sessions\/token](https:\/\/appwrite.io\/docs\/references\/cloud\/client-web\/account#createSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. If you are on a mobile device you can leave the URL parameter empty, so that the login completion will be handled by your Appwrite instance by default.\n\nA user is limited to 10 active sessions at a time by default. [Learn more about session limits](https:\/\/appwrite.io\/docs\/authentication-security#limits).\n", + "description": "Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST \/v1\/account\/sessions\/token](https:\/\/appwrite.io\/docs\/references\/cloud\/client-web\/account#createSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour.\n\nA user is limited to 10 active sessions at a time by default. [Learn more about session limits](https:\/\/appwrite.io\/docs\/authentication-security#limits).\n", "responses": { "201": { "description": "Token", diff --git a/app/config/specs/swagger2-1.6.x-console.json b/app/config/specs/swagger2-1.6.x-console.json index 9ce9d5f60d..a51fc316cb 100644 --- a/app/config/specs/swagger2-1.6.x-console.json +++ b/app/config/specs/swagger2-1.6.x-console.json @@ -1,7 +1,7 @@ { "swagger": "2.0", "info": { - "version": "1.6.0", + "version": "1.6.1", "title": "Appwrite", "description": "Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https:\/\/appwrite.io\/docs](https:\/\/appwrite.io\/docs)", "termsOfService": "https:\/\/appwrite.io\/policy\/terms", @@ -2949,7 +2949,7 @@ "tags": [ "account" ], - "description": "Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST \/v1\/account\/sessions\/token](https:\/\/appwrite.io\/docs\/references\/cloud\/client-web\/account#createSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. If you are on a mobile device you can leave the URL parameter empty, so that the login completion will be handled by your Appwrite instance by default.\n\nA user is limited to 10 active sessions at a time by default. [Learn more about session limits](https:\/\/appwrite.io\/docs\/authentication-security#limits).\n", + "description": "Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST \/v1\/account\/sessions\/token](https:\/\/appwrite.io\/docs\/references\/cloud\/client-web\/account#createSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour.\n\nA user is limited to 10 active sessions at a time by default. [Learn more about session limits](https:\/\/appwrite.io\/docs\/authentication-security#limits).\n", "responses": { "201": { "description": "Token", @@ -9610,7 +9610,8 @@ "bun-1.0", "bun-1.1", "go-1.23", - "static-1" + "static-1", + "flutter-3.24" ], "x-enum-name": null, "x-enum-keys": [] @@ -10286,7 +10287,8 @@ "bun-1.0", "bun-1.1", "go-1.23", - "static-1" + "static-1", + "flutter-3.24" ], "x-enum-name": null, "x-enum-keys": [] @@ -14328,13 +14330,13 @@ "title": { "type": "string", "description": "Title for push notification.", - "default": null, + "default": "", "x-example": "<TITLE>" }, "body": { "type": "string", "description": "Body for push notification.", - "default": null, + "default": "", "x-example": "<BODY>" }, "topics": { @@ -14366,7 +14368,7 @@ }, "data": { "type": "object", - "description": "Additional Data for push notification.", + "description": "Additional key-value pair data for push notification.", "default": {}, "x-example": "{}" }, @@ -14390,7 +14392,7 @@ }, "sound": { "type": "string", - "description": "Sound for push notification. Available only for Android and IOS Platform.", + "description": "Sound for push notification. Available only for Android and iOS Platform.", "default": "", "x-example": "<SOUND>" }, @@ -14407,10 +14409,10 @@ "x-example": "<TAG>" }, "badge": { - "type": "string", - "description": "Badge for push notification. Available only for IOS Platform.", - "default": "", - "x-example": "<BADGE>" + "type": "integer", + "description": "Badge for push notification. Available only for iOS Platform.", + "default": 0, + "x-example": null }, "draft": { "type": "boolean", @@ -14423,12 +14425,34 @@ "description": "Scheduled delivery time for message in [ISO 8601](https:\/\/www.iso.org\/iso-8601-date-and-time-format.html) format. DateTime value must be in future.", "default": null, "x-example": null + }, + "contentAvailable": { + "type": "boolean", + "description": "If set to true, the notification will be delivered in the background. Available only for iOS Platform.", + "default": false, + "x-example": false + }, + "critical": { + "type": "boolean", + "description": "If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform.", + "default": false, + "x-example": false + }, + "priority": { + "type": "string", + "description": "Set the notification priority. \"normal\" will consider device battery state and may send notifications later. \"high\" will always attempt to immediately deliver the notification.", + "default": "high", + "x-example": "normal", + "enum": [ + "normal", + "high" + ], + "x-enum-name": null, + "x-enum-keys": [] } }, "required": [ - "messageId", - "title", - "body" + "messageId" ] } } @@ -14600,6 +14624,30 @@ "description": "Scheduled delivery time for message in [ISO 8601](https:\/\/www.iso.org\/iso-8601-date-and-time-format.html) format. DateTime value must be in future.", "default": null, "x-example": null + }, + "contentAvailable": { + "type": "boolean", + "description": "If set to true, the notification will be delivered in the background. Available only for iOS Platform.", + "default": null, + "x-example": false + }, + "critical": { + "type": "boolean", + "description": "If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform.", + "default": null, + "x-example": false + }, + "priority": { + "type": "string", + "description": "Set the notification priority. \"normal\" will consider device battery state and may send notifications later. \"high\" will always attempt to immediately deliver the notification.", + "default": null, + "x-example": "normal", + "enum": [ + "normal", + "high" + ], + "x-enum-name": null, + "x-enum-keys": [] } } } @@ -35618,7 +35666,7 @@ }, "schedule": { "type": "string", - "description": "Function execution schedult in CRON format.", + "description": "Function execution schedule in CRON format.", "x-example": "5 4 * * *" }, "timeout": { diff --git a/app/config/specs/swagger2-1.6.x-server.json b/app/config/specs/swagger2-1.6.x-server.json index 2c8e80c65e..5a06a27a63 100644 --- a/app/config/specs/swagger2-1.6.x-server.json +++ b/app/config/specs/swagger2-1.6.x-server.json @@ -1,7 +1,7 @@ { "swagger": "2.0", "info": { - "version": "1.6.0", + "version": "1.6.1", "title": "Appwrite", "description": "Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https:\/\/appwrite.io\/docs](https:\/\/appwrite.io\/docs)", "termsOfService": "https:\/\/appwrite.io\/policy\/terms", @@ -2604,7 +2604,7 @@ "tags": [ "account" ], - "description": "Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST \/v1\/account\/sessions\/token](https:\/\/appwrite.io\/docs\/references\/cloud\/client-web\/account#createSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. If you are on a mobile device you can leave the URL parameter empty, so that the login completion will be handled by your Appwrite instance by default.\n\nA user is limited to 10 active sessions at a time by default. [Learn more about session limits](https:\/\/appwrite.io\/docs\/authentication-security#limits).\n", + "description": "Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST \/v1\/account\/sessions\/token](https:\/\/appwrite.io\/docs\/references\/cloud\/client-web\/account#createSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour.\n\nA user is limited to 10 active sessions at a time by default. [Learn more about session limits](https:\/\/appwrite.io\/docs\/authentication-security#limits).\n", "responses": { "201": { "description": "Token", @@ -8720,7 +8720,8 @@ "bun-1.0", "bun-1.1", "go-1.23", - "static-1" + "static-1", + "flutter-3.24" ], "x-enum-name": null, "x-enum-keys": [] @@ -9166,7 +9167,8 @@ "bun-1.0", "bun-1.1", "go-1.23", - "static-1" + "static-1", + "flutter-3.24" ], "x-enum-name": null, "x-enum-keys": [] @@ -13194,13 +13196,13 @@ "title": { "type": "string", "description": "Title for push notification.", - "default": null, + "default": "", "x-example": "<TITLE>" }, "body": { "type": "string", "description": "Body for push notification.", - "default": null, + "default": "", "x-example": "<BODY>" }, "topics": { @@ -13232,7 +13234,7 @@ }, "data": { "type": "object", - "description": "Additional Data for push notification.", + "description": "Additional key-value pair data for push notification.", "default": {}, "x-example": "{}" }, @@ -13256,7 +13258,7 @@ }, "sound": { "type": "string", - "description": "Sound for push notification. Available only for Android and IOS Platform.", + "description": "Sound for push notification. Available only for Android and iOS Platform.", "default": "", "x-example": "<SOUND>" }, @@ -13273,10 +13275,10 @@ "x-example": "<TAG>" }, "badge": { - "type": "string", - "description": "Badge for push notification. Available only for IOS Platform.", - "default": "", - "x-example": "<BADGE>" + "type": "integer", + "description": "Badge for push notification. Available only for iOS Platform.", + "default": 0, + "x-example": null }, "draft": { "type": "boolean", @@ -13289,12 +13291,34 @@ "description": "Scheduled delivery time for message in [ISO 8601](https:\/\/www.iso.org\/iso-8601-date-and-time-format.html) format. DateTime value must be in future.", "default": null, "x-example": null + }, + "contentAvailable": { + "type": "boolean", + "description": "If set to true, the notification will be delivered in the background. Available only for iOS Platform.", + "default": false, + "x-example": false + }, + "critical": { + "type": "boolean", + "description": "If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform.", + "default": false, + "x-example": false + }, + "priority": { + "type": "string", + "description": "Set the notification priority. \"normal\" will consider device battery state and may send notifications later. \"high\" will always attempt to immediately deliver the notification.", + "default": "high", + "x-example": "normal", + "enum": [ + "normal", + "high" + ], + "x-enum-name": null, + "x-enum-keys": [] } }, "required": [ - "messageId", - "title", - "body" + "messageId" ] } } @@ -13467,6 +13491,30 @@ "description": "Scheduled delivery time for message in [ISO 8601](https:\/\/www.iso.org\/iso-8601-date-and-time-format.html) format. DateTime value must be in future.", "default": null, "x-example": null + }, + "contentAvailable": { + "type": "boolean", + "description": "If set to true, the notification will be delivered in the background. Available only for iOS Platform.", + "default": null, + "x-example": false + }, + "critical": { + "type": "boolean", + "description": "If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform.", + "default": null, + "x-example": false + }, + "priority": { + "type": "string", + "description": "Set the notification priority. \"normal\" will consider device battery state and may send notifications later. \"high\" will always attempt to immediately deliver the notification.", + "default": null, + "x-example": "normal", + "enum": [ + "normal", + "high" + ], + "x-enum-name": null, + "x-enum-keys": [] } } } @@ -26233,7 +26281,7 @@ }, "schedule": { "type": "string", - "description": "Function execution schedult in CRON format.", + "description": "Function execution schedule in CRON format.", "x-example": "5 4 * * *" }, "timeout": { diff --git a/src/Appwrite/Platform/Workers/Messaging.php b/src/Appwrite/Platform/Workers/Messaging.php index 76e1ad3572..1de503cd9a 100644 --- a/src/Appwrite/Platform/Workers/Messaging.php +++ b/src/Appwrite/Platform/Workers/Messaging.php @@ -276,7 +276,7 @@ class Messaging extends Action Query::equal('identifier', [$result['recipient']]) ]); - if ($target instanceof Document && !$target->isEmpty()) { + if (!$target->isEmpty()) { $dbForProject->updateDocument( 'targets', $target->getId(), @@ -288,7 +288,7 @@ class Messaging extends Action } catch (\Throwable $e) { $deliveryErrors[] = 'Failed sending to targets with error: ' . $e->getMessage(); } finally { - $errorTotal = count($deliveryErrors); + $errorTotal = \count($deliveryErrors); $queueForUsage ->setProject($project) ->addMetric(METRIC_MESSAGES, ($deliveredTotal + $errorTotal)) @@ -676,8 +676,8 @@ class Messaging extends Action private function buildPushMessage(Document $message): Push { $to = $message['to']; - $title = $message['data']['title'] === '' ? null : $message['data']['title']; - $body = $message['data']['body'] === '' ? null : $message['data']['body']; + $title = ($message['data']['title'] ?? null) === '' ? null : $message['data']['title']; + $body = ($message['data']['body'] ?? null) === '' ? null : $message['data']['body']; $data = $message['data']['data'] ?? null; $action = $message['data']['action'] ?? null; $image = $message['data']['image']['url'] ?? null; @@ -688,7 +688,6 @@ class Messaging extends Action $badge = $message['data']['badge'] ?? null; $contentAvailable = $message['data']['contentAvailable'] ?? false; $critical = $message['data']['critical'] ?? false; - $priority = $message['data']['priority'] === 'high' ? Priority::HIGH : Priority::NORMAL; From 8649032b734ac9a40db08d31bcec1df752a2e814 Mon Sep 17 00:00:00 2001 From: Jake Barnby <jakeb994@gmail.com> Date: Tue, 10 Dec 2024 22:52:39 +1300 Subject: [PATCH 11/47] Fix badge param type --- app/controllers/api/messaging.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/messaging.php b/app/controllers/api/messaging.php index dea43add26..28bc9d2896 100644 --- a/app/controllers/api/messaging.php +++ b/app/controllers/api/messaging.php @@ -2930,7 +2930,7 @@ App::post('/v1/messaging/messages/push') ->inject('project') ->inject('queueForMessaging') ->inject('response') - ->action(function (string $messageId, string $title, string $body, array $topics, array $users, array $targets, ?array $data, string $action, string $image, string $icon, string $sound, string $color, string $tag, string $badge, bool $draft, ?string $scheduledAt, bool $contentAvailable, bool $critical, string $priority, Event $queueForEvents, Database $dbForProject, Database $dbForConsole, Document $project, Messaging $queueForMessaging, Response $response) { + ->action(function (string $messageId, string $title, string $body, array $topics, array $users, array $targets, ?array $data, string $action, string $image, string $icon, string $sound, string $color, string $tag, int $badge, bool $draft, ?string $scheduledAt, bool $contentAvailable, bool $critical, string $priority, Event $queueForEvents, Database $dbForProject, Database $dbForConsole, Document $project, Messaging $queueForMessaging, Response $response) { $messageId = $messageId == 'unique()' ? ID::unique() : $messageId; From 15855e2406d1763648dd0e15208a098d9bd94d1b Mon Sep 17 00:00:00 2001 From: Jake Barnby <jakeb994@gmail.com> Date: Tue, 10 Dec 2024 22:53:03 +1300 Subject: [PATCH 12/47] Fix message search builder subquery --- app/init.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/app/init.php b/app/init.php index 30ece74553..059fb412f7 100644 --- a/app/init.php +++ b/app/init.php @@ -721,12 +721,19 @@ Database::addFilter( $data = \json_decode($message->getAttribute('data', []), true); $providerType = $message->getAttribute('providerType', ''); - if ($providerType === MESSAGE_TYPE_EMAIL) { - $searchValues = \array_merge($searchValues, [$data['subject'], MESSAGE_TYPE_EMAIL]); - } elseif ($providerType === MESSAGE_TYPE_SMS) { - $searchValues = \array_merge($searchValues, [$data['content'], MESSAGE_TYPE_SMS]); - } else { - $searchValues = \array_merge($searchValues, [$data['title'], MESSAGE_TYPE_PUSH]); + switch ($providerType) { + case MESSAGE_TYPE_EMAIL: + $searchValues[] = $data['subject']; + $searchValues[] = MESSAGE_TYPE_EMAIL; + break; + case MESSAGE_TYPE_SMS: + $searchValues[] = $data['content']; + $searchValues[] = MESSAGE_TYPE_SMS; + break; + case MESSAGE_TYPE_PUSH: + $searchValues[] = $data['title'] ?? ''; + $searchValues[] = MESSAGE_TYPE_PUSH; + break; } $search = \implode(' ', \array_filter($searchValues)); From f2b202aa52548dfd034cd5d078b1570e93dbba13 Mon Sep 17 00:00:00 2001 From: Jake Barnby <jakeb994@gmail.com> Date: Tue, 10 Dec 2024 22:53:40 +1300 Subject: [PATCH 13/47] 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, From 30fed93e2aa76259395e453821d143fe6ab112eb Mon Sep 17 00:00:00 2001 From: Jake Barnby <jakeb994@gmail.com> Date: Tue, 10 Dec 2024 23:33:49 +1300 Subject: [PATCH 14/47] Remove variable variable usage --- app/controllers/api/messaging.php | 44 ++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/app/controllers/api/messaging.php b/app/controllers/api/messaging.php index 28bc9d2896..6c5fdf6df3 100644 --- a/app/controllers/api/messaging.php +++ b/app/controllers/api/messaging.php @@ -3013,12 +3013,44 @@ App::post('/v1/messaging/messages/push') $pushData = []; - $keys = ['title', 'body', 'data', 'action', 'image', 'icon', 'sound', 'color', 'tag', 'badge', 'contentAvailable', 'critical', 'priority']; - - foreach ($keys as $key) { - if (!empty($$key)) { - $pushData[$key] = $$key; - } + if (!empty($title)) { + $pushData['title'] = $title; + } + if (!empty($body)) { + $pushData['body'] = $body; + } + if (!empty($data)) { + $pushData['data'] = $data; + } + if (!empty($action)) { + $pushData['action'] = $action; + } + if (!empty($image)) { + $pushData['image'] = $image; + } + if (!empty($icon)) { + $pushData['icon'] = $icon; + } + if (!empty($sound)) { + $pushData['sound'] = $sound; + } + if (!empty($color)) { + $pushData['color'] = $color; + } + if (!empty($tag)) { + $pushData['tag'] = $tag; + } + if ($badge >= 0) { + $pushData['badge'] = $badge; + } + if ($contentAvailable) { + $pushData['contentAvailable'] = true; + } + if ($critical) { + $pushData['critical'] = true; + } + if (!empty($priority)) { + $pushData['priority'] = $priority; } $message = $dbForProject->createDocument('messages', new Document([ From 6c83eba693089b9928b1b5fd9e3b83c7c7864400 Mon Sep 17 00:00:00 2001 From: Jake Barnby <jakeb994@gmail.com> Date: Tue, 10 Dec 2024 23:34:24 +1300 Subject: [PATCH 15/47] Fix badge default to allow sending clear badge notifications --- app/controllers/api/messaging.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/messaging.php b/app/controllers/api/messaging.php index 6c5fdf6df3..fe75a0529b 100644 --- a/app/controllers/api/messaging.php +++ b/app/controllers/api/messaging.php @@ -2918,12 +2918,12 @@ App::post('/v1/messaging/messages/push') ->param('sound', '', new Text(256), 'Sound for push notification. Available only for Android and iOS Platform.', true) ->param('color', '', new Text(256), 'Color for push notification. Available only for Android Platform.', true) ->param('tag', '', new Text(256), 'Tag for push notification. Available only for Android Platform.', true) - ->param('badge', 0, new Integer(), 'Badge for push notification. Available only for iOS Platform.', true) + ->param('badge', -1, new Integer(), 'Badge for push notification. Available only for iOS Platform.', true) ->param('draft', false, new Boolean(), 'Is message a draft', true) ->param('scheduledAt', null, new DatetimeValidator(requireDateInFuture: true), 'Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future.', true) ->param('contentAvailable', false, new Boolean(), 'If set to true, the notification will be delivered in the background. Available only for iOS Platform.', true) ->param('critical', false, new Boolean(), 'If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform.', true) - ->param('priority', 'high', new WhiteList(['normal', 'high']), 'Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification.', true) + ->param('priority', 'high', new WhiteList(['normal', 'high']), 'Set the notification priority. "normal" will consider device state and may not deliver notifications immediately. "high" will always attempt to immediately deliver the notification.', true) ->inject('queueForEvents') ->inject('dbForProject') ->inject('dbForConsole') From 636dc8fe9faef5de29f57be8f045b02d48928cbf Mon Sep 17 00:00:00 2001 From: Jake Barnby <jakeb994@gmail.com> Date: Tue, 10 Dec 2024 23:53:56 +1300 Subject: [PATCH 16/47] Update specs --- app/config/specs/open-api3-1.6.x-console.json | 2 +- app/config/specs/open-api3-1.6.x-server.json | 2 +- app/config/specs/open-api3-latest-console.json | 2 +- app/config/specs/open-api3-latest-server.json | 2 +- app/config/specs/swagger2-1.6.x-console.json | 4 ++-- app/config/specs/swagger2-1.6.x-server.json | 4 ++-- app/config/specs/swagger2-latest-console.json | 4 ++-- app/config/specs/swagger2-latest-server.json | 4 ++-- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/config/specs/open-api3-1.6.x-console.json b/app/config/specs/open-api3-1.6.x-console.json index 32985d9c58..a9e502c1dd 100644 --- a/app/config/specs/open-api3-1.6.x-console.json +++ b/app/config/specs/open-api3-1.6.x-console.json @@ -14182,7 +14182,7 @@ }, "priority": { "type": "string", - "description": "Set the notification priority. \"normal\" will consider device battery state and may send notifications later. \"high\" will always attempt to immediately deliver the notification.", + "description": "Set the notification priority. \"normal\" will consider device state and may not deliver notifications immediately. \"high\" will always attempt to immediately deliver the notification.", "x-example": "normal", "enum": [ "normal", diff --git a/app/config/specs/open-api3-1.6.x-server.json b/app/config/specs/open-api3-1.6.x-server.json index 12d1337c5e..38a0fe242b 100644 --- a/app/config/specs/open-api3-1.6.x-server.json +++ b/app/config/specs/open-api3-1.6.x-server.json @@ -13040,7 +13040,7 @@ }, "priority": { "type": "string", - "description": "Set the notification priority. \"normal\" will consider device battery state and may send notifications later. \"high\" will always attempt to immediately deliver the notification.", + "description": "Set the notification priority. \"normal\" will consider device state and may not deliver notifications immediately. \"high\" will always attempt to immediately deliver the notification.", "x-example": "normal", "enum": [ "normal", diff --git a/app/config/specs/open-api3-latest-console.json b/app/config/specs/open-api3-latest-console.json index 32985d9c58..a9e502c1dd 100644 --- a/app/config/specs/open-api3-latest-console.json +++ b/app/config/specs/open-api3-latest-console.json @@ -14182,7 +14182,7 @@ }, "priority": { "type": "string", - "description": "Set the notification priority. \"normal\" will consider device battery state and may send notifications later. \"high\" will always attempt to immediately deliver the notification.", + "description": "Set the notification priority. \"normal\" will consider device state and may not deliver notifications immediately. \"high\" will always attempt to immediately deliver the notification.", "x-example": "normal", "enum": [ "normal", diff --git a/app/config/specs/open-api3-latest-server.json b/app/config/specs/open-api3-latest-server.json index 12d1337c5e..38a0fe242b 100644 --- a/app/config/specs/open-api3-latest-server.json +++ b/app/config/specs/open-api3-latest-server.json @@ -13040,7 +13040,7 @@ }, "priority": { "type": "string", - "description": "Set the notification priority. \"normal\" will consider device battery state and may send notifications later. \"high\" will always attempt to immediately deliver the notification.", + "description": "Set the notification priority. \"normal\" will consider device state and may not deliver notifications immediately. \"high\" will always attempt to immediately deliver the notification.", "x-example": "normal", "enum": [ "normal", diff --git a/app/config/specs/swagger2-1.6.x-console.json b/app/config/specs/swagger2-1.6.x-console.json index a51fc316cb..c62d82fac7 100644 --- a/app/config/specs/swagger2-1.6.x-console.json +++ b/app/config/specs/swagger2-1.6.x-console.json @@ -14411,7 +14411,7 @@ "badge": { "type": "integer", "description": "Badge for push notification. Available only for iOS Platform.", - "default": 0, + "default": -1, "x-example": null }, "draft": { @@ -14440,7 +14440,7 @@ }, "priority": { "type": "string", - "description": "Set the notification priority. \"normal\" will consider device battery state and may send notifications later. \"high\" will always attempt to immediately deliver the notification.", + "description": "Set the notification priority. \"normal\" will consider device state and may not deliver notifications immediately. \"high\" will always attempt to immediately deliver the notification.", "default": "high", "x-example": "normal", "enum": [ diff --git a/app/config/specs/swagger2-1.6.x-server.json b/app/config/specs/swagger2-1.6.x-server.json index 5a06a27a63..4336313588 100644 --- a/app/config/specs/swagger2-1.6.x-server.json +++ b/app/config/specs/swagger2-1.6.x-server.json @@ -13277,7 +13277,7 @@ "badge": { "type": "integer", "description": "Badge for push notification. Available only for iOS Platform.", - "default": 0, + "default": -1, "x-example": null }, "draft": { @@ -13306,7 +13306,7 @@ }, "priority": { "type": "string", - "description": "Set the notification priority. \"normal\" will consider device battery state and may send notifications later. \"high\" will always attempt to immediately deliver the notification.", + "description": "Set the notification priority. \"normal\" will consider device state and may not deliver notifications immediately. \"high\" will always attempt to immediately deliver the notification.", "default": "high", "x-example": "normal", "enum": [ diff --git a/app/config/specs/swagger2-latest-console.json b/app/config/specs/swagger2-latest-console.json index a51fc316cb..c62d82fac7 100644 --- a/app/config/specs/swagger2-latest-console.json +++ b/app/config/specs/swagger2-latest-console.json @@ -14411,7 +14411,7 @@ "badge": { "type": "integer", "description": "Badge for push notification. Available only for iOS Platform.", - "default": 0, + "default": -1, "x-example": null }, "draft": { @@ -14440,7 +14440,7 @@ }, "priority": { "type": "string", - "description": "Set the notification priority. \"normal\" will consider device battery state and may send notifications later. \"high\" will always attempt to immediately deliver the notification.", + "description": "Set the notification priority. \"normal\" will consider device state and may not deliver notifications immediately. \"high\" will always attempt to immediately deliver the notification.", "default": "high", "x-example": "normal", "enum": [ diff --git a/app/config/specs/swagger2-latest-server.json b/app/config/specs/swagger2-latest-server.json index 5a06a27a63..4336313588 100644 --- a/app/config/specs/swagger2-latest-server.json +++ b/app/config/specs/swagger2-latest-server.json @@ -13277,7 +13277,7 @@ "badge": { "type": "integer", "description": "Badge for push notification. Available only for iOS Platform.", - "default": 0, + "default": -1, "x-example": null }, "draft": { @@ -13306,7 +13306,7 @@ }, "priority": { "type": "string", - "description": "Set the notification priority. \"normal\" will consider device battery state and may send notifications later. \"high\" will always attempt to immediately deliver the notification.", + "description": "Set the notification priority. \"normal\" will consider device state and may not deliver notifications immediately. \"high\" will always attempt to immediately deliver the notification.", "default": "high", "x-example": "normal", "enum": [ From 478e19f52fc8df3bfcfca025c0cbe8d8334d6c46 Mon Sep 17 00:00:00 2001 From: Jake Barnby <jakeb994@gmail.com> Date: Wed, 11 Dec 2024 00:26:01 +1300 Subject: [PATCH 17/47] Map push priority enum name --- app/config/specs/open-api3-1.6.x-console.json | 4 ++-- app/config/specs/open-api3-1.6.x-server.json | 4 ++-- app/config/specs/open-api3-latest-console.json | 4 ++-- app/config/specs/open-api3-latest-server.json | 4 ++-- app/config/specs/swagger2-1.6.x-console.json | 4 ++-- app/config/specs/swagger2-1.6.x-server.json | 4 ++-- app/config/specs/swagger2-latest-console.json | 4 ++-- app/config/specs/swagger2-latest-server.json | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/config/specs/open-api3-1.6.x-console.json b/app/config/specs/open-api3-1.6.x-console.json index a9e502c1dd..3c16ebc066 100644 --- a/app/config/specs/open-api3-1.6.x-console.json +++ b/app/config/specs/open-api3-1.6.x-console.json @@ -14188,7 +14188,7 @@ "normal", "high" ], - "x-enum-name": null, + "x-enum-name": "MessagePriority", "x-enum-keys": [] } }, @@ -14371,7 +14371,7 @@ "normal", "high" ], - "x-enum-name": null, + "x-enum-name": "MessagePriority", "x-enum-keys": [] } } diff --git a/app/config/specs/open-api3-1.6.x-server.json b/app/config/specs/open-api3-1.6.x-server.json index 38a0fe242b..75ff222ee6 100644 --- a/app/config/specs/open-api3-1.6.x-server.json +++ b/app/config/specs/open-api3-1.6.x-server.json @@ -13046,7 +13046,7 @@ "normal", "high" ], - "x-enum-name": null, + "x-enum-name": "MessagePriority", "x-enum-keys": [] } }, @@ -13230,7 +13230,7 @@ "normal", "high" ], - "x-enum-name": null, + "x-enum-name": "MessagePriority", "x-enum-keys": [] } } diff --git a/app/config/specs/open-api3-latest-console.json b/app/config/specs/open-api3-latest-console.json index a9e502c1dd..3c16ebc066 100644 --- a/app/config/specs/open-api3-latest-console.json +++ b/app/config/specs/open-api3-latest-console.json @@ -14188,7 +14188,7 @@ "normal", "high" ], - "x-enum-name": null, + "x-enum-name": "MessagePriority", "x-enum-keys": [] } }, @@ -14371,7 +14371,7 @@ "normal", "high" ], - "x-enum-name": null, + "x-enum-name": "MessagePriority", "x-enum-keys": [] } } diff --git a/app/config/specs/open-api3-latest-server.json b/app/config/specs/open-api3-latest-server.json index 38a0fe242b..75ff222ee6 100644 --- a/app/config/specs/open-api3-latest-server.json +++ b/app/config/specs/open-api3-latest-server.json @@ -13046,7 +13046,7 @@ "normal", "high" ], - "x-enum-name": null, + "x-enum-name": "MessagePriority", "x-enum-keys": [] } }, @@ -13230,7 +13230,7 @@ "normal", "high" ], - "x-enum-name": null, + "x-enum-name": "MessagePriority", "x-enum-keys": [] } } diff --git a/app/config/specs/swagger2-1.6.x-console.json b/app/config/specs/swagger2-1.6.x-console.json index c62d82fac7..5e42b84478 100644 --- a/app/config/specs/swagger2-1.6.x-console.json +++ b/app/config/specs/swagger2-1.6.x-console.json @@ -14447,7 +14447,7 @@ "normal", "high" ], - "x-enum-name": null, + "x-enum-name": "MessagePriority", "x-enum-keys": [] } }, @@ -14646,7 +14646,7 @@ "normal", "high" ], - "x-enum-name": null, + "x-enum-name": "MessagePriority", "x-enum-keys": [] } } diff --git a/app/config/specs/swagger2-1.6.x-server.json b/app/config/specs/swagger2-1.6.x-server.json index 4336313588..3aa1139c09 100644 --- a/app/config/specs/swagger2-1.6.x-server.json +++ b/app/config/specs/swagger2-1.6.x-server.json @@ -13313,7 +13313,7 @@ "normal", "high" ], - "x-enum-name": null, + "x-enum-name": "MessagePriority", "x-enum-keys": [] } }, @@ -13513,7 +13513,7 @@ "normal", "high" ], - "x-enum-name": null, + "x-enum-name": "MessagePriority", "x-enum-keys": [] } } diff --git a/app/config/specs/swagger2-latest-console.json b/app/config/specs/swagger2-latest-console.json index c62d82fac7..5e42b84478 100644 --- a/app/config/specs/swagger2-latest-console.json +++ b/app/config/specs/swagger2-latest-console.json @@ -14447,7 +14447,7 @@ "normal", "high" ], - "x-enum-name": null, + "x-enum-name": "MessagePriority", "x-enum-keys": [] } }, @@ -14646,7 +14646,7 @@ "normal", "high" ], - "x-enum-name": null, + "x-enum-name": "MessagePriority", "x-enum-keys": [] } } diff --git a/app/config/specs/swagger2-latest-server.json b/app/config/specs/swagger2-latest-server.json index 4336313588..3aa1139c09 100644 --- a/app/config/specs/swagger2-latest-server.json +++ b/app/config/specs/swagger2-latest-server.json @@ -13313,7 +13313,7 @@ "normal", "high" ], - "x-enum-name": null, + "x-enum-name": "MessagePriority", "x-enum-keys": [] } }, @@ -13513,7 +13513,7 @@ "normal", "high" ], - "x-enum-name": null, + "x-enum-name": "MessagePriority", "x-enum-keys": [] } } From 4a49629a34359bcd9cde7649c109e9d822348a7e Mon Sep 17 00:00:00 2001 From: Jake Barnby <jakeb994@gmail.com> Date: Wed, 11 Dec 2024 00:26:58 +1300 Subject: [PATCH 18/47] Map enum --- src/Appwrite/Specification/Format.php | 2 ++ src/Appwrite/Specification/Format/Swagger2.php | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/Specification/Format.php b/src/Appwrite/Specification/Format.php index 30ce6470e1..8396f5cb7c 100644 --- a/src/Appwrite/Specification/Format.php +++ b/src/Appwrite/Specification/Format.php @@ -215,6 +215,8 @@ abstract class Format switch ($param) { case 'status': return 'MessageStatus'; + case 'priority': + return 'MessagePriority'; } break; case 'createSmtpProvider': diff --git a/src/Appwrite/Specification/Format/Swagger2.php b/src/Appwrite/Specification/Format/Swagger2.php index 66a540a4d4..b10188525e 100644 --- a/src/Appwrite/Specification/Format/Swagger2.php +++ b/src/Appwrite/Specification/Format/Swagger2.php @@ -34,7 +34,6 @@ class Swagger2 extends Format foreach ($this->models as $m) { if ($m->getType() === $ruleType) { $this->getNestedModels($m, $usedModels); - continue; } } } @@ -46,7 +45,6 @@ class Swagger2 extends Format foreach ($this->models as $m) { if ($m->getType() === $rule['type']) { $this->getNestedModels($m, $usedModels); - continue; } } } From d80731e7dbbd160f37dea6b1ad952928e8e9a9b2 Mon Sep 17 00:00:00 2001 From: Jake Barnby <jakeb994@gmail.com> Date: Wed, 11 Dec 2024 19:14:10 +1300 Subject: [PATCH 19/47] Allow pushing SDK to new branches --- src/Appwrite/Platform/Tasks/SDKs.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Appwrite/Platform/Tasks/SDKs.php b/src/Appwrite/Platform/Tasks/SDKs.php index 6e37f270a4..126dcd7fb4 100644 --- a/src/Appwrite/Platform/Tasks/SDKs.php +++ b/src/Appwrite/Platform/Tasks/SDKs.php @@ -41,15 +41,15 @@ class SDKs extends Action $this ->desc('Generate Appwrite SDKs') ->param('platform', null, new Nullable(new Text(256)), 'Selected Platform', optional: true) - ->param('sdk', null, new Nullable(new Text(256)), 'Selected SDK', optional:true) - ->param('version', null, new Nullable(new Text(256)), 'Selected SDK', optional:true) + ->param('sdk', null, new Nullable(new Text(256)), 'Selected SDK', optional: true) + ->param('version', null, new Nullable(new Text(256)), 'Selected SDK', optional: true) ->param('git', null, new Nullable(new WhiteList(['yes', 'no'])), 'Should we use git push?', optional: true) - ->param('production', null, new Nullable(new WhiteList(['yes', 'no'])), 'Should we push to production?', optional:true) - ->param('message', null, new Nullable(new Text(256)), 'Commit Message', optional:true) + ->param('production', null, new Nullable(new WhiteList(['yes', 'no'])), 'Should we push to production?', optional: true) + ->param('message', null, new Nullable(new Text(256)), 'Commit Message', optional: true) ->callback([$this, 'action']); } - public function action(?string $selectedPlatform, ?string $selectedSDK, ?string $version, ?string $git, ?string $production, ?string $message) + public function action(?string $selectedPlatform, ?string $selectedSDK, ?string $version, ?string $git, ?string $production, ?string $message): void { $selectedPlatform ??= Console::confirm('Choose Platform ("' . APP_PLATFORM_CLIENT . '", "' . APP_PLATFORM_SERVER . '", "' . APP_PLATFORM_CONSOLE . '" or "*" for all):'); $selectedSDK ??= \strtolower(Console::confirm('Choose SDK ("*" for all):')); @@ -275,9 +275,13 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND \exec('rm -rf ' . $target . ' && \ mkdir -p ' . $target . ' && \ cd ' . $target . ' && \ - git init --initial-branch=' . $gitBranch . ' && \ + git init && \ git remote add origin ' . $gitUrl . ' && \ - git fetch origin ' . $gitBranch . ' && \ + git fetch origin && \ + git checkout main || git checkout -b main && \ + git pull origin main && \ + git checkout ' . $gitBranch . ' || git checkout -b ' . $gitBranch . ' && \ + git fetch origin ' . $gitBranch . ' || git push -u origin ' . $gitBranch . ' && \ git pull origin ' . $gitBranch . ' && \ rm -rf ' . $target . '/* && \ cp -r ' . $result . '/. ' . $target . '/ && \ From bb6da36b36582f70770bbdba481a4a3ffbcd6ab3 Mon Sep 17 00:00:00 2001 From: Jake Barnby <jakeb994@gmail.com> Date: Wed, 11 Dec 2024 19:15:10 +1300 Subject: [PATCH 20/47] Update versions --- app/config/platforms.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/config/platforms.php b/app/config/platforms.php index e54fb0a073..e83076cb9e 100644 --- a/app/config/platforms.php +++ b/app/config/platforms.php @@ -245,7 +245,7 @@ return [ [ 'key' => 'nodejs', 'name' => 'Node.js', - 'version' => '14.1.0', + 'version' => '14.2.0', 'url' => 'https://github.com/appwrite/sdk-for-node', 'package' => 'https://www.npmjs.com/package/node-appwrite', 'enabled' => true, @@ -263,7 +263,7 @@ return [ [ 'key' => 'deno', 'name' => 'Deno', - 'version' => '12.1.0', + 'version' => '12.2.0', 'url' => 'https://github.com/appwrite/sdk-for-deno', 'package' => 'https://deno.land/x/appwrite', 'enabled' => true, @@ -281,7 +281,7 @@ return [ [ 'key' => 'php', 'name' => 'PHP', - 'version' => '12.1.0', + 'version' => '12.2.0', 'url' => 'https://github.com/appwrite/sdk-for-php', 'package' => 'https://packagist.org/packages/appwrite/appwrite', 'enabled' => true, @@ -299,7 +299,7 @@ return [ [ 'key' => 'python', 'name' => 'Python', - 'version' => '6.1.0', + 'version' => '6.2.0', 'url' => 'https://github.com/appwrite/sdk-for-python', 'package' => 'https://pypi.org/project/appwrite/', 'enabled' => true, @@ -317,7 +317,7 @@ return [ [ 'key' => 'ruby', 'name' => 'Ruby', - 'version' => '12.1.1', + 'version' => '12.2.0', 'url' => 'https://github.com/appwrite/sdk-for-ruby', 'package' => 'https://rubygems.org/gems/appwrite', 'enabled' => true, @@ -335,7 +335,7 @@ return [ [ 'key' => 'go', 'name' => 'Go', - 'version' => '0.2.0', + 'version' => '0.3.0', 'url' => 'https://github.com/appwrite/sdk-for-go', 'package' => 'https://github.com/appwrite/sdk-for-go', 'enabled' => true, @@ -353,7 +353,7 @@ return [ [ 'key' => 'dotnet', 'name' => '.NET', - 'version' => '0.10.1', + 'version' => '0.11.0', 'url' => 'https://github.com/appwrite/sdk-for-dotnet', 'package' => 'https://www.nuget.org/packages/Appwrite', 'enabled' => true, @@ -371,7 +371,7 @@ return [ [ 'key' => 'dart', 'name' => 'Dart', - 'version' => '12.1.0', + 'version' => '12.2.0', 'url' => 'https://github.com/appwrite/sdk-for-dart', 'package' => 'https://pub.dev/packages/dart_appwrite', 'enabled' => true, @@ -389,7 +389,7 @@ return [ [ 'key' => 'kotlin', 'name' => 'Kotlin', - 'version' => '6.1.0', + 'version' => '6.2.0', 'url' => 'https://github.com/appwrite/sdk-for-kotlin', 'package' => 'https://search.maven.org/artifact/io.appwrite/sdk-for-kotlin', 'enabled' => true, @@ -411,7 +411,7 @@ return [ [ 'key' => 'swift', 'name' => 'Swift', - 'version' => '6.1.0', + 'version' => '6.2.0', 'url' => 'https://github.com/appwrite/sdk-for-swift', 'package' => 'https://github.com/appwrite/sdk-for-swift', 'enabled' => true, From 8531b70089cfee3c0c8aa36830b6ccd0519a44ce Mon Sep 17 00:00:00 2001 From: Jake Barnby <jakeb994@gmail.com> Date: Wed, 11 Dec 2024 19:15:29 +1300 Subject: [PATCH 21/47] Update docs --- .../examples/databases/update-string-attribute.md | 2 +- .../server-dart/examples/messaging/create-push.md | 9 ++++++--- .../server-dart/examples/messaging/update-push.md | 3 +++ .../examples/databases/update-string-attribute.md | 2 +- .../server-deno/examples/messaging/create-push.md | 13 ++++++++----- .../server-deno/examples/messaging/update-push.md | 7 +++++-- .../examples/databases/update-string-attribute.md | 2 +- .../server-dotnet/examples/messaging/create-push.md | 12 ++++++++---- .../server-dotnet/examples/messaging/update-push.md | 6 +++++- .../examples/databases/update-string-attribute.md | 2 +- .../server-go/examples/messaging/create-push.md | 9 ++++++--- .../server-go/examples/messaging/update-push.md | 3 +++ .../1.6.x/server-graphql/examples/account/create.md | 1 + .../1.6.x/server-graphql/examples/account/get.md | 1 + .../server-graphql/examples/account/update-email.md | 1 + .../server-graphql/examples/account/update-m-f-a.md | 1 + .../examples/account/update-mfa-authenticator.md | 1 + .../server-graphql/examples/account/update-name.md | 1 + .../examples/account/update-password.md | 1 + .../server-graphql/examples/account/update-phone.md | 1 + .../server-graphql/examples/account/update-prefs.md | 1 + .../examples/account/update-status.md | 1 + .../examples/databases/create-boolean-attribute.md | 2 ++ .../examples/databases/create-collection.md | 2 ++ .../examples/databases/create-datetime-attribute.md | 2 ++ .../examples/databases/create-email-attribute.md | 2 ++ .../examples/databases/create-enum-attribute.md | 2 ++ .../examples/databases/create-float-attribute.md | 2 ++ .../examples/databases/create-index.md | 2 ++ .../examples/databases/create-integer-attribute.md | 2 ++ .../examples/databases/create-ip-attribute.md | 2 ++ .../databases/create-relationship-attribute.md | 2 ++ .../examples/databases/create-string-attribute.md | 2 ++ .../examples/databases/create-url-attribute.md | 2 ++ .../examples/databases/get-collection.md | 2 ++ .../server-graphql/examples/databases/get-index.md | 2 ++ .../examples/databases/list-collections.md | 2 ++ .../examples/databases/list-indexes.md | 2 ++ .../examples/databases/update-boolean-attribute.md | 2 ++ .../examples/databases/update-collection.md | 2 ++ .../examples/databases/update-datetime-attribute.md | 2 ++ .../examples/databases/update-email-attribute.md | 2 ++ .../examples/databases/update-enum-attribute.md | 2 ++ .../examples/databases/update-float-attribute.md | 2 ++ .../examples/databases/update-integer-attribute.md | 2 ++ .../examples/databases/update-ip-attribute.md | 2 ++ .../databases/update-relationship-attribute.md | 2 ++ .../examples/databases/update-string-attribute.md | 4 +++- .../examples/databases/update-url-attribute.md | 2 ++ .../examples/messaging/create-push.md | 7 +++++-- .../examples/messaging/create-subscriber.md | 1 + .../examples/messaging/get-subscriber.md | 1 + .../examples/messaging/list-subscribers.md | 1 + .../examples/messaging/list-targets.md | 1 + .../examples/messaging/update-push.md | 5 ++++- .../examples/users/create-argon2user.md | 1 + .../examples/users/create-bcrypt-user.md | 1 + .../examples/users/create-m-d5user.md | 1 + .../examples/users/create-p-h-pass-user.md | 1 + .../examples/users/create-s-h-a-user.md | 1 + .../examples/users/create-scrypt-modified-user.md | 1 + .../examples/users/create-scrypt-user.md | 1 + .../server-graphql/examples/users/create-target.md | 1 + .../1.6.x/server-graphql/examples/users/create.md | 1 + .../examples/users/delete-mfa-authenticator.md | 1 + .../server-graphql/examples/users/get-target.md | 1 + .../1.6.x/server-graphql/examples/users/get.md | 1 + .../server-graphql/examples/users/list-targets.md | 1 + .../1.6.x/server-graphql/examples/users/list.md | 1 + .../examples/users/update-email-verification.md | 1 + .../server-graphql/examples/users/update-email.md | 1 + .../server-graphql/examples/users/update-labels.md | 1 + .../server-graphql/examples/users/update-mfa.md | 1 + .../server-graphql/examples/users/update-name.md | 1 + .../examples/users/update-password.md | 1 + .../examples/users/update-phone-verification.md | 1 + .../server-graphql/examples/users/update-phone.md | 1 + .../server-graphql/examples/users/update-status.md | 1 + .../server-graphql/examples/users/update-target.md | 1 + .../java/databases/update-string-attribute.md | 2 +- .../server-kotlin/java/messaging/create-push.md | 9 ++++++--- .../server-kotlin/java/messaging/update-push.md | 3 +++ .../kotlin/databases/update-string-attribute.md | 2 +- .../server-kotlin/kotlin/messaging/create-push.md | 11 +++++++---- .../server-kotlin/kotlin/messaging/update-push.md | 5 ++++- .../examples/databases/update-string-attribute.md | 2 +- .../server-nodejs/examples/messaging/create-push.md | 11 +++++++---- .../server-nodejs/examples/messaging/update-push.md | 5 ++++- .../examples/databases/update-string-attribute.md | 2 +- .../server-php/examples/messaging/create-push.md | 11 +++++++---- .../server-php/examples/messaging/update-push.md | 5 ++++- .../examples/databases/update-string-attribute.md | 2 +- .../server-python/examples/messaging/create-push.md | 11 +++++++---- .../server-python/examples/messaging/update-push.md | 5 ++++- .../examples/databases/update-string-attribute.md | 2 +- .../server-rest/examples/messaging/create-push.md | 7 +++++-- .../server-rest/examples/messaging/update-push.md | 5 ++++- .../examples/databases/update-string-attribute.md | 2 +- .../server-ruby/examples/messaging/create-push.md | 11 +++++++---- .../server-ruby/examples/messaging/update-push.md | 5 ++++- .../examples/databases/update-string-attribute.md | 2 +- .../server-swift/examples/messaging/create-push.md | 12 ++++++++---- .../server-swift/examples/messaging/update-push.md | 6 +++++- 103 files changed, 244 insertions(+), 70 deletions(-) diff --git a/docs/examples/1.6.x/server-dart/examples/databases/update-string-attribute.md b/docs/examples/1.6.x/server-dart/examples/databases/update-string-attribute.md index c2f3804c66..f9498aa36b 100644 --- a/docs/examples/1.6.x/server-dart/examples/databases/update-string-attribute.md +++ b/docs/examples/1.6.x/server-dart/examples/databases/update-string-attribute.md @@ -13,6 +13,6 @@ AttributeString result = await databases.updateStringAttribute( key: '', xrequired: false, xdefault: '<DEFAULT>', - size: 0, // (optional) + size: 1, // (optional) newKey: '', // (optional) ); diff --git a/docs/examples/1.6.x/server-dart/examples/messaging/create-push.md b/docs/examples/1.6.x/server-dart/examples/messaging/create-push.md index c3c7d2ffc5..e496de9d27 100644 --- a/docs/examples/1.6.x/server-dart/examples/messaging/create-push.md +++ b/docs/examples/1.6.x/server-dart/examples/messaging/create-push.md @@ -9,8 +9,8 @@ Messaging messaging = Messaging(client); Message result = await messaging.createPush( messageId: '<MESSAGE_ID>', - title: '<TITLE>', - body: '<BODY>', + title: '<TITLE>', // (optional) + body: '<BODY>', // (optional) topics: [], // (optional) users: [], // (optional) targets: [], // (optional) @@ -21,7 +21,10 @@ Message result = await messaging.createPush( sound: '<SOUND>', // (optional) color: '<COLOR>', // (optional) tag: '<TAG>', // (optional) - badge: '<BADGE>', // (optional) + badge: 0, // (optional) draft: false, // (optional) scheduledAt: '', // (optional) + contentAvailable: false, // (optional) + critical: false, // (optional) + priority: MessagePriority.normal, // (optional) ); diff --git a/docs/examples/1.6.x/server-dart/examples/messaging/update-push.md b/docs/examples/1.6.x/server-dart/examples/messaging/update-push.md index dcec9b243f..f5d75332e2 100644 --- a/docs/examples/1.6.x/server-dart/examples/messaging/update-push.md +++ b/docs/examples/1.6.x/server-dart/examples/messaging/update-push.md @@ -24,4 +24,7 @@ Message result = await messaging.updatePush( badge: 0, // (optional) draft: false, // (optional) scheduledAt: '', // (optional) + contentAvailable: false, // (optional) + critical: false, // (optional) + priority: MessagePriority.normal, // (optional) ); diff --git a/docs/examples/1.6.x/server-deno/examples/databases/update-string-attribute.md b/docs/examples/1.6.x/server-deno/examples/databases/update-string-attribute.md index 6603c377cb..d57f8fd663 100644 --- a/docs/examples/1.6.x/server-deno/examples/databases/update-string-attribute.md +++ b/docs/examples/1.6.x/server-deno/examples/databases/update-string-attribute.md @@ -13,6 +13,6 @@ const response = await databases.updateStringAttribute( '', // key false, // required '<DEFAULT>', // default - null, // size (optional) + 1, // size (optional) '' // newKey (optional) ); diff --git a/docs/examples/1.6.x/server-deno/examples/messaging/create-push.md b/docs/examples/1.6.x/server-deno/examples/messaging/create-push.md index 005cca1b77..7b41911918 100644 --- a/docs/examples/1.6.x/server-deno/examples/messaging/create-push.md +++ b/docs/examples/1.6.x/server-deno/examples/messaging/create-push.md @@ -1,4 +1,4 @@ -import { Client, Messaging } from "https://deno.land/x/appwrite/mod.ts"; +import { Client, Messaging, MessagePriority } from "https://deno.land/x/appwrite/mod.ts"; const client = new Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint @@ -9,8 +9,8 @@ const messaging = new Messaging(client); const response = await messaging.createPush( '<MESSAGE_ID>', // messageId - '<TITLE>', // title - '<BODY>', // body + '<TITLE>', // title (optional) + '<BODY>', // body (optional) [], // topics (optional) [], // users (optional) [], // targets (optional) @@ -21,7 +21,10 @@ const response = await messaging.createPush( '<SOUND>', // sound (optional) '<COLOR>', // color (optional) '<TAG>', // tag (optional) - '<BADGE>', // badge (optional) + null, // badge (optional) false, // draft (optional) - '' // scheduledAt (optional) + '', // scheduledAt (optional) + false, // contentAvailable (optional) + false, // critical (optional) + MessagePriority.Normal // priority (optional) ); diff --git a/docs/examples/1.6.x/server-deno/examples/messaging/update-push.md b/docs/examples/1.6.x/server-deno/examples/messaging/update-push.md index 9c66ab6ab7..11437fabe1 100644 --- a/docs/examples/1.6.x/server-deno/examples/messaging/update-push.md +++ b/docs/examples/1.6.x/server-deno/examples/messaging/update-push.md @@ -1,4 +1,4 @@ -import { Client, Messaging } from "https://deno.land/x/appwrite/mod.ts"; +import { Client, Messaging, MessagePriority } from "https://deno.land/x/appwrite/mod.ts"; const client = new Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint @@ -23,5 +23,8 @@ const response = await messaging.updatePush( '<TAG>', // tag (optional) null, // badge (optional) false, // draft (optional) - '' // scheduledAt (optional) + '', // scheduledAt (optional) + false, // contentAvailable (optional) + false, // critical (optional) + MessagePriority.Normal // priority (optional) ); diff --git a/docs/examples/1.6.x/server-dotnet/examples/databases/update-string-attribute.md b/docs/examples/1.6.x/server-dotnet/examples/databases/update-string-attribute.md index e915d23f51..a180815a50 100644 --- a/docs/examples/1.6.x/server-dotnet/examples/databases/update-string-attribute.md +++ b/docs/examples/1.6.x/server-dotnet/examples/databases/update-string-attribute.md @@ -15,6 +15,6 @@ AttributeString result = await databases.UpdateStringAttribute( key: "", required: false, default: "<DEFAULT>", - size: 0, // optional + size: 1, // optional newKey: "" // optional ); \ No newline at end of file diff --git a/docs/examples/1.6.x/server-dotnet/examples/messaging/create-push.md b/docs/examples/1.6.x/server-dotnet/examples/messaging/create-push.md index f83a0ed8df..588781b3a1 100644 --- a/docs/examples/1.6.x/server-dotnet/examples/messaging/create-push.md +++ b/docs/examples/1.6.x/server-dotnet/examples/messaging/create-push.md @@ -1,4 +1,5 @@ using Appwrite; +using Appwrite.Enums; using Appwrite.Models; using Appwrite.Services; @@ -11,8 +12,8 @@ Messaging messaging = new Messaging(client); Message result = await messaging.CreatePush( messageId: "<MESSAGE_ID>", - title: "<TITLE>", - body: "<BODY>", + title: "<TITLE>", // optional + body: "<BODY>", // optional topics: new List<string>(), // optional users: new List<string>(), // optional targets: new List<string>(), // optional @@ -23,7 +24,10 @@ Message result = await messaging.CreatePush( sound: "<SOUND>", // optional color: "<COLOR>", // optional tag: "<TAG>", // optional - badge: "<BADGE>", // optional + badge: 0, // optional draft: false, // optional - scheduledAt: "" // optional + scheduledAt: "", // optional + contentAvailable: false, // optional + critical: false, // optional + priority: MessagePriority.Normal // optional ); \ No newline at end of file diff --git a/docs/examples/1.6.x/server-dotnet/examples/messaging/update-push.md b/docs/examples/1.6.x/server-dotnet/examples/messaging/update-push.md index 0de09d570a..2b48d1827d 100644 --- a/docs/examples/1.6.x/server-dotnet/examples/messaging/update-push.md +++ b/docs/examples/1.6.x/server-dotnet/examples/messaging/update-push.md @@ -1,4 +1,5 @@ using Appwrite; +using Appwrite.Enums; using Appwrite.Models; using Appwrite.Services; @@ -25,5 +26,8 @@ Message result = await messaging.UpdatePush( tag: "<TAG>", // optional badge: 0, // optional draft: false, // optional - scheduledAt: "" // optional + scheduledAt: "", // optional + contentAvailable: false, // optional + critical: false, // optional + priority: MessagePriority.Normal // optional ); \ No newline at end of file diff --git a/docs/examples/1.6.x/server-go/examples/databases/update-string-attribute.md b/docs/examples/1.6.x/server-go/examples/databases/update-string-attribute.md index d662060f09..f3e6addb07 100644 --- a/docs/examples/1.6.x/server-go/examples/databases/update-string-attribute.md +++ b/docs/examples/1.6.x/server-go/examples/databases/update-string-attribute.md @@ -20,7 +20,7 @@ func main() { "", false, "<DEFAULT>", - databases.WithUpdateStringAttributeSize(0), + databases.WithUpdateStringAttributeSize(1), databases.WithUpdateStringAttributeNewKey(""), ) diff --git a/docs/examples/1.6.x/server-go/examples/messaging/create-push.md b/docs/examples/1.6.x/server-go/examples/messaging/create-push.md index 090e0cbca2..b40037472f 100644 --- a/docs/examples/1.6.x/server-go/examples/messaging/create-push.md +++ b/docs/examples/1.6.x/server-go/examples/messaging/create-push.md @@ -16,8 +16,8 @@ func main() { service := messaging.NewMessaging(client) response, error := service.CreatePush( "<MESSAGE_ID>", - "<TITLE>", - "<BODY>", + messaging.WithCreatePushTitle("<TITLE>"), + messaging.WithCreatePushBody("<BODY>"), messaging.WithCreatePushTopics([]interface{}{}), messaging.WithCreatePushUsers([]interface{}{}), messaging.WithCreatePushTargets([]interface{}{}), @@ -28,9 +28,12 @@ func main() { messaging.WithCreatePushSound("<SOUND>"), messaging.WithCreatePushColor("<COLOR>"), messaging.WithCreatePushTag("<TAG>"), - messaging.WithCreatePushBadge("<BADGE>"), + messaging.WithCreatePushBadge(0), messaging.WithCreatePushDraft(false), messaging.WithCreatePushScheduledAt(""), + messaging.WithCreatePushContentAvailable(false), + messaging.WithCreatePushCritical(false), + messaging.WithCreatePushPriority("normal"), ) if error != nil { diff --git a/docs/examples/1.6.x/server-go/examples/messaging/update-push.md b/docs/examples/1.6.x/server-go/examples/messaging/update-push.md index af1b6095cd..d1b47256c0 100644 --- a/docs/examples/1.6.x/server-go/examples/messaging/update-push.md +++ b/docs/examples/1.6.x/server-go/examples/messaging/update-push.md @@ -31,6 +31,9 @@ func main() { messaging.WithUpdatePushBadge(0), messaging.WithUpdatePushDraft(false), messaging.WithUpdatePushScheduledAt(""), + messaging.WithUpdatePushContentAvailable(false), + messaging.WithUpdatePushCritical(false), + messaging.WithUpdatePushPriority("normal"), ) if error != nil { diff --git a/docs/examples/1.6.x/server-graphql/examples/account/create.md b/docs/examples/1.6.x/server-graphql/examples/account/create.md index 3f8e3c3cf7..0d39394a3d 100644 --- a/docs/examples/1.6.x/server-graphql/examples/account/create.md +++ b/docs/examples/1.6.x/server-graphql/examples/account/create.md @@ -33,6 +33,7 @@ mutation { providerId providerType identifier + expired } accessedAt } diff --git a/docs/examples/1.6.x/server-graphql/examples/account/get.md b/docs/examples/1.6.x/server-graphql/examples/account/get.md index e4db8f0e41..f4f07c187f 100644 --- a/docs/examples/1.6.x/server-graphql/examples/account/get.md +++ b/docs/examples/1.6.x/server-graphql/examples/account/get.md @@ -28,6 +28,7 @@ query { providerId providerType identifier + expired } accessedAt } diff --git a/docs/examples/1.6.x/server-graphql/examples/account/update-email.md b/docs/examples/1.6.x/server-graphql/examples/account/update-email.md index b207bad4bb..c879e24a43 100644 --- a/docs/examples/1.6.x/server-graphql/examples/account/update-email.md +++ b/docs/examples/1.6.x/server-graphql/examples/account/update-email.md @@ -31,6 +31,7 @@ mutation { providerId providerType identifier + expired } accessedAt } diff --git a/docs/examples/1.6.x/server-graphql/examples/account/update-m-f-a.md b/docs/examples/1.6.x/server-graphql/examples/account/update-m-f-a.md index d2cd3d6ae5..787c2e0860 100644 --- a/docs/examples/1.6.x/server-graphql/examples/account/update-m-f-a.md +++ b/docs/examples/1.6.x/server-graphql/examples/account/update-m-f-a.md @@ -30,6 +30,7 @@ mutation { providerId providerType identifier + expired } accessedAt } diff --git a/docs/examples/1.6.x/server-graphql/examples/account/update-mfa-authenticator.md b/docs/examples/1.6.x/server-graphql/examples/account/update-mfa-authenticator.md index c74062c7d4..9cfe9150be 100644 --- a/docs/examples/1.6.x/server-graphql/examples/account/update-mfa-authenticator.md +++ b/docs/examples/1.6.x/server-graphql/examples/account/update-mfa-authenticator.md @@ -31,6 +31,7 @@ mutation { providerId providerType identifier + expired } accessedAt } diff --git a/docs/examples/1.6.x/server-graphql/examples/account/update-name.md b/docs/examples/1.6.x/server-graphql/examples/account/update-name.md index 850b5760a0..8ba2c99d9c 100644 --- a/docs/examples/1.6.x/server-graphql/examples/account/update-name.md +++ b/docs/examples/1.6.x/server-graphql/examples/account/update-name.md @@ -30,6 +30,7 @@ mutation { providerId providerType identifier + expired } accessedAt } diff --git a/docs/examples/1.6.x/server-graphql/examples/account/update-password.md b/docs/examples/1.6.x/server-graphql/examples/account/update-password.md index 5904da0842..f3619a10d2 100644 --- a/docs/examples/1.6.x/server-graphql/examples/account/update-password.md +++ b/docs/examples/1.6.x/server-graphql/examples/account/update-password.md @@ -31,6 +31,7 @@ mutation { providerId providerType identifier + expired } accessedAt } diff --git a/docs/examples/1.6.x/server-graphql/examples/account/update-phone.md b/docs/examples/1.6.x/server-graphql/examples/account/update-phone.md index 408a203300..adecb71168 100644 --- a/docs/examples/1.6.x/server-graphql/examples/account/update-phone.md +++ b/docs/examples/1.6.x/server-graphql/examples/account/update-phone.md @@ -31,6 +31,7 @@ mutation { providerId providerType identifier + expired } accessedAt } diff --git a/docs/examples/1.6.x/server-graphql/examples/account/update-prefs.md b/docs/examples/1.6.x/server-graphql/examples/account/update-prefs.md index 40db7b43db..57280247e4 100644 --- a/docs/examples/1.6.x/server-graphql/examples/account/update-prefs.md +++ b/docs/examples/1.6.x/server-graphql/examples/account/update-prefs.md @@ -30,6 +30,7 @@ mutation { providerId providerType identifier + expired } accessedAt } diff --git a/docs/examples/1.6.x/server-graphql/examples/account/update-status.md b/docs/examples/1.6.x/server-graphql/examples/account/update-status.md index aca8c098e7..c17f556842 100644 --- a/docs/examples/1.6.x/server-graphql/examples/account/update-status.md +++ b/docs/examples/1.6.x/server-graphql/examples/account/update-status.md @@ -28,6 +28,7 @@ mutation { providerId providerType identifier + expired } accessedAt } diff --git a/docs/examples/1.6.x/server-graphql/examples/databases/create-boolean-attribute.md b/docs/examples/1.6.x/server-graphql/examples/databases/create-boolean-attribute.md index 6e969a587e..aa0bfa832e 100644 --- a/docs/examples/1.6.x/server-graphql/examples/databases/create-boolean-attribute.md +++ b/docs/examples/1.6.x/server-graphql/examples/databases/create-boolean-attribute.md @@ -13,6 +13,8 @@ mutation { error required array + _createdAt + _updatedAt default } } diff --git a/docs/examples/1.6.x/server-graphql/examples/databases/create-collection.md b/docs/examples/1.6.x/server-graphql/examples/databases/create-collection.md index 05175cc1e7..51eb51f410 100644 --- a/docs/examples/1.6.x/server-graphql/examples/databases/create-collection.md +++ b/docs/examples/1.6.x/server-graphql/examples/databases/create-collection.md @@ -23,6 +23,8 @@ mutation { error attributes orders + _createdAt + _updatedAt } } } diff --git a/docs/examples/1.6.x/server-graphql/examples/databases/create-datetime-attribute.md b/docs/examples/1.6.x/server-graphql/examples/databases/create-datetime-attribute.md index fcd5cb37a2..47601df0d8 100644 --- a/docs/examples/1.6.x/server-graphql/examples/databases/create-datetime-attribute.md +++ b/docs/examples/1.6.x/server-graphql/examples/databases/create-datetime-attribute.md @@ -13,6 +13,8 @@ mutation { error required array + _createdAt + _updatedAt format default } diff --git a/docs/examples/1.6.x/server-graphql/examples/databases/create-email-attribute.md b/docs/examples/1.6.x/server-graphql/examples/databases/create-email-attribute.md index 1f23a23ba7..e5845ccd47 100644 --- a/docs/examples/1.6.x/server-graphql/examples/databases/create-email-attribute.md +++ b/docs/examples/1.6.x/server-graphql/examples/databases/create-email-attribute.md @@ -13,6 +13,8 @@ mutation { error required array + _createdAt + _updatedAt format default } diff --git a/docs/examples/1.6.x/server-graphql/examples/databases/create-enum-attribute.md b/docs/examples/1.6.x/server-graphql/examples/databases/create-enum-attribute.md index 410a7983b4..d13c080e4a 100644 --- a/docs/examples/1.6.x/server-graphql/examples/databases/create-enum-attribute.md +++ b/docs/examples/1.6.x/server-graphql/examples/databases/create-enum-attribute.md @@ -14,6 +14,8 @@ mutation { error required array + _createdAt + _updatedAt elements format default diff --git a/docs/examples/1.6.x/server-graphql/examples/databases/create-float-attribute.md b/docs/examples/1.6.x/server-graphql/examples/databases/create-float-attribute.md index ae6f9f72d6..2a270c3aff 100644 --- a/docs/examples/1.6.x/server-graphql/examples/databases/create-float-attribute.md +++ b/docs/examples/1.6.x/server-graphql/examples/databases/create-float-attribute.md @@ -15,6 +15,8 @@ mutation { error required array + _createdAt + _updatedAt min max default diff --git a/docs/examples/1.6.x/server-graphql/examples/databases/create-index.md b/docs/examples/1.6.x/server-graphql/examples/databases/create-index.md index efc92a798c..2875a9b4b7 100644 --- a/docs/examples/1.6.x/server-graphql/examples/databases/create-index.md +++ b/docs/examples/1.6.x/server-graphql/examples/databases/create-index.md @@ -13,5 +13,7 @@ mutation { error attributes orders + _createdAt + _updatedAt } } diff --git a/docs/examples/1.6.x/server-graphql/examples/databases/create-integer-attribute.md b/docs/examples/1.6.x/server-graphql/examples/databases/create-integer-attribute.md index 1dc43f6b0d..8c79706817 100644 --- a/docs/examples/1.6.x/server-graphql/examples/databases/create-integer-attribute.md +++ b/docs/examples/1.6.x/server-graphql/examples/databases/create-integer-attribute.md @@ -15,6 +15,8 @@ mutation { error required array + _createdAt + _updatedAt min max default diff --git a/docs/examples/1.6.x/server-graphql/examples/databases/create-ip-attribute.md b/docs/examples/1.6.x/server-graphql/examples/databases/create-ip-attribute.md index b2fd7215a0..0f4ad9e139 100644 --- a/docs/examples/1.6.x/server-graphql/examples/databases/create-ip-attribute.md +++ b/docs/examples/1.6.x/server-graphql/examples/databases/create-ip-attribute.md @@ -13,6 +13,8 @@ mutation { error required array + _createdAt + _updatedAt format default } diff --git a/docs/examples/1.6.x/server-graphql/examples/databases/create-relationship-attribute.md b/docs/examples/1.6.x/server-graphql/examples/databases/create-relationship-attribute.md index ddca20b83a..f66b87d6af 100644 --- a/docs/examples/1.6.x/server-graphql/examples/databases/create-relationship-attribute.md +++ b/docs/examples/1.6.x/server-graphql/examples/databases/create-relationship-attribute.md @@ -15,6 +15,8 @@ mutation { error required array + _createdAt + _updatedAt relatedCollection relationType twoWay diff --git a/docs/examples/1.6.x/server-graphql/examples/databases/create-string-attribute.md b/docs/examples/1.6.x/server-graphql/examples/databases/create-string-attribute.md index 3c290712e9..62d97d6962 100644 --- a/docs/examples/1.6.x/server-graphql/examples/databases/create-string-attribute.md +++ b/docs/examples/1.6.x/server-graphql/examples/databases/create-string-attribute.md @@ -15,6 +15,8 @@ mutation { error required array + _createdAt + _updatedAt size default } diff --git a/docs/examples/1.6.x/server-graphql/examples/databases/create-url-attribute.md b/docs/examples/1.6.x/server-graphql/examples/databases/create-url-attribute.md index d2a39756c9..89ad873e52 100644 --- a/docs/examples/1.6.x/server-graphql/examples/databases/create-url-attribute.md +++ b/docs/examples/1.6.x/server-graphql/examples/databases/create-url-attribute.md @@ -13,6 +13,8 @@ mutation { error required array + _createdAt + _updatedAt format default } diff --git a/docs/examples/1.6.x/server-graphql/examples/databases/get-collection.md b/docs/examples/1.6.x/server-graphql/examples/databases/get-collection.md index f76b71b6ba..ed27286b0d 100644 --- a/docs/examples/1.6.x/server-graphql/examples/databases/get-collection.md +++ b/docs/examples/1.6.x/server-graphql/examples/databases/get-collection.md @@ -19,6 +19,8 @@ query { error attributes orders + _createdAt + _updatedAt } } } diff --git a/docs/examples/1.6.x/server-graphql/examples/databases/get-index.md b/docs/examples/1.6.x/server-graphql/examples/databases/get-index.md index de3c44ebe0..29de7a76f8 100644 --- a/docs/examples/1.6.x/server-graphql/examples/databases/get-index.md +++ b/docs/examples/1.6.x/server-graphql/examples/databases/get-index.md @@ -10,5 +10,7 @@ query { error attributes orders + _createdAt + _updatedAt } } diff --git a/docs/examples/1.6.x/server-graphql/examples/databases/list-collections.md b/docs/examples/1.6.x/server-graphql/examples/databases/list-collections.md index b821b6c4cf..8dafbf7042 100644 --- a/docs/examples/1.6.x/server-graphql/examples/databases/list-collections.md +++ b/docs/examples/1.6.x/server-graphql/examples/databases/list-collections.md @@ -22,6 +22,8 @@ query { error attributes orders + _createdAt + _updatedAt } } } diff --git a/docs/examples/1.6.x/server-graphql/examples/databases/list-indexes.md b/docs/examples/1.6.x/server-graphql/examples/databases/list-indexes.md index e1c11b6c03..3cb67c6451 100644 --- a/docs/examples/1.6.x/server-graphql/examples/databases/list-indexes.md +++ b/docs/examples/1.6.x/server-graphql/examples/databases/list-indexes.md @@ -12,6 +12,8 @@ query { error attributes orders + _createdAt + _updatedAt } } } diff --git a/docs/examples/1.6.x/server-graphql/examples/databases/update-boolean-attribute.md b/docs/examples/1.6.x/server-graphql/examples/databases/update-boolean-attribute.md index e92b41a14e..d508e62139 100644 --- a/docs/examples/1.6.x/server-graphql/examples/databases/update-boolean-attribute.md +++ b/docs/examples/1.6.x/server-graphql/examples/databases/update-boolean-attribute.md @@ -13,6 +13,8 @@ mutation { error required array + _createdAt + _updatedAt default } } diff --git a/docs/examples/1.6.x/server-graphql/examples/databases/update-collection.md b/docs/examples/1.6.x/server-graphql/examples/databases/update-collection.md index fc78bb8efc..e918c058b8 100644 --- a/docs/examples/1.6.x/server-graphql/examples/databases/update-collection.md +++ b/docs/examples/1.6.x/server-graphql/examples/databases/update-collection.md @@ -23,6 +23,8 @@ mutation { error attributes orders + _createdAt + _updatedAt } } } diff --git a/docs/examples/1.6.x/server-graphql/examples/databases/update-datetime-attribute.md b/docs/examples/1.6.x/server-graphql/examples/databases/update-datetime-attribute.md index 46d9bbb728..a21b910edc 100644 --- a/docs/examples/1.6.x/server-graphql/examples/databases/update-datetime-attribute.md +++ b/docs/examples/1.6.x/server-graphql/examples/databases/update-datetime-attribute.md @@ -13,6 +13,8 @@ mutation { error required array + _createdAt + _updatedAt format default } diff --git a/docs/examples/1.6.x/server-graphql/examples/databases/update-email-attribute.md b/docs/examples/1.6.x/server-graphql/examples/databases/update-email-attribute.md index e05d365162..6c83d80e16 100644 --- a/docs/examples/1.6.x/server-graphql/examples/databases/update-email-attribute.md +++ b/docs/examples/1.6.x/server-graphql/examples/databases/update-email-attribute.md @@ -13,6 +13,8 @@ mutation { error required array + _createdAt + _updatedAt format default } diff --git a/docs/examples/1.6.x/server-graphql/examples/databases/update-enum-attribute.md b/docs/examples/1.6.x/server-graphql/examples/databases/update-enum-attribute.md index 619cbf817c..378e32f9b8 100644 --- a/docs/examples/1.6.x/server-graphql/examples/databases/update-enum-attribute.md +++ b/docs/examples/1.6.x/server-graphql/examples/databases/update-enum-attribute.md @@ -14,6 +14,8 @@ mutation { error required array + _createdAt + _updatedAt elements format default diff --git a/docs/examples/1.6.x/server-graphql/examples/databases/update-float-attribute.md b/docs/examples/1.6.x/server-graphql/examples/databases/update-float-attribute.md index 7641745a35..c5c7afca44 100644 --- a/docs/examples/1.6.x/server-graphql/examples/databases/update-float-attribute.md +++ b/docs/examples/1.6.x/server-graphql/examples/databases/update-float-attribute.md @@ -15,6 +15,8 @@ mutation { error required array + _createdAt + _updatedAt min max default diff --git a/docs/examples/1.6.x/server-graphql/examples/databases/update-integer-attribute.md b/docs/examples/1.6.x/server-graphql/examples/databases/update-integer-attribute.md index 11b7a66014..e38ccaa88c 100644 --- a/docs/examples/1.6.x/server-graphql/examples/databases/update-integer-attribute.md +++ b/docs/examples/1.6.x/server-graphql/examples/databases/update-integer-attribute.md @@ -15,6 +15,8 @@ mutation { error required array + _createdAt + _updatedAt min max default diff --git a/docs/examples/1.6.x/server-graphql/examples/databases/update-ip-attribute.md b/docs/examples/1.6.x/server-graphql/examples/databases/update-ip-attribute.md index 649fa881b5..7a26224200 100644 --- a/docs/examples/1.6.x/server-graphql/examples/databases/update-ip-attribute.md +++ b/docs/examples/1.6.x/server-graphql/examples/databases/update-ip-attribute.md @@ -13,6 +13,8 @@ mutation { error required array + _createdAt + _updatedAt format default } diff --git a/docs/examples/1.6.x/server-graphql/examples/databases/update-relationship-attribute.md b/docs/examples/1.6.x/server-graphql/examples/databases/update-relationship-attribute.md index 88ba2f9636..6694540d93 100644 --- a/docs/examples/1.6.x/server-graphql/examples/databases/update-relationship-attribute.md +++ b/docs/examples/1.6.x/server-graphql/examples/databases/update-relationship-attribute.md @@ -12,6 +12,8 @@ mutation { error required array + _createdAt + _updatedAt relatedCollection relationType twoWay diff --git a/docs/examples/1.6.x/server-graphql/examples/databases/update-string-attribute.md b/docs/examples/1.6.x/server-graphql/examples/databases/update-string-attribute.md index 4d88462efb..afafb307f5 100644 --- a/docs/examples/1.6.x/server-graphql/examples/databases/update-string-attribute.md +++ b/docs/examples/1.6.x/server-graphql/examples/databases/update-string-attribute.md @@ -5,7 +5,7 @@ mutation { key: "", required: false, default: "<DEFAULT>", - size: 0, + size: 1, newKey: "" ) { key @@ -14,6 +14,8 @@ mutation { error required array + _createdAt + _updatedAt size default } diff --git a/docs/examples/1.6.x/server-graphql/examples/databases/update-url-attribute.md b/docs/examples/1.6.x/server-graphql/examples/databases/update-url-attribute.md index 06838a9ed4..f9f14a04f6 100644 --- a/docs/examples/1.6.x/server-graphql/examples/databases/update-url-attribute.md +++ b/docs/examples/1.6.x/server-graphql/examples/databases/update-url-attribute.md @@ -13,6 +13,8 @@ mutation { error required array + _createdAt + _updatedAt format default } diff --git a/docs/examples/1.6.x/server-graphql/examples/messaging/create-push.md b/docs/examples/1.6.x/server-graphql/examples/messaging/create-push.md index 3084c97635..92264d1b67 100644 --- a/docs/examples/1.6.x/server-graphql/examples/messaging/create-push.md +++ b/docs/examples/1.6.x/server-graphql/examples/messaging/create-push.md @@ -13,9 +13,12 @@ mutation { sound: "<SOUND>", color: "<COLOR>", tag: "<TAG>", - badge: "<BADGE>", + badge: 0, draft: false, - scheduledAt: "" + scheduledAt: "", + contentAvailable: false, + critical: false, + priority: "normal" ) { _id _createdAt diff --git a/docs/examples/1.6.x/server-graphql/examples/messaging/create-subscriber.md b/docs/examples/1.6.x/server-graphql/examples/messaging/create-subscriber.md index b2712ebb48..bab53612b7 100644 --- a/docs/examples/1.6.x/server-graphql/examples/messaging/create-subscriber.md +++ b/docs/examples/1.6.x/server-graphql/examples/messaging/create-subscriber.md @@ -17,6 +17,7 @@ mutation { providerId providerType identifier + expired } userId userName diff --git a/docs/examples/1.6.x/server-graphql/examples/messaging/get-subscriber.md b/docs/examples/1.6.x/server-graphql/examples/messaging/get-subscriber.md index 54096dd70a..2e1672d010 100644 --- a/docs/examples/1.6.x/server-graphql/examples/messaging/get-subscriber.md +++ b/docs/examples/1.6.x/server-graphql/examples/messaging/get-subscriber.md @@ -16,6 +16,7 @@ query { providerId providerType identifier + expired } userId userName diff --git a/docs/examples/1.6.x/server-graphql/examples/messaging/list-subscribers.md b/docs/examples/1.6.x/server-graphql/examples/messaging/list-subscribers.md index 5c48ae34bb..a5a4f91e56 100644 --- a/docs/examples/1.6.x/server-graphql/examples/messaging/list-subscribers.md +++ b/docs/examples/1.6.x/server-graphql/examples/messaging/list-subscribers.md @@ -19,6 +19,7 @@ query { providerId providerType identifier + expired } userId userName diff --git a/docs/examples/1.6.x/server-graphql/examples/messaging/list-targets.md b/docs/examples/1.6.x/server-graphql/examples/messaging/list-targets.md index 8e356dce5f..aa82276de2 100644 --- a/docs/examples/1.6.x/server-graphql/examples/messaging/list-targets.md +++ b/docs/examples/1.6.x/server-graphql/examples/messaging/list-targets.md @@ -13,6 +13,7 @@ query { providerId providerType identifier + expired } } } diff --git a/docs/examples/1.6.x/server-graphql/examples/messaging/update-push.md b/docs/examples/1.6.x/server-graphql/examples/messaging/update-push.md index 9039792573..8ee2f57610 100644 --- a/docs/examples/1.6.x/server-graphql/examples/messaging/update-push.md +++ b/docs/examples/1.6.x/server-graphql/examples/messaging/update-push.md @@ -15,7 +15,10 @@ mutation { tag: "<TAG>", badge: 0, draft: false, - scheduledAt: "" + scheduledAt: "", + contentAvailable: false, + critical: false, + priority: "normal" ) { _id _createdAt diff --git a/docs/examples/1.6.x/server-graphql/examples/users/create-argon2user.md b/docs/examples/1.6.x/server-graphql/examples/users/create-argon2user.md index 464dc754c9..7f99622e52 100644 --- a/docs/examples/1.6.x/server-graphql/examples/users/create-argon2user.md +++ b/docs/examples/1.6.x/server-graphql/examples/users/create-argon2user.md @@ -33,6 +33,7 @@ mutation { providerId providerType identifier + expired } accessedAt } diff --git a/docs/examples/1.6.x/server-graphql/examples/users/create-bcrypt-user.md b/docs/examples/1.6.x/server-graphql/examples/users/create-bcrypt-user.md index 4d4bb09194..26659176eb 100644 --- a/docs/examples/1.6.x/server-graphql/examples/users/create-bcrypt-user.md +++ b/docs/examples/1.6.x/server-graphql/examples/users/create-bcrypt-user.md @@ -33,6 +33,7 @@ mutation { providerId providerType identifier + expired } accessedAt } diff --git a/docs/examples/1.6.x/server-graphql/examples/users/create-m-d5user.md b/docs/examples/1.6.x/server-graphql/examples/users/create-m-d5user.md index e8e833e6de..7e642b8233 100644 --- a/docs/examples/1.6.x/server-graphql/examples/users/create-m-d5user.md +++ b/docs/examples/1.6.x/server-graphql/examples/users/create-m-d5user.md @@ -33,6 +33,7 @@ mutation { providerId providerType identifier + expired } accessedAt } diff --git a/docs/examples/1.6.x/server-graphql/examples/users/create-p-h-pass-user.md b/docs/examples/1.6.x/server-graphql/examples/users/create-p-h-pass-user.md index 53960e7890..4c06b007a2 100644 --- a/docs/examples/1.6.x/server-graphql/examples/users/create-p-h-pass-user.md +++ b/docs/examples/1.6.x/server-graphql/examples/users/create-p-h-pass-user.md @@ -33,6 +33,7 @@ mutation { providerId providerType identifier + expired } accessedAt } diff --git a/docs/examples/1.6.x/server-graphql/examples/users/create-s-h-a-user.md b/docs/examples/1.6.x/server-graphql/examples/users/create-s-h-a-user.md index 17e287f8b3..f99da2752d 100644 --- a/docs/examples/1.6.x/server-graphql/examples/users/create-s-h-a-user.md +++ b/docs/examples/1.6.x/server-graphql/examples/users/create-s-h-a-user.md @@ -34,6 +34,7 @@ mutation { providerId providerType identifier + expired } accessedAt } diff --git a/docs/examples/1.6.x/server-graphql/examples/users/create-scrypt-modified-user.md b/docs/examples/1.6.x/server-graphql/examples/users/create-scrypt-modified-user.md index 6d51fb29ba..624ffcdd38 100644 --- a/docs/examples/1.6.x/server-graphql/examples/users/create-scrypt-modified-user.md +++ b/docs/examples/1.6.x/server-graphql/examples/users/create-scrypt-modified-user.md @@ -36,6 +36,7 @@ mutation { providerId providerType identifier + expired } accessedAt } diff --git a/docs/examples/1.6.x/server-graphql/examples/users/create-scrypt-user.md b/docs/examples/1.6.x/server-graphql/examples/users/create-scrypt-user.md index 0d4bac1db8..68a5f4c75f 100644 --- a/docs/examples/1.6.x/server-graphql/examples/users/create-scrypt-user.md +++ b/docs/examples/1.6.x/server-graphql/examples/users/create-scrypt-user.md @@ -38,6 +38,7 @@ mutation { providerId providerType identifier + expired } accessedAt } diff --git a/docs/examples/1.6.x/server-graphql/examples/users/create-target.md b/docs/examples/1.6.x/server-graphql/examples/users/create-target.md index a3a0696dec..7068c21aba 100644 --- a/docs/examples/1.6.x/server-graphql/examples/users/create-target.md +++ b/docs/examples/1.6.x/server-graphql/examples/users/create-target.md @@ -15,5 +15,6 @@ mutation { providerId providerType identifier + expired } } diff --git a/docs/examples/1.6.x/server-graphql/examples/users/create.md b/docs/examples/1.6.x/server-graphql/examples/users/create.md index 826a5168ef..465da80432 100644 --- a/docs/examples/1.6.x/server-graphql/examples/users/create.md +++ b/docs/examples/1.6.x/server-graphql/examples/users/create.md @@ -34,6 +34,7 @@ mutation { providerId providerType identifier + expired } accessedAt } diff --git a/docs/examples/1.6.x/server-graphql/examples/users/delete-mfa-authenticator.md b/docs/examples/1.6.x/server-graphql/examples/users/delete-mfa-authenticator.md index 227c340c68..26c9594a53 100644 --- a/docs/examples/1.6.x/server-graphql/examples/users/delete-mfa-authenticator.md +++ b/docs/examples/1.6.x/server-graphql/examples/users/delete-mfa-authenticator.md @@ -31,6 +31,7 @@ mutation { providerId providerType identifier + expired } accessedAt } diff --git a/docs/examples/1.6.x/server-graphql/examples/users/get-target.md b/docs/examples/1.6.x/server-graphql/examples/users/get-target.md index e4ba1a04a1..c84f947898 100644 --- a/docs/examples/1.6.x/server-graphql/examples/users/get-target.md +++ b/docs/examples/1.6.x/server-graphql/examples/users/get-target.md @@ -11,5 +11,6 @@ query { providerId providerType identifier + expired } } diff --git a/docs/examples/1.6.x/server-graphql/examples/users/get.md b/docs/examples/1.6.x/server-graphql/examples/users/get.md index f94a5818ed..9d0be685d9 100644 --- a/docs/examples/1.6.x/server-graphql/examples/users/get.md +++ b/docs/examples/1.6.x/server-graphql/examples/users/get.md @@ -30,6 +30,7 @@ query { providerId providerType identifier + expired } accessedAt } diff --git a/docs/examples/1.6.x/server-graphql/examples/users/list-targets.md b/docs/examples/1.6.x/server-graphql/examples/users/list-targets.md index 05e796f167..408fd96f80 100644 --- a/docs/examples/1.6.x/server-graphql/examples/users/list-targets.md +++ b/docs/examples/1.6.x/server-graphql/examples/users/list-targets.md @@ -13,6 +13,7 @@ query { providerId providerType identifier + expired } } } diff --git a/docs/examples/1.6.x/server-graphql/examples/users/list.md b/docs/examples/1.6.x/server-graphql/examples/users/list.md index e2326dd1a2..a90121adf2 100644 --- a/docs/examples/1.6.x/server-graphql/examples/users/list.md +++ b/docs/examples/1.6.x/server-graphql/examples/users/list.md @@ -33,6 +33,7 @@ query { providerId providerType identifier + expired } accessedAt } diff --git a/docs/examples/1.6.x/server-graphql/examples/users/update-email-verification.md b/docs/examples/1.6.x/server-graphql/examples/users/update-email-verification.md index 6bb2781854..cda7278ac0 100644 --- a/docs/examples/1.6.x/server-graphql/examples/users/update-email-verification.md +++ b/docs/examples/1.6.x/server-graphql/examples/users/update-email-verification.md @@ -31,6 +31,7 @@ mutation { providerId providerType identifier + expired } accessedAt } diff --git a/docs/examples/1.6.x/server-graphql/examples/users/update-email.md b/docs/examples/1.6.x/server-graphql/examples/users/update-email.md index 046937ac04..408a74972b 100644 --- a/docs/examples/1.6.x/server-graphql/examples/users/update-email.md +++ b/docs/examples/1.6.x/server-graphql/examples/users/update-email.md @@ -31,6 +31,7 @@ mutation { providerId providerType identifier + expired } accessedAt } diff --git a/docs/examples/1.6.x/server-graphql/examples/users/update-labels.md b/docs/examples/1.6.x/server-graphql/examples/users/update-labels.md index 93da33d805..cb3c5b6483 100644 --- a/docs/examples/1.6.x/server-graphql/examples/users/update-labels.md +++ b/docs/examples/1.6.x/server-graphql/examples/users/update-labels.md @@ -31,6 +31,7 @@ mutation { providerId providerType identifier + expired } accessedAt } diff --git a/docs/examples/1.6.x/server-graphql/examples/users/update-mfa.md b/docs/examples/1.6.x/server-graphql/examples/users/update-mfa.md index 9219aa1aea..ac09ea19a4 100644 --- a/docs/examples/1.6.x/server-graphql/examples/users/update-mfa.md +++ b/docs/examples/1.6.x/server-graphql/examples/users/update-mfa.md @@ -31,6 +31,7 @@ mutation { providerId providerType identifier + expired } accessedAt } diff --git a/docs/examples/1.6.x/server-graphql/examples/users/update-name.md b/docs/examples/1.6.x/server-graphql/examples/users/update-name.md index 01a53ce479..ec7e3dc27c 100644 --- a/docs/examples/1.6.x/server-graphql/examples/users/update-name.md +++ b/docs/examples/1.6.x/server-graphql/examples/users/update-name.md @@ -31,6 +31,7 @@ mutation { providerId providerType identifier + expired } accessedAt } diff --git a/docs/examples/1.6.x/server-graphql/examples/users/update-password.md b/docs/examples/1.6.x/server-graphql/examples/users/update-password.md index c95637c4ce..95ef74c83d 100644 --- a/docs/examples/1.6.x/server-graphql/examples/users/update-password.md +++ b/docs/examples/1.6.x/server-graphql/examples/users/update-password.md @@ -31,6 +31,7 @@ mutation { providerId providerType identifier + expired } accessedAt } diff --git a/docs/examples/1.6.x/server-graphql/examples/users/update-phone-verification.md b/docs/examples/1.6.x/server-graphql/examples/users/update-phone-verification.md index 58343ae365..c6afa54ba4 100644 --- a/docs/examples/1.6.x/server-graphql/examples/users/update-phone-verification.md +++ b/docs/examples/1.6.x/server-graphql/examples/users/update-phone-verification.md @@ -31,6 +31,7 @@ mutation { providerId providerType identifier + expired } accessedAt } diff --git a/docs/examples/1.6.x/server-graphql/examples/users/update-phone.md b/docs/examples/1.6.x/server-graphql/examples/users/update-phone.md index dbcb076c65..d3fc7d5f37 100644 --- a/docs/examples/1.6.x/server-graphql/examples/users/update-phone.md +++ b/docs/examples/1.6.x/server-graphql/examples/users/update-phone.md @@ -31,6 +31,7 @@ mutation { providerId providerType identifier + expired } accessedAt } diff --git a/docs/examples/1.6.x/server-graphql/examples/users/update-status.md b/docs/examples/1.6.x/server-graphql/examples/users/update-status.md index ad05bc75ff..2499c1c258 100644 --- a/docs/examples/1.6.x/server-graphql/examples/users/update-status.md +++ b/docs/examples/1.6.x/server-graphql/examples/users/update-status.md @@ -31,6 +31,7 @@ mutation { providerId providerType identifier + expired } accessedAt } diff --git a/docs/examples/1.6.x/server-graphql/examples/users/update-target.md b/docs/examples/1.6.x/server-graphql/examples/users/update-target.md index fe3444ede7..1f7cc1147a 100644 --- a/docs/examples/1.6.x/server-graphql/examples/users/update-target.md +++ b/docs/examples/1.6.x/server-graphql/examples/users/update-target.md @@ -14,5 +14,6 @@ mutation { providerId providerType identifier + expired } } diff --git a/docs/examples/1.6.x/server-kotlin/java/databases/update-string-attribute.md b/docs/examples/1.6.x/server-kotlin/java/databases/update-string-attribute.md index 75be9e01f8..2d69006181 100644 --- a/docs/examples/1.6.x/server-kotlin/java/databases/update-string-attribute.md +++ b/docs/examples/1.6.x/server-kotlin/java/databases/update-string-attribute.md @@ -15,7 +15,7 @@ databases.updateStringAttribute( "", // key false, // required "<DEFAULT>", // default - 0, // size (optional) + 1, // size (optional) "", // newKey (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/1.6.x/server-kotlin/java/messaging/create-push.md b/docs/examples/1.6.x/server-kotlin/java/messaging/create-push.md index 934f1faaa8..56c7a60795 100644 --- a/docs/examples/1.6.x/server-kotlin/java/messaging/create-push.md +++ b/docs/examples/1.6.x/server-kotlin/java/messaging/create-push.md @@ -11,8 +11,8 @@ Messaging messaging = new Messaging(client); messaging.createPush( "<MESSAGE_ID>", // messageId - "<TITLE>", // title - "<BODY>", // body + "<TITLE>", // title (optional) + "<BODY>", // body (optional) listOf(), // topics (optional) listOf(), // users (optional) listOf(), // targets (optional) @@ -23,9 +23,12 @@ messaging.createPush( "<SOUND>", // sound (optional) "<COLOR>", // color (optional) "<TAG>", // tag (optional) - "<BADGE>", // badge (optional) + 0, // badge (optional) false, // draft (optional) "", // scheduledAt (optional) + false, // contentAvailable (optional) + false, // critical (optional) + MessagePriority.NORMAL, // priority (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/1.6.x/server-kotlin/java/messaging/update-push.md b/docs/examples/1.6.x/server-kotlin/java/messaging/update-push.md index ef04203c37..bb8c3c8c2e 100644 --- a/docs/examples/1.6.x/server-kotlin/java/messaging/update-push.md +++ b/docs/examples/1.6.x/server-kotlin/java/messaging/update-push.md @@ -26,6 +26,9 @@ messaging.updatePush( 0, // badge (optional) false, // draft (optional) "", // scheduledAt (optional) + false, // contentAvailable (optional) + false, // critical (optional) + MessagePriority.NORMAL, // priority (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/1.6.x/server-kotlin/kotlin/databases/update-string-attribute.md b/docs/examples/1.6.x/server-kotlin/kotlin/databases/update-string-attribute.md index a37d4566ee..32e17beb9c 100644 --- a/docs/examples/1.6.x/server-kotlin/kotlin/databases/update-string-attribute.md +++ b/docs/examples/1.6.x/server-kotlin/kotlin/databases/update-string-attribute.md @@ -15,6 +15,6 @@ val response = databases.updateStringAttribute( key = "", required = false, default = "<DEFAULT>", - size = 0, // optional + size = 1, // optional newKey = "" // optional ) diff --git a/docs/examples/1.6.x/server-kotlin/kotlin/messaging/create-push.md b/docs/examples/1.6.x/server-kotlin/kotlin/messaging/create-push.md index 6a95f63992..f92a49d627 100644 --- a/docs/examples/1.6.x/server-kotlin/kotlin/messaging/create-push.md +++ b/docs/examples/1.6.x/server-kotlin/kotlin/messaging/create-push.md @@ -11,8 +11,8 @@ val messaging = Messaging(client) val response = messaging.createPush( messageId = "<MESSAGE_ID>", - title = "<TITLE>", - body = "<BODY>", + title = "<TITLE>", // optional + body = "<BODY>", // optional topics = listOf(), // optional users = listOf(), // optional targets = listOf(), // optional @@ -23,7 +23,10 @@ val response = messaging.createPush( sound = "<SOUND>", // optional color = "<COLOR>", // optional tag = "<TAG>", // optional - badge = "<BADGE>", // optional + badge = 0, // optional draft = false, // optional - scheduledAt = "" // optional + scheduledAt = "", // optional + contentAvailable = false, // optional + critical = false, // optional + priority = "normal" // optional ) diff --git a/docs/examples/1.6.x/server-kotlin/kotlin/messaging/update-push.md b/docs/examples/1.6.x/server-kotlin/kotlin/messaging/update-push.md index d91694e1bc..0ba72c461c 100644 --- a/docs/examples/1.6.x/server-kotlin/kotlin/messaging/update-push.md +++ b/docs/examples/1.6.x/server-kotlin/kotlin/messaging/update-push.md @@ -25,5 +25,8 @@ val response = messaging.updatePush( tag = "<TAG>", // optional badge = 0, // optional draft = false, // optional - scheduledAt = "" // optional + scheduledAt = "", // optional + contentAvailable = false, // optional + critical = false, // optional + priority = "normal" // optional ) diff --git a/docs/examples/1.6.x/server-nodejs/examples/databases/update-string-attribute.md b/docs/examples/1.6.x/server-nodejs/examples/databases/update-string-attribute.md index f379fdc0cf..6aecbb591e 100644 --- a/docs/examples/1.6.x/server-nodejs/examples/databases/update-string-attribute.md +++ b/docs/examples/1.6.x/server-nodejs/examples/databases/update-string-attribute.md @@ -13,6 +13,6 @@ const result = await databases.updateStringAttribute( '', // key false, // required '<DEFAULT>', // default - null, // size (optional) + 1, // size (optional) '' // newKey (optional) ); diff --git a/docs/examples/1.6.x/server-nodejs/examples/messaging/create-push.md b/docs/examples/1.6.x/server-nodejs/examples/messaging/create-push.md index 54103e11f7..bb98538748 100644 --- a/docs/examples/1.6.x/server-nodejs/examples/messaging/create-push.md +++ b/docs/examples/1.6.x/server-nodejs/examples/messaging/create-push.md @@ -9,8 +9,8 @@ const messaging = new sdk.Messaging(client); const result = await messaging.createPush( '<MESSAGE_ID>', // messageId - '<TITLE>', // title - '<BODY>', // body + '<TITLE>', // title (optional) + '<BODY>', // body (optional) [], // topics (optional) [], // users (optional) [], // targets (optional) @@ -21,7 +21,10 @@ const result = await messaging.createPush( '<SOUND>', // sound (optional) '<COLOR>', // color (optional) '<TAG>', // tag (optional) - '<BADGE>', // badge (optional) + null, // badge (optional) false, // draft (optional) - '' // scheduledAt (optional) + '', // scheduledAt (optional) + false, // contentAvailable (optional) + false, // critical (optional) + sdk.MessagePriority.Normal // priority (optional) ); diff --git a/docs/examples/1.6.x/server-nodejs/examples/messaging/update-push.md b/docs/examples/1.6.x/server-nodejs/examples/messaging/update-push.md index ec87ecf7cf..700c3a99de 100644 --- a/docs/examples/1.6.x/server-nodejs/examples/messaging/update-push.md +++ b/docs/examples/1.6.x/server-nodejs/examples/messaging/update-push.md @@ -23,5 +23,8 @@ const result = await messaging.updatePush( '<TAG>', // tag (optional) null, // badge (optional) false, // draft (optional) - '' // scheduledAt (optional) + '', // scheduledAt (optional) + false, // contentAvailable (optional) + false, // critical (optional) + sdk.MessagePriority.Normal // priority (optional) ); diff --git a/docs/examples/1.6.x/server-php/examples/databases/update-string-attribute.md b/docs/examples/1.6.x/server-php/examples/databases/update-string-attribute.md index 9e821e4436..721ba324de 100644 --- a/docs/examples/1.6.x/server-php/examples/databases/update-string-attribute.md +++ b/docs/examples/1.6.x/server-php/examples/databases/update-string-attribute.md @@ -16,6 +16,6 @@ $result = $databases->updateStringAttribute( key: '', required: false, default: '<DEFAULT>', - size: null, // optional + size: 1, // optional newKey: '' // optional ); \ No newline at end of file diff --git a/docs/examples/1.6.x/server-php/examples/messaging/create-push.md b/docs/examples/1.6.x/server-php/examples/messaging/create-push.md index 7838576df0..9aaf6ad4ad 100644 --- a/docs/examples/1.6.x/server-php/examples/messaging/create-push.md +++ b/docs/examples/1.6.x/server-php/examples/messaging/create-push.md @@ -12,8 +12,8 @@ $messaging = new Messaging($client); $result = $messaging->createPush( messageId: '<MESSAGE_ID>', - title: '<TITLE>', - body: '<BODY>', + title: '<TITLE>', // optional + body: '<BODY>', // optional topics: [], // optional users: [], // optional targets: [], // optional @@ -24,7 +24,10 @@ $result = $messaging->createPush( sound: '<SOUND>', // optional color: '<COLOR>', // optional tag: '<TAG>', // optional - badge: '<BADGE>', // optional + badge: null, // optional draft: false, // optional - scheduledAt: '' // optional + scheduledAt: '', // optional + contentAvailable: false, // optional + critical: false, // optional + priority: MessagePriority::NORMAL() // optional ); \ No newline at end of file diff --git a/docs/examples/1.6.x/server-php/examples/messaging/update-push.md b/docs/examples/1.6.x/server-php/examples/messaging/update-push.md index 09a4d96042..7546fc8668 100644 --- a/docs/examples/1.6.x/server-php/examples/messaging/update-push.md +++ b/docs/examples/1.6.x/server-php/examples/messaging/update-push.md @@ -26,5 +26,8 @@ $result = $messaging->updatePush( tag: '<TAG>', // optional badge: null, // optional draft: false, // optional - scheduledAt: '' // optional + scheduledAt: '', // optional + contentAvailable: false, // optional + critical: false, // optional + priority: MessagePriority::NORMAL() // optional ); \ No newline at end of file diff --git a/docs/examples/1.6.x/server-python/examples/databases/update-string-attribute.md b/docs/examples/1.6.x/server-python/examples/databases/update-string-attribute.md index bbe7ddb19f..ab910d9800 100644 --- a/docs/examples/1.6.x/server-python/examples/databases/update-string-attribute.md +++ b/docs/examples/1.6.x/server-python/examples/databases/update-string-attribute.md @@ -13,6 +13,6 @@ result = databases.update_string_attribute( key = '', required = False, default = '<DEFAULT>', - size = None, # optional + size = 1, # optional new_key = '' # optional ) diff --git a/docs/examples/1.6.x/server-python/examples/messaging/create-push.md b/docs/examples/1.6.x/server-python/examples/messaging/create-push.md index ffed825a3d..616b945d33 100644 --- a/docs/examples/1.6.x/server-python/examples/messaging/create-push.md +++ b/docs/examples/1.6.x/server-python/examples/messaging/create-push.md @@ -9,8 +9,8 @@ messaging = Messaging(client) result = messaging.create_push( message_id = '<MESSAGE_ID>', - title = '<TITLE>', - body = '<BODY>', + title = '<TITLE>', # optional + body = '<BODY>', # optional topics = [], # optional users = [], # optional targets = [], # optional @@ -21,7 +21,10 @@ result = messaging.create_push( sound = '<SOUND>', # optional color = '<COLOR>', # optional tag = '<TAG>', # optional - badge = '<BADGE>', # optional + badge = None, # optional draft = False, # optional - scheduled_at = '' # optional + scheduled_at = '', # optional + content_available = False, # optional + critical = False, # optional + priority = MessagePriority.NORMAL # optional ) diff --git a/docs/examples/1.6.x/server-python/examples/messaging/update-push.md b/docs/examples/1.6.x/server-python/examples/messaging/update-push.md index 3c3965c3bd..f5bdf155e6 100644 --- a/docs/examples/1.6.x/server-python/examples/messaging/update-push.md +++ b/docs/examples/1.6.x/server-python/examples/messaging/update-push.md @@ -23,5 +23,8 @@ result = messaging.update_push( tag = '<TAG>', # optional badge = None, # optional draft = False, # optional - scheduled_at = '' # optional + scheduled_at = '', # optional + content_available = False, # optional + critical = False, # optional + priority = MessagePriority.NORMAL # optional ) diff --git a/docs/examples/1.6.x/server-rest/examples/databases/update-string-attribute.md b/docs/examples/1.6.x/server-rest/examples/databases/update-string-attribute.md index 197ea2767d..71a5302e1a 100644 --- a/docs/examples/1.6.x/server-rest/examples/databases/update-string-attribute.md +++ b/docs/examples/1.6.x/server-rest/examples/databases/update-string-attribute.md @@ -8,6 +8,6 @@ X-Appwrite-Key: <YOUR_API_KEY> { "required": false, "default": "<DEFAULT>", - "size": 0, + "size": 1, "newKey": } diff --git a/docs/examples/1.6.x/server-rest/examples/messaging/create-push.md b/docs/examples/1.6.x/server-rest/examples/messaging/create-push.md index 1c7550950b..cf5256d921 100644 --- a/docs/examples/1.6.x/server-rest/examples/messaging/create-push.md +++ b/docs/examples/1.6.x/server-rest/examples/messaging/create-push.md @@ -19,7 +19,10 @@ X-Appwrite-Key: <YOUR_API_KEY> "sound": "<SOUND>", "color": "<COLOR>", "tag": "<TAG>", - "badge": "<BADGE>", + "badge": 0, "draft": false, - "scheduledAt": + "scheduledAt": , + "contentAvailable": false, + "critical": false, + "priority": "normal" } diff --git a/docs/examples/1.6.x/server-rest/examples/messaging/update-push.md b/docs/examples/1.6.x/server-rest/examples/messaging/update-push.md index 7a0338c74b..2159bc8aa2 100644 --- a/docs/examples/1.6.x/server-rest/examples/messaging/update-push.md +++ b/docs/examples/1.6.x/server-rest/examples/messaging/update-push.md @@ -20,5 +20,8 @@ X-Appwrite-Key: <YOUR_API_KEY> "tag": "<TAG>", "badge": 0, "draft": false, - "scheduledAt": + "scheduledAt": , + "contentAvailable": false, + "critical": false, + "priority": "normal" } diff --git a/docs/examples/1.6.x/server-ruby/examples/databases/update-string-attribute.md b/docs/examples/1.6.x/server-ruby/examples/databases/update-string-attribute.md index 3b3c5eb644..5e4ac573dc 100644 --- a/docs/examples/1.6.x/server-ruby/examples/databases/update-string-attribute.md +++ b/docs/examples/1.6.x/server-ruby/examples/databases/update-string-attribute.md @@ -15,6 +15,6 @@ result = databases.update_string_attribute( key: '', required: false, default: '<DEFAULT>', - size: null, # optional + size: 1, # optional new_key: '' # optional ) diff --git a/docs/examples/1.6.x/server-ruby/examples/messaging/create-push.md b/docs/examples/1.6.x/server-ruby/examples/messaging/create-push.md index 1c6700db43..61663f4dc0 100644 --- a/docs/examples/1.6.x/server-ruby/examples/messaging/create-push.md +++ b/docs/examples/1.6.x/server-ruby/examples/messaging/create-push.md @@ -11,8 +11,8 @@ messaging = Messaging.new(client) result = messaging.create_push( message_id: '<MESSAGE_ID>', - title: '<TITLE>', - body: '<BODY>', + title: '<TITLE>', # optional + body: '<BODY>', # optional topics: [], # optional users: [], # optional targets: [], # optional @@ -23,7 +23,10 @@ result = messaging.create_push( sound: '<SOUND>', # optional color: '<COLOR>', # optional tag: '<TAG>', # optional - badge: '<BADGE>', # optional + badge: null, # optional draft: false, # optional - scheduled_at: '' # optional + scheduled_at: '', # optional + content_available: false, # optional + critical: false, # optional + priority: MessagePriority::NORMAL # optional ) diff --git a/docs/examples/1.6.x/server-ruby/examples/messaging/update-push.md b/docs/examples/1.6.x/server-ruby/examples/messaging/update-push.md index 54f6368eee..6bf9fcaa79 100644 --- a/docs/examples/1.6.x/server-ruby/examples/messaging/update-push.md +++ b/docs/examples/1.6.x/server-ruby/examples/messaging/update-push.md @@ -25,5 +25,8 @@ result = messaging.update_push( tag: '<TAG>', # optional badge: null, # optional draft: false, # optional - scheduled_at: '' # optional + scheduled_at: '', # optional + content_available: false, # optional + critical: false, # optional + priority: MessagePriority::NORMAL # optional ) diff --git a/docs/examples/1.6.x/server-swift/examples/databases/update-string-attribute.md b/docs/examples/1.6.x/server-swift/examples/databases/update-string-attribute.md index 5fafd5e72e..d3129dcce2 100644 --- a/docs/examples/1.6.x/server-swift/examples/databases/update-string-attribute.md +++ b/docs/examples/1.6.x/server-swift/examples/databases/update-string-attribute.md @@ -13,7 +13,7 @@ let attributeString = try await databases.updateStringAttribute( key: "", required: false, default: "<DEFAULT>", - size: 0, // optional + size: 1, // optional newKey: "" // optional ) diff --git a/docs/examples/1.6.x/server-swift/examples/messaging/create-push.md b/docs/examples/1.6.x/server-swift/examples/messaging/create-push.md index dbc7bf0ca6..42f48ddd2e 100644 --- a/docs/examples/1.6.x/server-swift/examples/messaging/create-push.md +++ b/docs/examples/1.6.x/server-swift/examples/messaging/create-push.md @@ -1,4 +1,5 @@ import Appwrite +import AppwriteEnums let client = Client() .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -9,8 +10,8 @@ let messaging = Messaging(client) let message = try await messaging.createPush( messageId: "<MESSAGE_ID>", - title: "<TITLE>", - body: "<BODY>", + title: "<TITLE>", // optional + body: "<BODY>", // optional topics: [], // optional users: [], // optional targets: [], // optional @@ -21,8 +22,11 @@ let message = try await messaging.createPush( sound: "<SOUND>", // optional color: "<COLOR>", // optional tag: "<TAG>", // optional - badge: "<BADGE>", // optional + badge: 0, // optional draft: false, // optional - scheduledAt: "" // optional + scheduledAt: "", // optional + contentAvailable: false, // optional + critical: false, // optional + priority: .normal // optional ) diff --git a/docs/examples/1.6.x/server-swift/examples/messaging/update-push.md b/docs/examples/1.6.x/server-swift/examples/messaging/update-push.md index 40ce34bf66..02893a180a 100644 --- a/docs/examples/1.6.x/server-swift/examples/messaging/update-push.md +++ b/docs/examples/1.6.x/server-swift/examples/messaging/update-push.md @@ -1,4 +1,5 @@ import Appwrite +import AppwriteEnums let client = Client() .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -23,6 +24,9 @@ let message = try await messaging.updatePush( tag: "<TAG>", // optional badge: 0, // optional draft: false, // optional - scheduledAt: "" // optional + scheduledAt: "", // optional + contentAvailable: false, // optional + critical: false, // optional + priority: .normal // optional ) From 4ce919c8c6ffcf55af196637399c4e1b90cc239e Mon Sep 17 00:00:00 2001 From: Steven Nguyen <1477010+stnguyen90@users.noreply.github.com> Date: Tue, 31 Dec 2024 23:11:00 +0000 Subject: [PATCH 22/47] chore: update composer.lock after merge --- composer.lock | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/composer.lock b/composer.lock index 361dfe4c84..aad4e039fa 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "6b136b5490c0d5d331eac0d70bb3e198", + "content-hash": "4ce4526b10d26830d8f9eaf55e40135c", "packages": [ { "name": "adhocore/jwt", @@ -2453,16 +2453,16 @@ }, { "name": "symfony/http-client", - "version": "v7.2.1", + "version": "v7.2.2", "source": { "type": "git", "url": "https://github.com/symfony/http-client.git", - "reference": "ff4df2b68d1c67abb9fef146e6540ea16b58d99e" + "reference": "339ba21476eb184290361542f732ad12c97591ec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-client/zipball/ff4df2b68d1c67abb9fef146e6540ea16b58d99e", - "reference": "ff4df2b68d1c67abb9fef146e6540ea16b58d99e", + "url": "https://api.github.com/repos/symfony/http-client/zipball/339ba21476eb184290361542f732ad12c97591ec", + "reference": "339ba21476eb184290361542f732ad12c97591ec", "shasum": "" }, "require": { @@ -2528,7 +2528,7 @@ "http" ], "support": { - "source": "https://github.com/symfony/http-client/tree/v7.2.1" + "source": "https://github.com/symfony/http-client/tree/v7.2.2" }, "funding": [ { @@ -2544,7 +2544,7 @@ "type": "tidelift" } ], - "time": "2024-12-07T08:50:44+00:00" + "time": "2024-12-30T18:35:15+00:00" }, { "name": "symfony/http-client-contracts", @@ -5126,16 +5126,16 @@ }, { "name": "laravel/pint", - "version": "v1.18.3", + "version": "v1.19.0", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "cef51821608239040ab841ad6e1c6ae502ae3026" + "reference": "8169513746e1bac70c85d6ea1524d9225d4886f0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/cef51821608239040ab841ad6e1c6ae502ae3026", - "reference": "cef51821608239040ab841ad6e1c6ae502ae3026", + "url": "https://api.github.com/repos/laravel/pint/zipball/8169513746e1bac70c85d6ea1524d9225d4886f0", + "reference": "8169513746e1bac70c85d6ea1524d9225d4886f0", "shasum": "" }, "require": { @@ -5146,10 +5146,10 @@ "php": "^8.1.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.65.0", - "illuminate/view": "^10.48.24", - "larastan/larastan": "^2.9.11", - "laravel-zero/framework": "^10.4.0", + "friendsofphp/php-cs-fixer": "^3.66.0", + "illuminate/view": "^10.48.25", + "larastan/larastan": "^2.9.12", + "laravel-zero/framework": "^10.48.25", "mockery/mockery": "^1.6.12", "nunomaduro/termwind": "^1.17.0", "pestphp/pest": "^2.36.0" @@ -5188,7 +5188,7 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2024-11-26T15:34:00+00:00" + "time": "2024-12-30T16:20:10+00:00" }, { "name": "matthiasmullie/minify", @@ -7735,16 +7735,16 @@ }, { "name": "symfony/finder", - "version": "v7.2.0", + "version": "v7.2.2", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "6de263e5868b9a137602dd1e33e4d48bfae99c49" + "reference": "87a71856f2f56e4100373e92529eed3171695cfb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/6de263e5868b9a137602dd1e33e4d48bfae99c49", - "reference": "6de263e5868b9a137602dd1e33e4d48bfae99c49", + "url": "https://api.github.com/repos/symfony/finder/zipball/87a71856f2f56e4100373e92529eed3171695cfb", + "reference": "87a71856f2f56e4100373e92529eed3171695cfb", "shasum": "" }, "require": { @@ -7779,7 +7779,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v7.2.0" + "source": "https://github.com/symfony/finder/tree/v7.2.2" }, "funding": [ { @@ -7795,7 +7795,7 @@ "type": "tidelift" } ], - "time": "2024-10-23T06:56:12+00:00" + "time": "2024-12-30T19:00:17+00:00" }, { "name": "symfony/options-resolver", @@ -8556,7 +8556,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": {}, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { From e1c08e33d402c13718caeb612778b99bd102cf4c Mon Sep 17 00:00:00 2001 From: Christy Jacob <christyjacob4@gmail.com> Date: Sat, 4 Jan 2025 12:51:42 +0530 Subject: [PATCH 23/47] fix: trigger webhooks events only if a project has webhooks --- app/controllers/shared/api.php | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 012dd13c73..5c1251da08 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -58,7 +58,7 @@ $parseLabel = function (string $label, array $responsePayload, array $requestPar return $label; }; -$eventDatabaseListener = function (Document $document, Response $response, Event $queueForEvents, Func $queueForFunctions, Webhook $queueForWebhooks, Realtime $queueForRealtime) { +$eventDatabaseListener = function (Document $project,Document $document, Response $response, Event $queueForEvents, Func $queueForFunctions, Webhook $queueForWebhooks, Realtime $queueForRealtime) { // Only trigger events for user creation with the database listener. if ($document->getCollection() !== 'users') { return; @@ -74,17 +74,20 @@ $eventDatabaseListener = function (Document $document, Response $response, Event ->from($queueForEvents) ->trigger(); - $queueForWebhooks - ->from($queueForEvents) - ->trigger(); - if ($queueForEvents->getProject()->getId() === 'console') { - return; + /** Trigger webhooks events only if a project has them enabled */ + if ($project->getAttribute('webhooks', []) !== []) { + $queueForWebhooks + ->from($queueForEvents) + ->trigger(); } - $queueForRealtime - ->from($queueForEvents) - ->trigger(); + /** Trigger realtime events only for non console events */ + if ($queueForEvents->getProject()->getId() !== 'console') { + $queueForRealtime + ->from($queueForEvents) + ->trigger(); + } }; $usageDatabaseListener = function (string $event, Document $document, Usage $queueForUsage) { @@ -526,6 +529,7 @@ App::init() ->on(Database::EVENT_DOCUMENT_CREATE, 'calculate-usage', fn ($event, $document) => $usageDatabaseListener($event, $document, $queueForUsage)) ->on(Database::EVENT_DOCUMENT_DELETE, 'calculate-usage', fn ($event, $document) => $usageDatabaseListener($event, $document, $queueForUsage)) ->on(Database::EVENT_DOCUMENT_CREATE, 'create-trigger-events', fn ($event, $document) => $eventDatabaseListener( + $project, $document, $response, $queueForEventsClone->from($queueForEvents), @@ -678,10 +682,6 @@ App::shutdown() $queueForEvents->setPayload($responsePayload); } - $queueForWebhooks - ->from($queueForEvents) - ->trigger(); - $queueForFunctions ->from($queueForEvents) ->trigger(); @@ -691,6 +691,13 @@ App::shutdown() ->from($queueForEvents) ->trigger(); } + + /** Trigger webhooks events only if a project has them enabled */ + if ($project->getAttribute('webhooks', []) !== []) { + $queueForWebhooks + ->from($queueForEvents) + ->trigger(); + } } $route = $utopia->getRoute(); From 56af9d09913502729548f27b3981eb2251be2191 Mon Sep 17 00:00:00 2001 From: Christy Jacob <christyjacob4@gmail.com> Date: Sat, 4 Jan 2025 12:51:50 +0530 Subject: [PATCH 24/47] chore: add todo --- app/controllers/shared/api.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 5c1251da08..38755b9bfb 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -692,7 +692,11 @@ App::shutdown() ->trigger(); } - /** Trigger webhooks events only if a project has them enabled */ + /** Trigger webhooks events only if a project has them enabled + * A future optimisation is to only trigger webhooks if the webhook is "enabled" + * But it might have performance implications on the API due to the number of webhooks etc. + * Some profiling is needed to see if this is a problem. + */ if ($project->getAttribute('webhooks', []) !== []) { $queueForWebhooks ->from($queueForEvents) From bdb6599087e05cac48e3a5a3395ce7d991069fb3 Mon Sep 17 00:00:00 2001 From: Christy Jacob <christyjacob4@gmail.com> Date: Sat, 4 Jan 2025 12:55:20 +0530 Subject: [PATCH 25/47] chore: linter --- app/controllers/shared/api.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 38755b9bfb..592c7b8a49 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -58,7 +58,7 @@ $parseLabel = function (string $label, array $responsePayload, array $requestPar return $label; }; -$eventDatabaseListener = function (Document $project,Document $document, Response $response, Event $queueForEvents, Func $queueForFunctions, Webhook $queueForWebhooks, Realtime $queueForRealtime) { +$eventDatabaseListener = function (Document $project, Document $document, Response $response, Event $queueForEvents, Func $queueForFunctions, Webhook $queueForWebhooks, Realtime $queueForRealtime) { // Only trigger events for user creation with the database listener. if ($document->getCollection() !== 'users') { return; @@ -692,7 +692,7 @@ App::shutdown() ->trigger(); } - /** Trigger webhooks events only if a project has them enabled + /** Trigger webhooks events only if a project has them enabled * A future optimisation is to only trigger webhooks if the webhook is "enabled" * But it might have performance implications on the API due to the number of webhooks etc. * Some profiling is needed to see if this is a problem. From a7f40708a396a6e76b2331b82790f3928b837b46 Mon Sep 17 00:00:00 2001 From: Jake Barnby <jakeb994@gmail.com> Date: Wed, 15 Jan 2025 15:20:15 +1300 Subject: [PATCH 26/47] Update lock --- composer.lock | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/composer.lock b/composer.lock index a4bffa3416..4db1b5b4e7 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "4ce4526b10d26830d8f9eaf55e40135c", + "content-hash": "f80fb401ae4c587e1f79daa5f6215329", "packages": [ { "name": "adhocore/jwt", @@ -4095,16 +4095,16 @@ }, { "name": "utopia-php/platform", - "version": "0.7.1", + "version": "0.7.2", "source": { "type": "git", "url": "https://github.com/utopia-php/platform.git", - "reference": "3433a0f1a54988f2a59c735f507745cb2c24638a" + "reference": "a67772f8be70f75fa60bab49c38c95048f4dc8cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/platform/zipball/3433a0f1a54988f2a59c735f507745cb2c24638a", - "reference": "3433a0f1a54988f2a59c735f507745cb2c24638a", + "url": "https://api.github.com/repos/utopia-php/platform/zipball/a67772f8be70f75fa60bab49c38c95048f4dc8cf", + "reference": "a67772f8be70f75fa60bab49c38c95048f4dc8cf", "shasum": "" }, "require": { @@ -4139,9 +4139,9 @@ ], "support": { "issues": "https://github.com/utopia-php/platform/issues", - "source": "https://github.com/utopia-php/platform/tree/0.7.1" + "source": "https://github.com/utopia-php/platform/tree/0.7.2" }, - "time": "2024-10-22T10:27:49+00:00" + "time": "2025-01-14T08:23:27+00:00" }, { "name": "utopia-php/pools", @@ -5126,16 +5126,16 @@ }, { "name": "laravel/pint", - "version": "v1.19.0", + "version": "v1.20.0", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "8169513746e1bac70c85d6ea1524d9225d4886f0" + "reference": "53072e8ea22213a7ed168a8a15b96fbb8b82d44b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/8169513746e1bac70c85d6ea1524d9225d4886f0", - "reference": "8169513746e1bac70c85d6ea1524d9225d4886f0", + "url": "https://api.github.com/repos/laravel/pint/zipball/53072e8ea22213a7ed168a8a15b96fbb8b82d44b", + "reference": "53072e8ea22213a7ed168a8a15b96fbb8b82d44b", "shasum": "" }, "require": { @@ -5188,7 +5188,7 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2024-12-30T16:20:10+00:00" + "time": "2025-01-14T16:20:53+00:00" }, { "name": "matthiasmullie/minify", @@ -8556,7 +8556,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, "platform": { From c0a0f1016ec1c22ba8a76b9c45f8ab57d2197d7d Mon Sep 17 00:00:00 2001 From: Jake Barnby <jakeb994@gmail.com> Date: Wed, 15 Jan 2025 18:36:30 +1300 Subject: [PATCH 27/47] Revert platform update --- composer.json | 2 +- composer.lock | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 5f354dff39..4e1b5a98a2 100644 --- a/composer.json +++ b/composer.json @@ -62,7 +62,7 @@ "utopia-php/messaging": "0.13.*", "utopia-php/migration": "0.6.*", "utopia-php/orchestration": "0.9.*", - "utopia-php/platform": "0.7.*", + "utopia-php/platform": "0.7.1", "utopia-php/pools": "0.5.*", "utopia-php/preloader": "0.2.*", "utopia-php/queue": "0.7.*", diff --git a/composer.lock b/composer.lock index 4db1b5b4e7..68dbc191bf 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f80fb401ae4c587e1f79daa5f6215329", + "content-hash": "3853435a659889e86c16764046950bed", "packages": [ { "name": "adhocore/jwt", @@ -4095,16 +4095,16 @@ }, { "name": "utopia-php/platform", - "version": "0.7.2", + "version": "0.7.1", "source": { "type": "git", "url": "https://github.com/utopia-php/platform.git", - "reference": "a67772f8be70f75fa60bab49c38c95048f4dc8cf" + "reference": "3433a0f1a54988f2a59c735f507745cb2c24638a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/platform/zipball/a67772f8be70f75fa60bab49c38c95048f4dc8cf", - "reference": "a67772f8be70f75fa60bab49c38c95048f4dc8cf", + "url": "https://api.github.com/repos/utopia-php/platform/zipball/3433a0f1a54988f2a59c735f507745cb2c24638a", + "reference": "3433a0f1a54988f2a59c735f507745cb2c24638a", "shasum": "" }, "require": { @@ -4139,9 +4139,9 @@ ], "support": { "issues": "https://github.com/utopia-php/platform/issues", - "source": "https://github.com/utopia-php/platform/tree/0.7.2" + "source": "https://github.com/utopia-php/platform/tree/0.7.1" }, - "time": "2025-01-14T08:23:27+00:00" + "time": "2024-10-22T10:27:49+00:00" }, { "name": "utopia-php/pools", From b16b662a21c3b4c11d19f8034c2e513bc4cbfe41 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Wed, 15 Jan 2025 14:53:38 +0000 Subject: [PATCH 28/47] debug: log usage --- src/Appwrite/Event/Usage.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Appwrite/Event/Usage.php b/src/Appwrite/Event/Usage.php index 89e900d2ab..a09b651da8 100644 --- a/src/Appwrite/Event/Usage.php +++ b/src/Appwrite/Event/Usage.php @@ -2,6 +2,7 @@ namespace Appwrite\Event; +use Utopia\CLI\Console; use Utopia\Database\Document; use Utopia\Queue\Client; use Utopia\Queue\Connection; @@ -62,6 +63,11 @@ class Usage extends Event return false; } + Console::log('------------------------'); + Console::log('Usage Event Triggered'); + Console::log('Metrics: ' . json_encode($this->metrics, JSON_PRETTY_PRINT)); + Console::log('------------------------'); + $client = new Client($this->queue, $this->connection); $result = $client->enqueue([ From de6fced412c8451d9ee2f2aaf1315cbb50f63a32 Mon Sep 17 00:00:00 2001 From: Christy Jacob <christyjacob4@gmail.com> Date: Thu, 16 Jan 2025 11:35:22 +0530 Subject: [PATCH 29/47] feat: optimise events payloads --- composer.lock | 32 ++++++++++---------- src/Appwrite/Event/Event.php | 5 ++- src/Appwrite/Event/Webhook.php | 6 +--- src/Appwrite/Platform/Workers/Builds.php | 7 +++-- src/Appwrite/Platform/Workers/Databases.php | 7 +++-- src/Appwrite/Platform/Workers/Deletes.php | 8 ++--- src/Appwrite/Platform/Workers/Messaging.php | 6 ++-- src/Appwrite/Platform/Workers/Migrations.php | 6 ++-- src/Appwrite/Platform/Workers/Usage.php | 10 +++--- src/Appwrite/Platform/Workers/UsageDump.php | 17 +---------- src/Appwrite/Platform/Workers/Webhooks.php | 8 ++--- 11 files changed, 50 insertions(+), 62 deletions(-) diff --git a/composer.lock b/composer.lock index b77915f0a4..e5c79ee1dc 100644 --- a/composer.lock +++ b/composer.lock @@ -1430,16 +1430,16 @@ }, { "name": "open-telemetry/gen-otlp-protobuf", - "version": "1.2.1", + "version": "1.5.0", "source": { "type": "git", "url": "https://github.com/opentelemetry-php/gen-otlp-protobuf.git", - "reference": "66c3b98e998a726691c92e6405a82e6e7b8b169d" + "reference": "585bafddd4ae6565de154610b10a787a455c9ba0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/opentelemetry-php/gen-otlp-protobuf/zipball/66c3b98e998a726691c92e6405a82e6e7b8b169d", - "reference": "66c3b98e998a726691c92e6405a82e6e7b8b169d", + "url": "https://api.github.com/repos/opentelemetry-php/gen-otlp-protobuf/zipball/585bafddd4ae6565de154610b10a787a455c9ba0", + "reference": "585bafddd4ae6565de154610b10a787a455c9ba0", "shasum": "" }, "require": { @@ -1489,7 +1489,7 @@ "issues": "https://github.com/open-telemetry/opentelemetry-php/issues", "source": "https://github.com/open-telemetry/opentelemetry-php" }, - "time": "2024-10-30T11:49:49+00:00" + "time": "2025-01-15T23:07:07+00:00" }, { "name": "open-telemetry/sdk", @@ -4095,16 +4095,16 @@ }, { "name": "utopia-php/platform", - "version": "0.7.1", + "version": "0.7.2", "source": { "type": "git", "url": "https://github.com/utopia-php/platform.git", - "reference": "3433a0f1a54988f2a59c735f507745cb2c24638a" + "reference": "6f9243848f1c6466f6509fd01c7e18306a6d8caf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/platform/zipball/3433a0f1a54988f2a59c735f507745cb2c24638a", - "reference": "3433a0f1a54988f2a59c735f507745cb2c24638a", + "url": "https://api.github.com/repos/utopia-php/platform/zipball/6f9243848f1c6466f6509fd01c7e18306a6d8caf", + "reference": "6f9243848f1c6466f6509fd01c7e18306a6d8caf", "shasum": "" }, "require": { @@ -4139,9 +4139,9 @@ ], "support": { "issues": "https://github.com/utopia-php/platform/issues", - "source": "https://github.com/utopia-php/platform/tree/0.7.1" + "source": "https://github.com/utopia-php/platform/tree/0.7.2" }, - "time": "2024-10-22T10:27:49+00:00" + "time": "2025-01-15T05:56:26+00:00" }, { "name": "utopia-php/pools", @@ -5126,16 +5126,16 @@ }, { "name": "laravel/pint", - "version": "v1.19.0", + "version": "v1.20.0", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "8169513746e1bac70c85d6ea1524d9225d4886f0" + "reference": "53072e8ea22213a7ed168a8a15b96fbb8b82d44b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/8169513746e1bac70c85d6ea1524d9225d4886f0", - "reference": "8169513746e1bac70c85d6ea1524d9225d4886f0", + "url": "https://api.github.com/repos/laravel/pint/zipball/53072e8ea22213a7ed168a8a15b96fbb8b82d44b", + "reference": "53072e8ea22213a7ed168a8a15b96fbb8b82d44b", "shasum": "" }, "require": { @@ -5188,7 +5188,7 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2024-12-30T16:20:10+00:00" + "time": "2025-01-14T16:20:53+00:00" }, { "name": "matthiasmullie/minify", diff --git a/src/Appwrite/Event/Event.php b/src/Appwrite/Event/Event.php index e3a2e394cf..a830fd66b1 100644 --- a/src/Appwrite/Event/Event.php +++ b/src/Appwrite/Event/Event.php @@ -136,7 +136,10 @@ class Event */ public function setProject(Document $project): self { - $this->project = $project; + $this->project = new Document([ + '$id' => $project->getId(), + '$internalId' => $project->getInternalId() + ]); return $this; } diff --git a/src/Appwrite/Event/Webhook.php b/src/Appwrite/Event/Webhook.php index 36c6923cae..052d8f0fb9 100644 --- a/src/Appwrite/Event/Webhook.php +++ b/src/Appwrite/Event/Webhook.php @@ -20,11 +20,7 @@ class Webhook extends Event { /** Filter out context and trim project to keep the payload small */ $this->context = []; - $this->project = new Document([ - '$id' => $this->project->getId(), - '$internalId' => $this->project->getInternalId(), - ]); - + return parent::trigger(); } } diff --git a/src/Appwrite/Platform/Workers/Builds.php b/src/Appwrite/Platform/Workers/Builds.php index bef78a7514..4f5d6eb694 100644 --- a/src/Appwrite/Platform/Workers/Builds.php +++ b/src/Appwrite/Platform/Workers/Builds.php @@ -46,6 +46,7 @@ class Builds extends Action $this ->desc('Builds worker') ->inject('message') + ->inject('project') ->inject('dbForPlatform') ->inject('queueForEvents') ->inject('queueForFunctions') @@ -54,11 +55,12 @@ class Builds extends Action ->inject('dbForProject') ->inject('deviceForFunctions') ->inject('log') - ->callback(fn ($message, Database $dbForPlatform, Event $queueForEvents, Func $queueForFunctions, Usage $usage, Cache $cache, Database $dbForProject, Device $deviceForFunctions, Log $log) => $this->action($message, $dbForPlatform, $queueForEvents, $queueForFunctions, $usage, $cache, $dbForProject, $deviceForFunctions, $log)); + ->callback(fn ($message, Document $project, Database $dbForPlatform, Event $queueForEvents, Func $queueForFunctions, Usage $usage, Cache $cache, Database $dbForProject, Device $deviceForFunctions, Log $log) => $this->action($message, $project, $dbForPlatform, $queueForEvents, $queueForFunctions, $usage, $cache, $dbForProject, $deviceForFunctions, $log)); } /** * @param Message $message + * @param Document $project * @param Database $dbForPlatform * @param Event $queueForEvents * @param Func $queueForFunctions @@ -70,7 +72,7 @@ class Builds extends Action * @return void * @throws \Utopia\Database\Exception */ - public function action(Message $message, Database $dbForPlatform, Event $queueForEvents, Func $queueForFunctions, Usage $queueForUsage, Cache $cache, Database $dbForProject, Device $deviceForFunctions, Log $log): void + public function action(Message $message, Document $project, Database $dbForPlatform, Event $queueForEvents, Func $queueForFunctions, Usage $queueForUsage, Cache $cache, Database $dbForProject, Device $deviceForFunctions, Log $log): void { $payload = $message->getPayload() ?? []; @@ -79,7 +81,6 @@ class Builds extends Action } $type = $payload['type'] ?? ''; - $project = new Document($payload['project'] ?? []); $resource = new Document($payload['resource'] ?? []); $deployment = new Document($payload['deployment'] ?? []); $template = new Document($payload['template'] ?? []); diff --git a/src/Appwrite/Platform/Workers/Databases.php b/src/Appwrite/Platform/Workers/Databases.php index 5b73e6a75c..9345f31165 100644 --- a/src/Appwrite/Platform/Workers/Databases.php +++ b/src/Appwrite/Platform/Workers/Databases.php @@ -34,21 +34,23 @@ class Databases extends Action $this ->desc('Databases worker') ->inject('message') + ->inject('project') ->inject('dbForPlatform') ->inject('dbForProject') ->inject('log') - ->callback(fn (Message $message, Database $dbForPlatform, Database $dbForProject, Log $log) => $this->action($message, $dbForPlatform, $dbForProject, $log)); + ->callback(fn (Message $message, Document $project, Database $dbForPlatform, Database $dbForProject, Log $log) => $this->action($message, $project, $dbForPlatform, $dbForProject, $log)); } /** * @param Message $message + * @param Document $project * @param Database $dbForPlatform * @param Database $dbForProject * @param Log $log * @return void * @throws \Exception */ - public function action(Message $message, Database $dbForPlatform, Database $dbForProject, Log $log): void + public function action(Message $message, Document $project, Database $dbForPlatform, Database $dbForProject, Log $log): void { $payload = $message->getPayload() ?? []; @@ -57,7 +59,6 @@ class Databases extends Action } $type = $payload['type']; - $project = new Document($payload['project']); $collection = new Document($payload['collection'] ?? []); $document = new Document($payload['document'] ?? []); $database = new Document($payload['database'] ?? []); diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index 9aaf19f412..35ee50c791 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -43,6 +43,7 @@ class Deletes extends Action $this ->desc('Deletes worker') ->inject('message') + ->inject('project') ->inject('dbForPlatform') ->inject('getProjectDB') ->inject('timelimit') @@ -55,8 +56,8 @@ class Deletes extends Action ->inject('auditRetention') ->inject('log') ->callback( - fn ($message, $dbForPlatform, callable $getProjectDB, callable $timelimit, Device $deviceForFiles, Device $deviceForFunctions, Device $deviceForBuilds, Device $deviceForCache, CertificatesAdapter $certificates, string $executionRetention, string $auditRetention, Log $log) => - $this->action($message, $dbForPlatform, $getProjectDB, $timelimit, $deviceForFiles, $deviceForFunctions, $deviceForBuilds, $deviceForCache, $certificates, $executionRetention, $auditRetention, $log) + fn ($message, Document $project, Database $dbForPlatform, callable $getProjectDB, callable $timelimit, Device $deviceForFiles, Device $deviceForFunctions, Device $deviceForBuilds, Device $deviceForCache, CertificatesAdapter $certificates, string $executionRetention, string $auditRetention, Log $log) => + $this->action($message, $project, $dbForPlatform, $getProjectDB, $timelimit, $deviceForFiles, $deviceForFunctions, $deviceForBuilds, $deviceForCache, $certificates, $executionRetention, $auditRetention, $log) ); } @@ -64,7 +65,7 @@ class Deletes extends Action * @throws Exception * @throws Throwable */ - public function action(Message $message, Database $dbForPlatform, callable $getProjectDB, callable $timelimit, Device $deviceForFiles, Device $deviceForFunctions, Device $deviceForBuilds, Device $deviceForCache, CertificatesAdapter $certificates, string $executionRetention, string $auditRetention, Log $log): void + public function action(Message $message, Document $project, Database $dbForPlatform, callable $getProjectDB, callable $timelimit, Device $deviceForFiles, Device $deviceForFunctions, Device $deviceForBuilds, Device $deviceForCache, CertificatesAdapter $certificates, string $executionRetention, string $auditRetention, Log $log): void { $payload = $message->getPayload() ?? []; @@ -78,7 +79,6 @@ class Deletes extends Action $resource = $payload['resource'] ?? null; $resourceType = $payload['resourceType'] ?? null; $document = new Document($payload['document'] ?? []); - $project = new Document($payload['project'] ?? []); $log->addTag('projectId', $project->getId()); $log->addTag('type', $type); diff --git a/src/Appwrite/Platform/Workers/Messaging.php b/src/Appwrite/Platform/Workers/Messaging.php index 1ff032c3e1..febc4a4e55 100644 --- a/src/Appwrite/Platform/Workers/Messaging.php +++ b/src/Appwrite/Platform/Workers/Messaging.php @@ -58,15 +58,17 @@ class Messaging extends Action $this ->desc('Messaging worker') ->inject('message') + ->inject('project') ->inject('log') ->inject('dbForProject') ->inject('deviceForFiles') ->inject('queueForUsage') - ->callback(fn (Message $message, Log $log, Database $dbForProject, Device $deviceForFiles, Usage $queueForUsage) => $this->action($message, $log, $dbForProject, $deviceForFiles, $queueForUsage)); + ->callback(fn (Message $message, Document $project, Log $log, Database $dbForProject, Device $deviceForFiles, Usage $queueForUsage) => $this->action($message, $project, $log, $dbForProject, $deviceForFiles, $queueForUsage)); } /** * @param Message $message + * @param Document $project * @param Log $log * @param Database $dbForProject * @param Device $deviceForFiles @@ -76,6 +78,7 @@ class Messaging extends Action */ public function action( Message $message, + Document $project, Log $log, Database $dbForProject, Device $deviceForFiles, @@ -89,7 +92,6 @@ class Messaging extends Action } $type = $payload['type'] ?? ''; - $project = new Document($payload['project'] ?? []); switch ($type) { case MESSAGE_SEND_TYPE_INTERNAL: diff --git a/src/Appwrite/Platform/Workers/Migrations.php b/src/Appwrite/Platform/Workers/Migrations.php index f6af0eb5f2..078c9fa0ff 100644 --- a/src/Appwrite/Platform/Workers/Migrations.php +++ b/src/Appwrite/Platform/Workers/Migrations.php @@ -51,16 +51,17 @@ class Migrations extends Action $this ->desc('Migrations worker') ->inject('message') + ->inject('project') ->inject('dbForProject') ->inject('dbForPlatform') ->inject('logError') - ->callback(fn (Message $message, Database $dbForProject, Database $dbForPlatform, callable $logError) => $this->action($message, $dbForProject, $dbForPlatform, $logError)); + ->callback(fn (Message $message, Document $project, Database $dbForProject, Database $dbForPlatform, callable $logError) => $this->action($message, $project, $dbForProject, $dbForPlatform, $logError)); } /** * @throws Exception */ - public function action(Message $message, Database $dbForProject, Database $dbForPlatform, callable $logError): void + public function action(Message $message, Document $project, Database $dbForProject, Database $dbForPlatform, callable $logError): void { $payload = $message->getPayload() ?? []; @@ -69,7 +70,6 @@ class Migrations extends Action } $events = $payload['events'] ?? []; - $project = new Document($payload['project'] ?? []); $migration = new Document($payload['migration'] ?? []); if ($project->getId() === 'console') { diff --git a/src/Appwrite/Platform/Workers/Usage.php b/src/Appwrite/Platform/Workers/Usage.php index 8199fe73a7..be916f33e9 100644 --- a/src/Appwrite/Platform/Workers/Usage.php +++ b/src/Appwrite/Platform/Workers/Usage.php @@ -34,10 +34,11 @@ class Usage extends Action $this ->desc('Usage worker') ->inject('message') + ->inject('project') ->inject('getProjectDB') ->inject('queueForUsageDump') - ->callback(function (Message $message, callable $getProjectDB, UsageDump $queueForUsageDump) { - $this->action($message, $getProjectDB, $queueForUsageDump); + ->callback(function (Message $message, Document $project, callable $getProjectDB, UsageDump $queueForUsageDump) { + $this->action($message, $project, $getProjectDB, $queueForUsageDump); }); $this->aggregationInterval = (int) System::getEnv('_APP_USAGE_AGGREGATION_INTERVAL', '20'); @@ -46,21 +47,20 @@ class Usage extends Action /** * @param Message $message + * @param Document $project * @param callable $getProjectDB * @param UsageDump $queueForUsageDump * @return void * @throws \Utopia\Database\Exception * @throws Exception */ - public function action(Message $message, callable $getProjectDB, UsageDump $queueForUsageDump): void + public function action(Message $message, Document $project, callable $getProjectDB, UsageDump $queueForUsageDump): void { $payload = $message->getPayload() ?? []; if (empty($payload)) { throw new Exception('Missing payload'); } - $document = $payload['project'] ?? []; - $project = new Document($document); if (empty($project->getAttribute('database'))) { var_dump($payload); diff --git a/src/Appwrite/Platform/Workers/UsageDump.php b/src/Appwrite/Platform/Workers/UsageDump.php index 3e50ba0363..2f1d13f29a 100644 --- a/src/Appwrite/Platform/Workers/UsageDump.php +++ b/src/Appwrite/Platform/Workers/UsageDump.php @@ -59,26 +59,11 @@ class UsageDump extends Action foreach ($payload['stats'] ?? [] as $stats) { - //$project = new Document($stats['project'] ?? []); - - /** - * Start temp bug fallback - */ - $document = $stats['project'] ?? []; - if (!empty($document['$uid'])) { - $document['$id'] = $document['$uid']; - } - - $project = new Document($document); - - if (empty($project->getAttribute('database'))) { - continue; - } + $project = new Document($stats['project'] ?? []); /** * End temp bug fallback */ - $numberOfKeys = !empty($stats['keys']) ? count($stats['keys']) : 0; $receivedAt = $stats['receivedAt'] ?? 'NONE'; if ($numberOfKeys === 0) { diff --git a/src/Appwrite/Platform/Workers/Webhooks.php b/src/Appwrite/Platform/Workers/Webhooks.php index 50f64ea02d..a76e4f17b0 100644 --- a/src/Appwrite/Platform/Workers/Webhooks.php +++ b/src/Appwrite/Platform/Workers/Webhooks.php @@ -32,22 +32,24 @@ class Webhooks extends Action $this ->desc('Webhooks worker') ->inject('message') + ->inject('project') ->inject('dbForPlatform') ->inject('queueForMails') ->inject('queueForUsage') ->inject('log') - ->callback(fn (Message $message, Database $dbForPlatform, Mail $queueForMails, Usage $queueForUsage, Log $log) => $this->action($message, $dbForPlatform, $queueForMails, $queueForUsage, $log)); + ->callback(fn (Message $message, Document $project, Database $dbForPlatform, Mail $queueForMails, Usage $queueForUsage, Log $log) => $this->action($message, $project, $dbForPlatform, $queueForMails, $queueForUsage, $log)); } /** * @param Message $message + * @param Document $project * @param Database $dbForPlatform * @param Mail $queueForMails * @param Log $log * @return void * @throws Exception */ - public function action(Message $message, Database $dbForPlatform, Mail $queueForMails, Usage $queueForUsage, Log $log): void + public function action(Message $message, Document $project, Database $dbForPlatform, Mail $queueForMails, Usage $queueForUsage, Log $log): void { $this->errors = []; $payload = $message->getPayload() ?? []; @@ -60,8 +62,6 @@ class Webhooks extends Action $webhookPayload = json_encode($payload['payload']); $user = new Document($payload['user'] ?? []); - $project = new Document($payload['project']); - $project = $dbForPlatform->getDocument('projects', $project->getId()); $log->addTag('projectId', $project->getId()); foreach ($project->getAttribute('webhooks', []) as $webhook) { From 8ea1f436c1dd501b6d5b6469ab18d6b453e9f6a8 Mon Sep 17 00:00:00 2001 From: Christy Jacob <christyjacob4@gmail.com> Date: Thu, 16 Jan 2025 11:37:02 +0530 Subject: [PATCH 30/47] feat: linter --- src/Appwrite/Event/Webhook.php | 3 +-- src/Appwrite/Platform/Workers/Usage.php | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Appwrite/Event/Webhook.php b/src/Appwrite/Event/Webhook.php index 052d8f0fb9..c7035070b8 100644 --- a/src/Appwrite/Event/Webhook.php +++ b/src/Appwrite/Event/Webhook.php @@ -2,7 +2,6 @@ namespace Appwrite\Event; -use Utopia\Database\Document; use Utopia\Queue\Connection; class Webhook extends Event @@ -20,7 +19,7 @@ class Webhook extends Event { /** Filter out context and trim project to keep the payload small */ $this->context = []; - + return parent::trigger(); } } diff --git a/src/Appwrite/Platform/Workers/Usage.php b/src/Appwrite/Platform/Workers/Usage.php index be916f33e9..3687eeab67 100644 --- a/src/Appwrite/Platform/Workers/Usage.php +++ b/src/Appwrite/Platform/Workers/Usage.php @@ -34,7 +34,7 @@ class Usage extends Action $this ->desc('Usage worker') ->inject('message') - ->inject('project') + ->inject('project') ->inject('getProjectDB') ->inject('queueForUsageDump') ->callback(function (Message $message, Document $project, callable $getProjectDB, UsageDump $queueForUsageDump) { From e8f97baf262531bf45020a082302103fc2091383 Mon Sep 17 00:00:00 2001 From: Christy Jacob <christyjacob4@gmail.com> Date: Thu, 16 Jan 2025 13:14:47 +0530 Subject: [PATCH 31/47] fix: incorrect project payloads --- app/init.php | 1 + src/Appwrite/Event/Audit.php | 2 + src/Appwrite/Event/Build.php | 2 + src/Appwrite/Event/Certificate.php | 2 + src/Appwrite/Event/Database.php | 2 + src/Appwrite/Event/Delete.php | 2 + src/Appwrite/Event/Event.php | 18 ++++++++- src/Appwrite/Event/Func.php | 2 + src/Appwrite/Event/Mail.php | 2 + src/Appwrite/Event/Messaging.php | 2 + src/Appwrite/Event/Migration.php | 2 + src/Appwrite/Event/Usage.php | 4 +- src/Appwrite/Event/UsageDump.php | 2 + src/Appwrite/Event/Webhook.php | 1 - src/Appwrite/Platform/Tasks/Maintenance.php | 44 ++------------------- src/Appwrite/Platform/Workers/Deletes.php | 12 ++++++ 16 files changed, 55 insertions(+), 45 deletions(-) diff --git a/app/init.php b/app/init.php index df2a66aa00..df0e9d3a08 100644 --- a/app/init.php +++ b/app/init.php @@ -202,6 +202,7 @@ const DELETE_TYPE_TOPIC = 'topic'; const DELETE_TYPE_TARGET = 'target'; const DELETE_TYPE_EXPIRED_TARGETS = 'invalid_targets'; const DELETE_TYPE_SESSION_TARGETS = 'session_targets'; +const DELETE_TYPE_MAINTENANCE = 'maintenance'; // Message types const MESSAGE_SEND_TYPE_INTERNAL = 'internal'; diff --git a/src/Appwrite/Event/Audit.php b/src/Appwrite/Event/Audit.php index 406f64b370..5cbe379666 100644 --- a/src/Appwrite/Event/Audit.php +++ b/src/Appwrite/Event/Audit.php @@ -150,6 +150,8 @@ class Audit extends Event return false; } + $this->trimFields(); + $client = new Client($this->queue, $this->connection); return $client->enqueue([ diff --git a/src/Appwrite/Event/Build.php b/src/Appwrite/Event/Build.php index 1fbf20a9f9..bdbcf6826c 100644 --- a/src/Appwrite/Event/Build.php +++ b/src/Appwrite/Event/Build.php @@ -116,6 +116,8 @@ class Build extends Event return false; } + $this->trimFields(); + $client = new Client($this->queue, $this->connection); return $client->enqueue([ diff --git a/src/Appwrite/Event/Certificate.php b/src/Appwrite/Event/Certificate.php index 5d30c3d5ac..2629653c59 100644 --- a/src/Appwrite/Event/Certificate.php +++ b/src/Appwrite/Event/Certificate.php @@ -78,6 +78,8 @@ class Certificate extends Event return false; } + $this->trimFields(); + $client = new Client($this->queue, $this->connection); return $client->enqueue([ diff --git a/src/Appwrite/Event/Database.php b/src/Appwrite/Event/Database.php index 1b0ea6851c..e78fe967e7 100644 --- a/src/Appwrite/Event/Database.php +++ b/src/Appwrite/Event/Database.php @@ -121,6 +121,8 @@ class Database extends Event $this->setQueue($dsn->getHost()); + $this->trimFields(); + $client = new Client($this->queue, $this->connection); try { diff --git a/src/Appwrite/Event/Delete.php b/src/Appwrite/Event/Delete.php index 1a4c9318e3..2874043163 100644 --- a/src/Appwrite/Event/Delete.php +++ b/src/Appwrite/Event/Delete.php @@ -144,6 +144,8 @@ class Delete extends Event return false; } + $this->trimFields(); + $client = new Client($this->queue, $this->connection); return $client->enqueue([ diff --git a/src/Appwrite/Event/Event.php b/src/Appwrite/Event/Event.php index a830fd66b1..4029502ea7 100644 --- a/src/Appwrite/Event/Event.php +++ b/src/Appwrite/Event/Event.php @@ -135,10 +135,22 @@ class Event * @return self */ public function setProject(Document $project): self + { + $this->project = $project; + return $this; + } + + /** + * Trims the fields of the project document to only include the necessary fields. + * + * @return self + */ + public function trimFields(): self { $this->project = new Document([ - '$id' => $project->getId(), - '$internalId' => $project->getInternalId() + '$id' => $this->project->getId(), + '$internalId' => $this->project->getInternalId(), + 'database' => $this->project->getAttribute('database') ]); return $this; @@ -327,6 +339,8 @@ class Event return false; } + $this->trimFields(); + $client = new Client($this->queue, $this->connection); return $client->enqueue([ diff --git a/src/Appwrite/Event/Func.php b/src/Appwrite/Event/Func.php index 0ad639a9f5..7c6a2e9194 100644 --- a/src/Appwrite/Event/Func.php +++ b/src/Appwrite/Event/Func.php @@ -217,6 +217,8 @@ class Func extends Event return false; } + $this->trimFields(); + $client = new Client($this->queue, $this->connection); $events = $this->getEvent() ? Event::generateEvents($this->getEvent(), $this->getParams()) : null; diff --git a/src/Appwrite/Event/Mail.php b/src/Appwrite/Event/Mail.php index a0fca75688..0db576ba68 100644 --- a/src/Appwrite/Event/Mail.php +++ b/src/Appwrite/Event/Mail.php @@ -408,6 +408,8 @@ class Mail extends Event return false; } + $this->trimFields(); + $client = new Client($this->queue, $this->connection); return $client->enqueue([ diff --git a/src/Appwrite/Event/Messaging.php b/src/Appwrite/Event/Messaging.php index 755b8c9158..ac2df7f92a 100644 --- a/src/Appwrite/Event/Messaging.php +++ b/src/Appwrite/Event/Messaging.php @@ -186,6 +186,8 @@ class Messaging extends Event return false; } + $this->trimFields(); + $client = new Client($this->queue, $this->connection); return $client->enqueue([ diff --git a/src/Appwrite/Event/Migration.php b/src/Appwrite/Event/Migration.php index 789b8e2160..376264bce3 100644 --- a/src/Appwrite/Event/Migration.php +++ b/src/Appwrite/Event/Migration.php @@ -79,6 +79,8 @@ class Migration extends Event return false; } + $this->trimFields(); + $client = new Client($this->queue, $this->connection); return $client->enqueue([ diff --git a/src/Appwrite/Event/Usage.php b/src/Appwrite/Event/Usage.php index 89e900d2ab..f17c048a2e 100644 --- a/src/Appwrite/Event/Usage.php +++ b/src/Appwrite/Event/Usage.php @@ -62,10 +62,12 @@ class Usage extends Event return false; } + $this->trimFields(); + $client = new Client($this->queue, $this->connection); $result = $client->enqueue([ - 'project' => $this->getProject(), + 'project' => $this->project, 'reduce' => $this->reduce, 'metrics' => $this->metrics, ]); diff --git a/src/Appwrite/Event/UsageDump.php b/src/Appwrite/Event/UsageDump.php index 2998e4e104..83206e4add 100644 --- a/src/Appwrite/Event/UsageDump.php +++ b/src/Appwrite/Event/UsageDump.php @@ -42,6 +42,8 @@ class UsageDump extends Event return false; } + $this->trimFields(); + $client = new Client($this->queue, $this->connection); return $client->enqueue([ diff --git a/src/Appwrite/Event/Webhook.php b/src/Appwrite/Event/Webhook.php index c7035070b8..9d14dcdc3d 100644 --- a/src/Appwrite/Event/Webhook.php +++ b/src/Appwrite/Event/Webhook.php @@ -19,7 +19,6 @@ class Webhook extends Event { /** Filter out context and trim project to keep the payload small */ $this->context = []; - return parent::trigger(); } } diff --git a/src/Appwrite/Platform/Tasks/Maintenance.php b/src/Appwrite/Platform/Tasks/Maintenance.php index c789cbdaac..a7558934b5 100644 --- a/src/Appwrite/Platform/Tasks/Maintenance.php +++ b/src/Appwrite/Platform/Tasks/Maintenance.php @@ -64,11 +64,9 @@ class Maintenance extends Action */ protected function notifyProjects(Delete $queueForDeletes, int $usageStatsRetentionHourly): void { - $this->notifyDeleteTargets($queueForDeletes); - $this->notifyDeleteExecutionLogs($queueForDeletes); - $this->notifyDeleteAuditLogs($queueForDeletes); - $this->notifyDeleteUsageStats($usageStatsRetentionHourly, $queueForDeletes); - $this->notifyDeleteExpiredSessions($queueForDeletes); + $queueForDeletes + ->setUsageRetentionHourlyDateTime(DateTime::addSeconds(new \DateTime(), -1 * $usageStatsRetentionHourly)) + ->trigger(); } protected function foreachProject(Database $dbForPlatform, callable $callback): void @@ -98,28 +96,6 @@ class Maintenance extends Action Console::info("Found {$count} projects " . ($executionEnd - $executionStart) . " seconds"); } - private function notifyDeleteExecutionLogs(Delete $queueForDeletes): void - { - $queueForDeletes - ->setType(DELETE_TYPE_EXECUTIONS) - ->trigger(); - } - - private function notifyDeleteAuditLogs(Delete $queueForDeletes): void - { - $queueForDeletes - ->setType(DELETE_TYPE_AUDIT) - ->trigger(); - } - - private function notifyDeleteUsageStats(int $usageStatsRetentionHourly, Delete $queueForDeletes): void - { - $queueForDeletes - ->setType(DELETE_TYPE_USAGE) - ->setUsageRetentionHourlyDateTime(DateTime::addSeconds(new \DateTime(), -1 * $usageStatsRetentionHourly)) - ->trigger(); - } - private function notifyDeleteConnections(Delete $queueForDeletes): void { $queueForDeletes @@ -128,13 +104,6 @@ class Maintenance extends Action ->trigger(); } - private function notifyDeleteExpiredSessions(Delete $queueForDeletes): void - { - $queueForDeletes - ->setType(DELETE_TYPE_SESSIONS) - ->trigger(); - } - private function renewCertificates(Database $dbForPlatform, Certificate $queueForCertificate): void { $time = DateTime::now(); @@ -177,11 +146,4 @@ class Maintenance extends Action ->setDatetime(DateTime::addSeconds(new \DateTime(), -1 * $interval)) ->trigger(); } - - private function notifyDeleteTargets(Delete $queueForDeletes): void - { - $queueForDeletes - ->setType(DELETE_TYPE_EXPIRED_TARGETS) - ->trigger(); - } } diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index 35ee50c791..45e7725c9b 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -153,11 +153,23 @@ class Deletes extends Action case DELETE_TYPE_SESSION_TARGETS: $this->deleteSessionTargets($project, $getProjectDB, $document); break; + case DELETE_TYPE_MAINTENANCE: + $this->performMaintenance($project, $getProjectDB, $executionRetention, $auditRetention, $hourlyUsageRetentionDatetime); + break; default: throw new \Exception('No delete operation for type: ' . \strval($type)); } } + private function performMaintenance(Document $project, callable $getProjectDB, string $executionRetention, string $auditRetention, string $hourlyUsageRetentionDatetime): void + { + $this->deleteExpiredTargets($project, $getProjectDB); + $this->deleteExecutionLogs($project, $getProjectDB, $executionRetention); + $this->deleteAuditLogs($project, $getProjectDB, $auditRetention); + $this->deleteUsageStats($project, $getProjectDB, $hourlyUsageRetentionDatetime); + $this->deleteExpiredSessions($project, $getProjectDB); + } + /** * @param Database $dbForPlatform * @param callable $getProjectDB From 2a0894f3d1df1015f3a7d2f5acc04cccbb4b2096 Mon Sep 17 00:00:00 2001 From: Christy Jacob <christyjacob4@gmail.com> Date: Thu, 16 Jan 2025 13:29:08 +0530 Subject: [PATCH 32/47] fix: incorrect project payloads --- src/Appwrite/Event/Event.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Appwrite/Event/Event.php b/src/Appwrite/Event/Event.php index 4029502ea7..4efc138ec6 100644 --- a/src/Appwrite/Event/Event.php +++ b/src/Appwrite/Event/Event.php @@ -147,11 +147,13 @@ class Event */ public function trimFields(): self { - $this->project = new Document([ - '$id' => $this->project->getId(), - '$internalId' => $this->project->getInternalId(), - 'database' => $this->project->getAttribute('database') - ]); + if ($this->project) { + $this->project = new Document([ + '$id' => $this->project->getId(), + '$internalId' => $this->project->getInternalId(), + 'database' => $this->project->getAttribute('database') + ]); + } return $this; } From f52b2d5dcde55de4928740371e6d39b5dce0262a Mon Sep 17 00:00:00 2001 From: Christy Jacob <christyjacob4@gmail.com> Date: Thu, 16 Jan 2025 16:59:30 +0530 Subject: [PATCH 33/47] chore: review comments --- src/Appwrite/Platform/Workers/Deletes.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index 45e7725c9b..539bbd61f9 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -154,22 +154,17 @@ class Deletes extends Action $this->deleteSessionTargets($project, $getProjectDB, $document); break; case DELETE_TYPE_MAINTENANCE: - $this->performMaintenance($project, $getProjectDB, $executionRetention, $auditRetention, $hourlyUsageRetentionDatetime); + $this->deleteExpiredTargets($project, $getProjectDB); + $this->deleteExecutionLogs($project, $getProjectDB, $executionRetention); + $this->deleteAuditLogs($project, $getProjectDB, $auditRetention); + $this->deleteUsageStats($project, $getProjectDB, $hourlyUsageRetentionDatetime); + $this->deleteExpiredSessions($project, $getProjectDB); break; default: throw new \Exception('No delete operation for type: ' . \strval($type)); } } - private function performMaintenance(Document $project, callable $getProjectDB, string $executionRetention, string $auditRetention, string $hourlyUsageRetentionDatetime): void - { - $this->deleteExpiredTargets($project, $getProjectDB); - $this->deleteExecutionLogs($project, $getProjectDB, $executionRetention); - $this->deleteAuditLogs($project, $getProjectDB, $auditRetention); - $this->deleteUsageStats($project, $getProjectDB, $hourlyUsageRetentionDatetime); - $this->deleteExpiredSessions($project, $getProjectDB); - } - /** * @param Database $dbForPlatform * @param callable $getProjectDB From f392b5ab45c8087c1a5065c8b37f33fffea8d7ee Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Thu, 16 Jan 2025 16:01:35 +0000 Subject: [PATCH 34/47] chore: composer update --- composer.lock | 56 +++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/composer.lock b/composer.lock index b77915f0a4..57a5d9294a 100644 --- a/composer.lock +++ b/composer.lock @@ -1430,16 +1430,16 @@ }, { "name": "open-telemetry/gen-otlp-protobuf", - "version": "1.2.1", + "version": "1.5.0", "source": { "type": "git", "url": "https://github.com/opentelemetry-php/gen-otlp-protobuf.git", - "reference": "66c3b98e998a726691c92e6405a82e6e7b8b169d" + "reference": "585bafddd4ae6565de154610b10a787a455c9ba0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/opentelemetry-php/gen-otlp-protobuf/zipball/66c3b98e998a726691c92e6405a82e6e7b8b169d", - "reference": "66c3b98e998a726691c92e6405a82e6e7b8b169d", + "url": "https://api.github.com/repos/opentelemetry-php/gen-otlp-protobuf/zipball/585bafddd4ae6565de154610b10a787a455c9ba0", + "reference": "585bafddd4ae6565de154610b10a787a455c9ba0", "shasum": "" }, "require": { @@ -1489,7 +1489,7 @@ "issues": "https://github.com/open-telemetry/opentelemetry-php/issues", "source": "https://github.com/open-telemetry/opentelemetry-php" }, - "time": "2024-10-30T11:49:49+00:00" + "time": "2025-01-15T23:07:07+00:00" }, { "name": "open-telemetry/sdk", @@ -3379,16 +3379,16 @@ }, { "name": "utopia-php/compression", - "version": "0.1.2", + "version": "0.1.3", "source": { "type": "git", "url": "https://github.com/utopia-php/compression.git", - "reference": "6062f70596415f8d5de40a589367b0eb2a435f98" + "reference": "66f093557ba66d98245e562036182016c7dcfe8a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/compression/zipball/6062f70596415f8d5de40a589367b0eb2a435f98", - "reference": "6062f70596415f8d5de40a589367b0eb2a435f98", + "url": "https://api.github.com/repos/utopia-php/compression/zipball/66f093557ba66d98245e562036182016c7dcfe8a", + "reference": "66f093557ba66d98245e562036182016c7dcfe8a", "shasum": "" }, "require": { @@ -3419,9 +3419,9 @@ ], "support": { "issues": "https://github.com/utopia-php/compression/issues", - "source": "https://github.com/utopia-php/compression/tree/0.1.2" + "source": "https://github.com/utopia-php/compression/tree/0.1.3" }, - "time": "2024-11-08T14:59:54+00:00" + "time": "2025-01-15T15:15:51+00:00" }, { "name": "utopia-php/config", @@ -3678,16 +3678,16 @@ }, { "name": "utopia-php/framework", - "version": "0.33.15", + "version": "0.33.16", "source": { "type": "git", "url": "https://github.com/utopia-php/http.git", - "reference": "83b0628900c2c53e8c3efbf069f3e13050295edc" + "reference": "e91d4c560d1b809e25faa63d564fef034363b50f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/http/zipball/83b0628900c2c53e8c3efbf069f3e13050295edc", - "reference": "83b0628900c2c53e8c3efbf069f3e13050295edc", + "url": "https://api.github.com/repos/utopia-php/http/zipball/e91d4c560d1b809e25faa63d564fef034363b50f", + "reference": "e91d4c560d1b809e25faa63d564fef034363b50f", "shasum": "" }, "require": { @@ -3719,9 +3719,9 @@ ], "support": { "issues": "https://github.com/utopia-php/http/issues", - "source": "https://github.com/utopia-php/http/tree/0.33.15" + "source": "https://github.com/utopia-php/http/tree/0.33.16" }, - "time": "2024-12-10T13:07:04+00:00" + "time": "2025-01-16T15:58:50+00:00" }, { "name": "utopia-php/image", @@ -4095,16 +4095,16 @@ }, { "name": "utopia-php/platform", - "version": "0.7.1", + "version": "0.7.2", "source": { "type": "git", "url": "https://github.com/utopia-php/platform.git", - "reference": "3433a0f1a54988f2a59c735f507745cb2c24638a" + "reference": "6f9243848f1c6466f6509fd01c7e18306a6d8caf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/platform/zipball/3433a0f1a54988f2a59c735f507745cb2c24638a", - "reference": "3433a0f1a54988f2a59c735f507745cb2c24638a", + "url": "https://api.github.com/repos/utopia-php/platform/zipball/6f9243848f1c6466f6509fd01c7e18306a6d8caf", + "reference": "6f9243848f1c6466f6509fd01c7e18306a6d8caf", "shasum": "" }, "require": { @@ -4139,9 +4139,9 @@ ], "support": { "issues": "https://github.com/utopia-php/platform/issues", - "source": "https://github.com/utopia-php/platform/tree/0.7.1" + "source": "https://github.com/utopia-php/platform/tree/0.7.2" }, - "time": "2024-10-22T10:27:49+00:00" + "time": "2025-01-15T05:56:26+00:00" }, { "name": "utopia-php/pools", @@ -5126,16 +5126,16 @@ }, { "name": "laravel/pint", - "version": "v1.19.0", + "version": "v1.20.0", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "8169513746e1bac70c85d6ea1524d9225d4886f0" + "reference": "53072e8ea22213a7ed168a8a15b96fbb8b82d44b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/8169513746e1bac70c85d6ea1524d9225d4886f0", - "reference": "8169513746e1bac70c85d6ea1524d9225d4886f0", + "url": "https://api.github.com/repos/laravel/pint/zipball/53072e8ea22213a7ed168a8a15b96fbb8b82d44b", + "reference": "53072e8ea22213a7ed168a8a15b96fbb8b82d44b", "shasum": "" }, "require": { @@ -5188,7 +5188,7 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2024-12-30T16:20:10+00:00" + "time": "2025-01-14T16:20:53+00:00" }, { "name": "matthiasmullie/minify", From 7db65f46ae0fe5b0646688b3e9af6487d94eed64 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Thu, 16 Jan 2025 17:23:22 +0000 Subject: [PATCH 35/47] feat: add compression toggle env --- app/http.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/http.php b/app/http.php index 3a7562ffd1..dac941d25b 100644 --- a/app/http.php +++ b/app/http.php @@ -334,7 +334,7 @@ $http->on(Constant::EVENT_REQUEST, function (SwooleRequest $swooleRequest, Swool } $app = new App('UTC'); - $app->setCompression(true); + $app->setCompression(System::getEnv('_APP_COMPRESSION_ENABLED', 'enabled') === 'enabled'); $app->setCompressionMinSize(intval(System::getEnv('_APP_COMPRESSION_MIN_SIZE_BYTES', '1024'))); // 1KB $pools = $register->get('pools'); From facdf1a362ed6a08afdfa0b7f6c45270c1b14965 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Thu, 16 Jan 2025 18:05:49 +0000 Subject: [PATCH 36/47] chore: revert usage debug --- src/Appwrite/Event/Usage.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Appwrite/Event/Usage.php b/src/Appwrite/Event/Usage.php index a09b651da8..89e900d2ab 100644 --- a/src/Appwrite/Event/Usage.php +++ b/src/Appwrite/Event/Usage.php @@ -2,7 +2,6 @@ namespace Appwrite\Event; -use Utopia\CLI\Console; use Utopia\Database\Document; use Utopia\Queue\Client; use Utopia\Queue\Connection; @@ -63,11 +62,6 @@ class Usage extends Event return false; } - Console::log('------------------------'); - Console::log('Usage Event Triggered'); - Console::log('Metrics: ' . json_encode($this->metrics, JSON_PRETTY_PRINT)); - Console::log('------------------------'); - $client = new Client($this->queue, $this->connection); $result = $client->enqueue([ From 8bdafb46d6d39a23c5ad6624758de129c953b4d6 Mon Sep 17 00:00:00 2001 From: Christy Jacob <christyjacob4@gmail.com> Date: Fri, 17 Jan 2025 10:38:39 +0530 Subject: [PATCH 37/47] chore: review comments & refactoring --- app/controllers/api/functions.php | 4 ++ phpunit.xml | 2 +- src/Appwrite/Event/Audit.php | 20 ++----- src/Appwrite/Event/Build.php | 20 ++----- src/Appwrite/Event/Certificate.php | 20 ++----- src/Appwrite/Event/Database.php | 51 +++++++--------- src/Appwrite/Event/Delete.php | 21 ++----- src/Appwrite/Event/Event.php | 58 ++++++++++++------- src/Appwrite/Event/Func.php | 43 ++------------ src/Appwrite/Event/Mail.php | 20 ++----- src/Appwrite/Event/Messaging.php | 21 ++----- src/Appwrite/Event/Migration.php | 20 ++----- src/Appwrite/Event/Realtime.php | 3 + src/Appwrite/Event/Usage.php | 33 +++++------ src/Appwrite/Event/UsageDump.php | 19 ++---- src/Appwrite/Event/Webhook.php | 15 +++-- .../Functions/FunctionsCustomServerTest.php | 2 +- 17 files changed, 138 insertions(+), 234 deletions(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index d4d5fc64cf..f459875fca 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -400,6 +400,10 @@ App::post('/v1/functions') $allEvents = Event::generateEvents('rules.[ruleId].create', [ 'ruleId' => $rule->getId(), ]); + + + var_dump("-------------------- Create Function ---------------"); + var_dump($project); $target = Realtime::fromPayload( // Pass first, most verbose event pattern event: $allEvents[0], diff --git a/phpunit.xml b/phpunit.xml index 4c4e55ea4e..598b730908 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -6,7 +6,7 @@ convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" - stopOnFailure="false" + stopOnFailure="true" > <extensions> <extension class="Appwrite\Tests\TestHook" /> diff --git a/src/Appwrite/Event/Audit.php b/src/Appwrite/Event/Audit.php index 5cbe379666..4b9aa9f5c5 100644 --- a/src/Appwrite/Event/Audit.php +++ b/src/Appwrite/Event/Audit.php @@ -2,7 +2,6 @@ namespace Appwrite\Event; -use Utopia\Queue\Client; use Utopia\Queue\Connection; class Audit extends Event @@ -139,22 +138,13 @@ class Audit extends Event } /** - * Executes the event and sends it to the audit worker. + * Prepare payload for queue. * - * @return string|bool - * @throws \InvalidArgumentException + * @return array */ - public function trigger(): string|bool + protected function preparePayload(): array { - if ($this->paused) { - return false; - } - - $this->trimFields(); - - $client = new Client($this->queue, $this->connection); - - return $client->enqueue([ + return [ 'project' => $this->project, 'user' => $this->user, 'payload' => $this->payload, @@ -164,6 +154,6 @@ class Audit extends Event 'userAgent' => $this->userAgent, 'event' => $this->event, 'hostname' => $this->hostname - ]); + ]; } } diff --git a/src/Appwrite/Event/Build.php b/src/Appwrite/Event/Build.php index bdbcf6826c..831adf8e41 100644 --- a/src/Appwrite/Event/Build.php +++ b/src/Appwrite/Event/Build.php @@ -3,7 +3,6 @@ namespace Appwrite\Event; use Utopia\Database\Document; -use Utopia\Queue\Client; use Utopia\Queue\Connection; class Build extends Event @@ -105,28 +104,19 @@ class Build extends Event } /** - * Executes the function event and sends it to the functions worker. + * Prepare payload for queue. * - * @return string|bool - * @throws \InvalidArgumentException + * @return array */ - public function trigger(): string|bool + protected function preparePayload(): array { - if ($this->paused) { - return false; - } - - $this->trimFields(); - - $client = new Client($this->queue, $this->connection); - - return $client->enqueue([ + return [ 'project' => $this->project, 'resource' => $this->resource, 'deployment' => $this->deployment, 'type' => $this->type, 'template' => $this->template - ]); + ]; } /** diff --git a/src/Appwrite/Event/Certificate.php b/src/Appwrite/Event/Certificate.php index 2629653c59..6a395417ed 100644 --- a/src/Appwrite/Event/Certificate.php +++ b/src/Appwrite/Event/Certificate.php @@ -3,7 +3,6 @@ namespace Appwrite\Event; use Utopia\Database\Document; -use Utopia\Queue\Client; use Utopia\Queue\Connection; class Certificate extends Event @@ -67,25 +66,16 @@ class Certificate extends Event } /** - * Executes the event and sends it to the certificates worker. + * Prepare the payload for the event * - * @return string|bool - * @throws \InvalidArgumentException + * @return array */ - public function trigger(): string|bool + protected function preparePayload(): array { - if ($this->paused) { - return false; - } - - $this->trimFields(); - - $client = new Client($this->queue, $this->connection); - - return $client->enqueue([ + return [ 'project' => $this->project, 'domain' => $this->domain, 'skipRenewCheck' => $this->skipRenewCheck - ]); + ]; } } diff --git a/src/Appwrite/Event/Database.php b/src/Appwrite/Event/Database.php index e78fe967e7..24123de6c1 100644 --- a/src/Appwrite/Event/Database.php +++ b/src/Appwrite/Event/Database.php @@ -4,7 +4,6 @@ namespace Appwrite\Event; use Utopia\Database\Document; use Utopia\DSN\DSN; -use Utopia\Queue\Client; use Utopia\Queue\Connection; class Database extends Event @@ -100,18 +99,8 @@ class Database extends Event return $this->document; } - /** - * Executes the event and send it to the database worker. - * - * @return string|bool - * @throws \InvalidArgumentException - */ - public function trigger(): string|bool + public function getQueue(): string { - if ($this->paused) { - return false; - } - try { $dsn = new DSN($this->getProject()->getAttribute('database')); } catch (\InvalidArgumentException) { @@ -119,25 +108,25 @@ class Database extends Event $dsn = new DSN('mysql://' . $this->getProject()->getAttribute('database')); } - $this->setQueue($dsn->getHost()); + $this->queue = $dsn->getHost(); + return $this->queue; + } - $this->trimFields(); - - $client = new Client($this->queue, $this->connection); - - try { - $result = $client->enqueue([ - 'project' => $this->project, - 'user' => $this->user, - 'type' => $this->type, - 'collection' => $this->collection, - 'document' => $this->document, - 'database' => $this->database, - 'events' => Event::generateEvents($this->getEvent(), $this->getParams()) - ]); - return $result; - } catch (\Throwable $th) { - return false; - } + /** + * Prepare the payload for the event + * + * @return array + */ + protected function preparePayload(): array + { + return [ + 'project' => $this->project, + 'user' => $this->user, + 'type' => $this->type, + 'collection' => $this->collection, + 'document' => $this->document, + 'database' => $this->database, + 'events' => Event::generateEvents($this->getEvent(), $this->getParams()) + ]; } } diff --git a/src/Appwrite/Event/Delete.php b/src/Appwrite/Event/Delete.php index 2874043163..f0af20f21b 100644 --- a/src/Appwrite/Event/Delete.php +++ b/src/Appwrite/Event/Delete.php @@ -3,7 +3,6 @@ namespace Appwrite\Event; use Utopia\Database\Document; -use Utopia\Queue\Client; use Utopia\Queue\Connection; class Delete extends Event @@ -131,24 +130,14 @@ class Delete extends Event return $this->document; } - /** - * Executes this event and sends it to the deletes worker. + * Prepare the payload for the event * - * @return string|bool - * @throws \InvalidArgumentException + * @return array */ - public function trigger(): string|bool + protected function preparePayload(): array { - if ($this->paused) { - return false; - } - - $this->trimFields(); - - $client = new Client($this->queue, $this->connection); - - return $client->enqueue([ + return [ 'project' => $this->project, 'type' => $this->type, 'document' => $this->document, @@ -156,6 +145,6 @@ class Delete extends Event 'resourceType' => $this->resourceType, 'datetime' => $this->datetime, 'hourlyUsageRetentionDatetime' => $this->hourlyUsageRetentionDatetime - ]); + ]; } } diff --git a/src/Appwrite/Event/Event.php b/src/Appwrite/Event/Event.php index 4efc138ec6..8dc0acbe2f 100644 --- a/src/Appwrite/Event/Event.php +++ b/src/Appwrite/Event/Event.php @@ -140,24 +140,6 @@ class Event return $this; } - /** - * Trims the fields of the project document to only include the necessary fields. - * - * @return self - */ - public function trimFields(): self - { - if ($this->project) { - $this->project = new Document([ - '$id' => $this->project->getId(), - '$internalId' => $this->project->getInternalId(), - 'database' => $this->project->getAttribute('database') - ]); - } - - return $this; - } - /** * Get project for this event. * @@ -329,6 +311,27 @@ class Event return $this->params; } + /** + * Get trimmed values for sensitive/large payload fields. + * Override this method in child classes to add more fields to trim. + * + * @return array + */ + protected function trimPayload(): array + { + $trimmed = []; + + if ($this->project) { + $trimmed['project'] = new Document([ + '$id' => $this->project->getId(), + '$internalId' => $this->project->getInternalId(), + 'database' => $this->project->getAttribute('database') + ]); + } + + return $trimmed; + } + /** * Execute Event. * @@ -341,18 +344,29 @@ class Event return false; } - $this->trimFields(); + $client = new Client($this->getQueue(), $this->connection); - $client = new Client($this->queue, $this->connection); + // Merge the base payload with any trimmed values + $payload = array_merge($this->preparePayload(), $this->trimPayload()); - return $client->enqueue([ + return $client->enqueue($payload); + } + + /** + * Prepare payload for queue. Can be overridden by child classes to customize payload. + * + * @return array + */ + protected function preparePayload(): array + { + return [ 'project' => $this->project, 'user' => $this->user, 'userId' => $this->userId, 'payload' => $this->payload, 'context' => $this->context, 'events' => Event::generateEvents($this->getEvent(), $this->getParams()) - ]); + ]; } /** diff --git a/src/Appwrite/Event/Func.php b/src/Appwrite/Event/Func.php index 7c6a2e9194..2e72cb86bf 100644 --- a/src/Appwrite/Event/Func.php +++ b/src/Appwrite/Event/Func.php @@ -3,7 +3,6 @@ namespace Appwrite\Event; use Utopia\Database\Document; -use Utopia\Queue\Client; use Utopia\Queue\Connection; class Func extends Event @@ -172,29 +171,6 @@ class Func extends Event return $this; } - /** - * Returns set custom data for the function event. - * - * @return string - */ - public function getData(): string - { - return $this->data; - } - - /** - * Sets JWT for the function event. - * - * @param string $jwt - * @return self - */ - public function setJWT(string $jwt): self - { - $this->jwt = $jwt; - - return $this; - } - /** * Returns set JWT for the function event. * @@ -206,24 +182,15 @@ class Func extends Event } /** - * Executes the function event and sends it to the functions worker. + * Prepare payload for the function event. * - * @return string|bool - * @throws \InvalidArgumentException + * @return array */ - public function trigger(): string|bool + protected function preparePayload(): array { - if ($this->paused) { - return false; - } - - $this->trimFields(); - - $client = new Client($this->queue, $this->connection); - $events = $this->getEvent() ? Event::generateEvents($this->getEvent(), $this->getParams()) : null; - return $client->enqueue([ + return [ 'project' => $this->project, 'user' => $this->user, 'userId' => $this->userId, @@ -238,6 +205,6 @@ class Func extends Event 'path' => $this->path, 'headers' => $this->headers, 'method' => $this->method, - ]); + ]; } } diff --git a/src/Appwrite/Event/Mail.php b/src/Appwrite/Event/Mail.php index 0db576ba68..1c9e539cdb 100644 --- a/src/Appwrite/Event/Mail.php +++ b/src/Appwrite/Event/Mail.php @@ -2,7 +2,6 @@ namespace Appwrite\Event; -use Utopia\Queue\Client; use Utopia\Queue\Connection; class Mail extends Event @@ -397,22 +396,13 @@ class Mail extends Event } /** - * Executes the event and sends it to the mails worker. + * Prepare the payload for the event * - * @return string|bool - * @throws \InvalidArgumentException + * @return array */ - public function trigger(): string|bool + protected function preparePayload(): array { - if ($this->paused) { - return false; - } - - $this->trimFields(); - - $client = new Client($this->queue, $this->connection); - - return $client->enqueue([ + return [ 'project' => $this->project, 'recipient' => $this->recipient, 'name' => $this->name, @@ -423,6 +413,6 @@ class Mail extends Event 'variables' => $this->variables, 'attachment' => $this->attachment, 'events' => Event::generateEvents($this->getEvent(), $this->getParams()) - ]); + ]; } } diff --git a/src/Appwrite/Event/Messaging.php b/src/Appwrite/Event/Messaging.php index ac2df7f92a..61dbe9c427 100644 --- a/src/Appwrite/Event/Messaging.php +++ b/src/Appwrite/Event/Messaging.php @@ -3,7 +3,6 @@ namespace Appwrite\Event; use Utopia\Database\Document; -use Utopia\Queue\Client; use Utopia\Queue\Connection; class Messaging extends Event @@ -176,21 +175,13 @@ class Messaging extends Event } /** - * Executes the event and sends it to the messaging worker. - * @return string|bool - * @throws \InvalidArgumentException + * Prepare the payload for the event + * + * @return array */ - public function trigger(): string | bool + protected function preparePayload(): array { - if ($this->paused) { - return false; - } - - $this->trimFields(); - - $client = new Client($this->queue, $this->connection); - - return $client->enqueue([ + return [ 'type' => $this->type, 'project' => $this->project, 'user' => $this->user, @@ -198,6 +189,6 @@ class Messaging extends Event 'message' => $this->message, 'recipients' => $this->recipients, 'providerType' => $this->providerType, - ]); + ]; } } diff --git a/src/Appwrite/Event/Migration.php b/src/Appwrite/Event/Migration.php index 376264bce3..5fb2d5a106 100644 --- a/src/Appwrite/Event/Migration.php +++ b/src/Appwrite/Event/Migration.php @@ -3,7 +3,6 @@ namespace Appwrite\Event; use Utopia\Database\Document; -use Utopia\Queue\Client; use Utopia\Queue\Connection; class Migration extends Event @@ -68,25 +67,16 @@ class Migration extends Event } /** - * Executes the migration event and sends it to the migrations worker. + * Prepare the payload for the migration event. * - * @return string|bool - * @throws \InvalidArgumentException + * @return array */ - public function trigger(): string|bool + protected function preparePayload(): array { - if ($this->paused) { - return false; - } - - $this->trimFields(); - - $client = new Client($this->queue, $this->connection); - - return $client->enqueue([ + return [ 'project' => $this->project, 'user' => $this->user, 'migration' => $this->migration, - ]); + ]; } } diff --git a/src/Appwrite/Event/Realtime.php b/src/Appwrite/Event/Realtime.php index f4f00b59d4..481c7918ca 100644 --- a/src/Appwrite/Event/Realtime.php +++ b/src/Appwrite/Event/Realtime.php @@ -43,6 +43,9 @@ class Realtime extends Event $collection = $this->getContext('collection'); $bucket = $this->getContext('bucket'); + // var_dump("-------------------- In Realtime trigger ---------------"); + // var_dump($this->getProject()); + $target = RealtimeAdapter::fromPayload( // Pass first, most verbose event pattern event: $allEvents[0], diff --git a/src/Appwrite/Event/Usage.php b/src/Appwrite/Event/Usage.php index f17c048a2e..5609859f37 100644 --- a/src/Appwrite/Event/Usage.php +++ b/src/Appwrite/Event/Usage.php @@ -3,7 +3,6 @@ namespace Appwrite\Event; use Utopia\Database\Document; -use Utopia\Queue\Client; use Utopia\Queue\Connection; class Usage extends Event @@ -51,6 +50,20 @@ class Usage extends Event return $this; } + /** + * Prepare the payload for the usage event. + * + * @return array + */ + protected function preparePayload(): array + { + return [ + 'project' => $this->project, + 'reduce' => $this->reduce, + 'metrics' => $this->metrics, + ]; + } + /** * Sends metrics to the usage worker. * @@ -58,22 +71,8 @@ class Usage extends Event */ public function trigger(): string|bool { - if ($this->paused) { - return false; - } - - $this->trimFields(); - - $client = new Client($this->queue, $this->connection); - - $result = $client->enqueue([ - 'project' => $this->project, - 'reduce' => $this->reduce, - 'metrics' => $this->metrics, - ]); - + parent::trigger(); $this->metrics = []; - - return $result; + return true; } } diff --git a/src/Appwrite/Event/UsageDump.php b/src/Appwrite/Event/UsageDump.php index 83206e4add..6f44de4eda 100644 --- a/src/Appwrite/Event/UsageDump.php +++ b/src/Appwrite/Event/UsageDump.php @@ -2,7 +2,6 @@ namespace Appwrite\Event; -use Utopia\Queue\Client; use Utopia\Queue\Connection; class UsageDump extends Event @@ -32,22 +31,14 @@ class UsageDump extends Event } /** - * Sends metrics to the usage worker. + * Prepare the payload for the usage dump event. * - * @return string|bool + * @return array */ - public function trigger(): string|bool + protected function preparePayload(): array { - if ($this->paused) { - return false; - } - - $this->trimFields(); - - $client = new Client($this->queue, $this->connection); - - return $client->enqueue([ + return [ 'stats' => $this->stats, - ]); + ]; } } diff --git a/src/Appwrite/Event/Webhook.php b/src/Appwrite/Event/Webhook.php index 9d14dcdc3d..3e0dbe446f 100644 --- a/src/Appwrite/Event/Webhook.php +++ b/src/Appwrite/Event/Webhook.php @@ -15,10 +15,17 @@ class Webhook extends Event ->setClass(Event::WEBHOOK_CLASS_NAME); } - public function trigger(): string|bool + /** + * Trim the payload for the webhook event. + * + * @return array + */ + public function trimPayload(): array { - /** Filter out context and trim project to keep the payload small */ - $this->context = []; - return parent::trigger(); + $trimmed = parent::trimPayload(); + if (isset($this->context)) { + $trimmed['context'] = []; + } + return $trimmed; } } diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 9b9f03a100..d8d1eb8eb5 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -375,7 +375,7 @@ class FunctionsCustomServerTest extends Scope $this->assertEquals(200, $deployment['headers']['status-code']); $this->assertEquals('ready', $deployment['body']['status']); - }, 500000, 1000); + }, 50000, 1000); $function = $this->getFunction($functionId); From a2962b6b95db0ec079cbfacf121a7895dd37c6f6 Mon Sep 17 00:00:00 2001 From: Christy Jacob <christyjacob4@gmail.com> Date: Fri, 17 Jan 2025 10:42:06 +0530 Subject: [PATCH 38/47] chore: review comments --- app/controllers/api/functions.php | 2 -- phpunit.xml | 2 +- src/Appwrite/Event/Event.php | 1 + 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index f459875fca..f7606ed66b 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -402,8 +402,6 @@ App::post('/v1/functions') ]); - var_dump("-------------------- Create Function ---------------"); - var_dump($project); $target = Realtime::fromPayload( // Pass first, most verbose event pattern event: $allEvents[0], diff --git a/phpunit.xml b/phpunit.xml index 598b730908..4c4e55ea4e 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -6,7 +6,7 @@ convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" - stopOnFailure="true" + stopOnFailure="false" > <extensions> <extension class="Appwrite\Tests\TestHook" /> diff --git a/src/Appwrite/Event/Event.php b/src/Appwrite/Event/Event.php index 8dc0acbe2f..5cd5f8e7d6 100644 --- a/src/Appwrite/Event/Event.php +++ b/src/Appwrite/Event/Event.php @@ -344,6 +344,7 @@ class Event return false; } + /** The getter is required since events like Databases need to override the queue name depending on the project */ $client = new Client($this->getQueue(), $this->connection); // Merge the base payload with any trimmed values From f66f75b8085f537b745b47af5ae70ae765551388 Mon Sep 17 00:00:00 2001 From: Christy Jacob <christyjacob4@gmail.com> Date: Fri, 17 Jan 2025 10:43:02 +0530 Subject: [PATCH 39/47] chore: review comments --- app/controllers/api/functions.php | 1 - src/Appwrite/Event/Realtime.php | 3 --- 2 files changed, 4 deletions(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index f7606ed66b..efd6967408 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -401,7 +401,6 @@ App::post('/v1/functions') 'ruleId' => $rule->getId(), ]); - $target = Realtime::fromPayload( // Pass first, most verbose event pattern event: $allEvents[0], diff --git a/src/Appwrite/Event/Realtime.php b/src/Appwrite/Event/Realtime.php index 481c7918ca..f4f00b59d4 100644 --- a/src/Appwrite/Event/Realtime.php +++ b/src/Appwrite/Event/Realtime.php @@ -43,9 +43,6 @@ class Realtime extends Event $collection = $this->getContext('collection'); $bucket = $this->getContext('bucket'); - // var_dump("-------------------- In Realtime trigger ---------------"); - // var_dump($this->getProject()); - $target = RealtimeAdapter::fromPayload( // Pass first, most verbose event pattern event: $allEvents[0], From 455bc3370cf40a58c27e4a972920585a2923c2ad Mon Sep 17 00:00:00 2001 From: Christy Jacob <christyjacob4@gmail.com> Date: Fri, 17 Jan 2025 11:16:21 +0530 Subject: [PATCH 40/47] chore: fix tests --- src/Appwrite/Event/Func.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Appwrite/Event/Func.php b/src/Appwrite/Event/Func.php index 2e72cb86bf..b3945fccb8 100644 --- a/src/Appwrite/Event/Func.php +++ b/src/Appwrite/Event/Func.php @@ -181,6 +181,18 @@ class Func extends Event return $this->jwt; } + /** + * Sets JWT for the function event. + * + * @param string $jwt + * @return self + */ + public function setJWT(string $jwt): self + { + $this->jwt = $jwt; + return $this; + } + /** * Prepare payload for the function event. * From ef0b836987864e8ab167c88b3f4d34be9e6bea7b Mon Sep 17 00:00:00 2001 From: Christy Jacob <christyjacob4@gmail.com> Date: Fri, 17 Jan 2025 11:19:34 +0530 Subject: [PATCH 41/47] chore: composer update --- composer.lock | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/composer.lock b/composer.lock index e60804b733..980dcdcd29 100644 --- a/composer.lock +++ b/composer.lock @@ -3379,16 +3379,16 @@ }, { "name": "utopia-php/compression", - "version": "0.1.2", + "version": "0.1.3", "source": { "type": "git", "url": "https://github.com/utopia-php/compression.git", - "reference": "6062f70596415f8d5de40a589367b0eb2a435f98" + "reference": "66f093557ba66d98245e562036182016c7dcfe8a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/compression/zipball/6062f70596415f8d5de40a589367b0eb2a435f98", - "reference": "6062f70596415f8d5de40a589367b0eb2a435f98", + "url": "https://api.github.com/repos/utopia-php/compression/zipball/66f093557ba66d98245e562036182016c7dcfe8a", + "reference": "66f093557ba66d98245e562036182016c7dcfe8a", "shasum": "" }, "require": { @@ -3419,9 +3419,9 @@ ], "support": { "issues": "https://github.com/utopia-php/compression/issues", - "source": "https://github.com/utopia-php/compression/tree/0.1.2" + "source": "https://github.com/utopia-php/compression/tree/0.1.3" }, - "time": "2024-11-08T14:59:54+00:00" + "time": "2025-01-15T15:15:51+00:00" }, { "name": "utopia-php/config", @@ -3678,16 +3678,16 @@ }, { "name": "utopia-php/framework", - "version": "0.33.15", + "version": "0.33.16", "source": { "type": "git", "url": "https://github.com/utopia-php/http.git", - "reference": "83b0628900c2c53e8c3efbf069f3e13050295edc" + "reference": "e91d4c560d1b809e25faa63d564fef034363b50f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/http/zipball/83b0628900c2c53e8c3efbf069f3e13050295edc", - "reference": "83b0628900c2c53e8c3efbf069f3e13050295edc", + "url": "https://api.github.com/repos/utopia-php/http/zipball/e91d4c560d1b809e25faa63d564fef034363b50f", + "reference": "e91d4c560d1b809e25faa63d564fef034363b50f", "shasum": "" }, "require": { @@ -3719,9 +3719,9 @@ ], "support": { "issues": "https://github.com/utopia-php/http/issues", - "source": "https://github.com/utopia-php/http/tree/0.33.15" + "source": "https://github.com/utopia-php/http/tree/0.33.16" }, - "time": "2024-12-10T13:07:04+00:00" + "time": "2025-01-16T15:58:50+00:00" }, { "name": "utopia-php/image", @@ -4095,16 +4095,16 @@ }, { "name": "utopia-php/platform", - "version": "0.7.2", + "version": "0.7.1", "source": { "type": "git", "url": "https://github.com/utopia-php/platform.git", - "reference": "6f9243848f1c6466f6509fd01c7e18306a6d8caf" + "reference": "3433a0f1a54988f2a59c735f507745cb2c24638a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/platform/zipball/6f9243848f1c6466f6509fd01c7e18306a6d8caf", - "reference": "6f9243848f1c6466f6509fd01c7e18306a6d8caf", + "url": "https://api.github.com/repos/utopia-php/platform/zipball/3433a0f1a54988f2a59c735f507745cb2c24638a", + "reference": "3433a0f1a54988f2a59c735f507745cb2c24638a", "shasum": "" }, "require": { @@ -4139,9 +4139,9 @@ ], "support": { "issues": "https://github.com/utopia-php/platform/issues", - "source": "https://github.com/utopia-php/platform/tree/0.7.2" + "source": "https://github.com/utopia-php/platform/tree/0.7.1" }, - "time": "2025-01-15T05:56:26+00:00" + "time": "2024-10-22T10:27:49+00:00" }, { "name": "utopia-php/pools", From e343a1068eca9322a1fc6df7c1b50a8d8b7807d8 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 17 Jan 2025 09:55:14 +0000 Subject: [PATCH 42/47] fix: linter --- composer.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.lock b/composer.lock index f89889f534..980dcdcd29 100644 --- a/composer.lock +++ b/composer.lock @@ -4095,16 +4095,16 @@ }, { "name": "utopia-php/platform", - "version": "0.7.2", + "version": "0.7.1", "source": { "type": "git", "url": "https://github.com/utopia-php/platform.git", - "reference": "6f9243848f1c6466f6509fd01c7e18306a6d8caf" + "reference": "3433a0f1a54988f2a59c735f507745cb2c24638a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/platform/zipball/6f9243848f1c6466f6509fd01c7e18306a6d8caf", - "reference": "6f9243848f1c6466f6509fd01c7e18306a6d8caf", + "url": "https://api.github.com/repos/utopia-php/platform/zipball/3433a0f1a54988f2a59c735f507745cb2c24638a", + "reference": "3433a0f1a54988f2a59c735f507745cb2c24638a", "shasum": "" }, "require": { @@ -4139,9 +4139,9 @@ ], "support": { "issues": "https://github.com/utopia-php/platform/issues", - "source": "https://github.com/utopia-php/platform/tree/0.7.2" + "source": "https://github.com/utopia-php/platform/tree/0.7.1" }, - "time": "2025-01-15T05:56:26+00:00" + "time": "2024-10-22T10:27:49+00:00" }, { "name": "utopia-php/pools", From 40f16fab500e0941be5ef21eb4a2a9abb4643a77 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 17 Jan 2025 10:17:49 +0000 Subject: [PATCH 43/47] docs: add compression vars to documentation --- app/config/variables.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/config/variables.php b/app/config/variables.php index 113fbae335..57810525c7 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -268,6 +268,24 @@ return [ 'question' => '', 'filter' => '' ], + [ + 'name' => '_APP_COMPRESSION_ENABLED', + 'description' => 'This option allows you to enable or disable the response compression for the Appwrite API. It\'s enabled by default with value "enabled", and to disable it, pass value "disabled".', + 'introduction' => '1.6.0', + 'default' => 'enabled', + 'required' => false, + 'question' => '', + 'filter' => '' + ], + [ + 'name' => '_APP_COMPRESSION_MIN_SIZE_BYTES', + 'description' => 'This option allows you to set the minimum size in bytes for the response compression to be applied. The default value is 1024 bytes.', + 'introduction' => '1.6.0', + 'default' => 1024, + 'required' => false, + 'question' => '', + 'filter' => '' + ] ], ], [ From 5b28e7c478fe4630cf82e3c0e7d8aef2db7acdb4 Mon Sep 17 00:00:00 2001 From: Christy Jacob <christyjacob4@gmail.com> Date: Fri, 17 Jan 2025 11:48:19 +0000 Subject: [PATCH 44/47] chore: review comments --- app/controllers/shared/api.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 592c7b8a49..2f094e33ef 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -76,7 +76,7 @@ $eventDatabaseListener = function (Document $project, Document $document, Respon /** Trigger webhooks events only if a project has them enabled */ - if ($project->getAttribute('webhooks', []) !== []) { + if (!empty($project->getAttribute('webhooks'))) { $queueForWebhooks ->from($queueForEvents) ->trigger(); @@ -697,7 +697,7 @@ App::shutdown() * But it might have performance implications on the API due to the number of webhooks etc. * Some profiling is needed to see if this is a problem. */ - if ($project->getAttribute('webhooks', []) !== []) { + if (!empty($project->getAttribute('webhooks'))) { $queueForWebhooks ->from($queueForEvents) ->trigger(); From e4efaf1efa36ac2aa8cd3754e9cca29aecaa2d4d Mon Sep 17 00:00:00 2001 From: Christy Jacob <christyjacob4@gmail.com> Date: Fri, 17 Jan 2025 22:53:31 +0530 Subject: [PATCH 45/47] fix: maintenance job missing type --- .env | 2 +- src/Appwrite/Platform/Tasks/Maintenance.php | 17 +++++------------ src/Appwrite/Platform/Workers/Deletes.php | 3 +++ 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/.env b/.env index 8f7d7996e7..53a93b5fb2 100644 --- a/.env +++ b/.env @@ -79,7 +79,7 @@ _APP_FUNCTIONS_RUNTIMES_NETWORK=runtimes _APP_EXECUTOR_SECRET=your-secret-key _APP_EXECUTOR_HOST=http://proxy/v1 _APP_FUNCTIONS_RUNTIMES=php-8.0,node-18.0,python-3.9,ruby-3.1 -_APP_MAINTENANCE_INTERVAL=86400 +_APP_MAINTENANCE_INTERVAL=60 _APP_MAINTENANCE_DELAY= _APP_MAINTENANCE_RETENTION_CACHE=2592000 _APP_MAINTENANCE_RETENTION_EXECUTION=1209600 diff --git a/src/Appwrite/Platform/Tasks/Maintenance.php b/src/Appwrite/Platform/Tasks/Maintenance.php index a7558934b5..2d37bdbf70 100644 --- a/src/Appwrite/Platform/Tasks/Maintenance.php +++ b/src/Appwrite/Platform/Tasks/Maintenance.php @@ -47,9 +47,12 @@ class Maintenance extends Action Console::info("[{$time}] Notifying workers with maintenance tasks every {$interval} seconds"); $this->foreachProject($dbForPlatform, function (Document $project) use ($queueForDeletes, $usageStatsRetentionHourly) { - $queueForDeletes->setProject($project); + $queueForDeletes + ->setType(DELETE_TYPE_MAINTENANCE) + ->setProject($project) + ->setUsageRetentionHourlyDateTime(DateTime::addSeconds(new \DateTime(), -1 * $usageStatsRetentionHourly)) + ->trigger(); - $this->notifyProjects($queueForDeletes, $usageStatsRetentionHourly); }); $this->notifyDeleteConnections($queueForDeletes); @@ -59,16 +62,6 @@ class Maintenance extends Action }, $interval, $delay); } - /** - * Hook to allow sub-classes to extend project-level maintenance functionality. - */ - protected function notifyProjects(Delete $queueForDeletes, int $usageStatsRetentionHourly): void - { - $queueForDeletes - ->setUsageRetentionHourlyDateTime(DateTime::addSeconds(new \DateTime(), -1 * $usageStatsRetentionHourly)) - ->trigger(); - } - protected function foreachProject(Database $dbForPlatform, callable $callback): void { // TODO: @Meldiron name of this method no longer matches. It does not delete, and it gives whole document diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index 539bbd61f9..dcfbd1d1e7 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -83,6 +83,9 @@ class Deletes extends Action $log->addTag('projectId', $project->getId()); $log->addTag('type', $type); + var_dump("--------------------------------"); + var_dump($type); + switch (\strval($type)) { case DELETE_TYPE_DOCUMENT: switch ($document->getCollection()) { From e7d33ebc5258b42530f4c49ca03e7bbdc6cd9324 Mon Sep 17 00:00:00 2001 From: Christy Jacob <christyjacob4@gmail.com> Date: Fri, 17 Jan 2025 22:55:00 +0530 Subject: [PATCH 46/47] fix: maintenance job missing type --- .env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env b/.env index 53a93b5fb2..8f7d7996e7 100644 --- a/.env +++ b/.env @@ -79,7 +79,7 @@ _APP_FUNCTIONS_RUNTIMES_NETWORK=runtimes _APP_EXECUTOR_SECRET=your-secret-key _APP_EXECUTOR_HOST=http://proxy/v1 _APP_FUNCTIONS_RUNTIMES=php-8.0,node-18.0,python-3.9,ruby-3.1 -_APP_MAINTENANCE_INTERVAL=60 +_APP_MAINTENANCE_INTERVAL=86400 _APP_MAINTENANCE_DELAY= _APP_MAINTENANCE_RETENTION_CACHE=2592000 _APP_MAINTENANCE_RETENTION_EXECUTION=1209600 From dc651f632af6358b5085101603a522d7d5861098 Mon Sep 17 00:00:00 2001 From: Christy Jacob <christyjacob4@gmail.com> Date: Fri, 17 Jan 2025 22:55:16 +0530 Subject: [PATCH 47/47] fix: maintenance job missing type --- src/Appwrite/Platform/Workers/Deletes.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index dcfbd1d1e7..539bbd61f9 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -83,9 +83,6 @@ class Deletes extends Action $log->addTag('projectId', $project->getId()); $log->addTag('type', $type); - var_dump("--------------------------------"); - var_dump($type); - switch (\strval($type)) { case DELETE_TYPE_DOCUMENT: switch ($document->getCollection()) {