diff --git a/.github/workflows/phpunit-mysql.yml b/.github/workflows/phpunit-mysql.yml index 178b032da..b53f3e8ab 100644 --- a/.github/workflows/phpunit-mysql.yml +++ b/.github/workflows/phpunit-mysql.yml @@ -133,6 +133,11 @@ jobs: working-directory: apps/${{ env.APP_NAME }} run: composer run test:integration + - name: Print logs + if: always() + run: | + cat data/nextcloud.log + - name: Skipped # Fail the action when neither unit nor integration tests ran if: steps.check_phpunit.outcome == 'failure' && steps.check_integration.outcome == 'failure' diff --git a/.github/workflows/phpunit-oci.yml b/.github/workflows/phpunit-oci.yml index 540ded77b..ddff030df 100644 --- a/.github/workflows/phpunit-oci.yml +++ b/.github/workflows/phpunit-oci.yml @@ -125,6 +125,11 @@ jobs: working-directory: apps/${{ env.APP_NAME }} run: composer run test:integration + - name: Print logs + if: always() + run: | + cat data/nextcloud.log + - name: Skipped # Fail the action when neither unit nor integration tests ran if: steps.check_phpunit.outcome == 'failure' && steps.check_integration.outcome == 'failure' diff --git a/.github/workflows/phpunit-pgsql.yml b/.github/workflows/phpunit-pgsql.yml index 861548580..6c4c80575 100644 --- a/.github/workflows/phpunit-pgsql.yml +++ b/.github/workflows/phpunit-pgsql.yml @@ -130,6 +130,11 @@ jobs: working-directory: apps/${{ env.APP_NAME }} run: composer run test:integration + - name: Print logs + if: always() + run: | + cat data/nextcloud.log + - name: Skipped # Fail the action when neither unit nor integration tests ran if: steps.check_phpunit.outcome == 'failure' && steps.check_integration.outcome == 'failure' diff --git a/.github/workflows/phpunit-sqlite.yml b/.github/workflows/phpunit-sqlite.yml index 130bbdd45..b46262e49 100644 --- a/.github/workflows/phpunit-sqlite.yml +++ b/.github/workflows/phpunit-sqlite.yml @@ -119,6 +119,11 @@ jobs: working-directory: apps/${{ env.APP_NAME }} run: composer run test:integration + - name: Print logs + if: always() + run: | + cat data/nextcloud.log + - name: Skipped # Fail the action when neither unit nor integration tests ran if: steps.check_phpunit.outcome == 'failure' && steps.check_integration.outcome == 'failure' diff --git a/appinfo/routes.php b/appinfo/routes.php index d9b217f9c..b652f56ba 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -3,9 +3,11 @@ declare(strict_types=1); /** + * @copyright Copyright (c) 2023, Joas Schilling + * @copyright Copyright (c) 2016, ownCloud, Inc. + * * @author Joas Schilling * - * @copyright Copyright (c) 2016, ownCloud, Inc. * @license AGPL-3.0 * * This code is free software: you can redistribute it and/or modify @@ -26,6 +28,7 @@ 'ocs' => [ ['name' => 'Endpoint#listNotifications', 'url' => '/api/{apiVersion}/notifications', 'verb' => 'GET', 'requirements' => ['apiVersion' => 'v(1|2)']], ['name' => 'Endpoint#getNotification', 'url' => '/api/{apiVersion}/notifications/{id}', 'verb' => 'GET', 'requirements' => ['apiVersion' => 'v(1|2)', 'id' => '\d+']], + ['name' => 'Endpoint#confirmIdsForUser', 'url' => '/api/{apiVersion}/notifications/exists', 'verb' => 'POST', 'requirements' => ['apiVersion' => 'v(1|2)']], ['name' => 'Endpoint#deleteNotification', 'url' => '/api/{apiVersion}/notifications/{id}', 'verb' => 'DELETE', 'requirements' => ['apiVersion' => 'v(1|2)', 'id' => '\d+']], ['name' => 'Endpoint#deleteAllNotifications', 'url' => '/api/{apiVersion}/notifications', 'verb' => 'DELETE', 'requirements' => ['apiVersion' => 'v(1|2)']], ['name' => 'Push#registerDevice', 'url' => '/api/{apiVersion}/push', 'verb' => 'POST', 'requirements' => ['apiVersion' => 'v2']], diff --git a/docs/ocs-endpoint-v2.md b/docs/ocs-endpoint-v2.md index 1c679db50..34d70ca50 100644 --- a/docs/ocs-endpoint-v2.md +++ b/docs/ocs-endpoint-v2.md @@ -168,3 +168,12 @@ In order to delete a notification, you can send a DELETE request against `/ocs/v In order to delete all notifications, you can send a DELETE request against `/ocs/v2.php/apps/notifications/api/v2/notifications` **Note:** This endpoint was added for Nextcloud 14, so check for the `delete-all` capability first. + + +## Check existance of notifications for a user + +In order to check whether a set of notification ids (max. 200 items per request) still exist for a user, +a client can send a POST request against `/ocs/v2.php/apps/notifications/api/v2/notifications/exists` with +the integer list provided as `ids` field on the POST body. + +**Note:** This endpoint was added for Nextcloud 27, so check for the `exists` capability first. diff --git a/lib/App.php b/lib/App.php index 866cdca10..6ac5e688b 100644 --- a/lib/App.php +++ b/lib/App.php @@ -3,9 +3,10 @@ declare(strict_types=1); /** + * @copyright Copyright (c) 2016, ownCloud, Inc. + * * @author Joas Schilling * - * @copyright Copyright (c) 2016, ownCloud, Inc. * @license AGPL-3.0 * * This code is free software: you can redistribute it and/or modify diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 1e76210bf..7ac23e347 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -2,9 +2,11 @@ declare(strict_types=1); /** + * @copyright Copyright (c) 2023, Joas Schilling + * @copyright Copyright (c) 2016, ownCloud, Inc. + * * @author Joas Schilling * - * @copyright Copyright (c) 2016, ownCloud, Inc. * @license AGPL-3.0 * * This code is free software: you can redistribute it and/or modify diff --git a/lib/BackgroundJob/GenerateUserSettings.php b/lib/BackgroundJob/GenerateUserSettings.php index a8b42c25a..d62536a41 100644 --- a/lib/BackgroundJob/GenerateUserSettings.php +++ b/lib/BackgroundJob/GenerateUserSettings.php @@ -2,9 +2,11 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2021 Joas Schilling + * @copyright Copyright (c) 2021, Joas Schilling * - * @license GNU AGPL version 3 or any later version + * @author Joas Schilling + * + * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as diff --git a/lib/BackgroundJob/SendNotificationMails.php b/lib/BackgroundJob/SendNotificationMails.php index 97e64cd31..c455e86a6 100644 --- a/lib/BackgroundJob/SendNotificationMails.php +++ b/lib/BackgroundJob/SendNotificationMails.php @@ -2,9 +2,11 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2021 Julien Barnoin + * @copyright Copyright (c) 2021, Julien Barnoin * - * @license GNU AGPL version 3 or any later version + * @author Julien Barnoin + * + * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as diff --git a/lib/Capabilities.php b/lib/Capabilities.php index c2c5cb05f..f6eac3708 100644 --- a/lib/Capabilities.php +++ b/lib/Capabilities.php @@ -3,9 +3,10 @@ declare(strict_types=1); /** + * @copyright Copyright (c) 2016, ownCloud, Inc. + * * @author Joas Schilling * - * @copyright Copyright (c) 2016, ownCloud, Inc. * @license AGPL-3.0 * * This code is free software: you can redistribute it and/or modify @@ -50,6 +51,7 @@ public function getCapabilities(): array { 'rich-strings', 'action-web', 'user-status', + 'exists', ], 'push' => [ 'devices', diff --git a/lib/Command/Generate.php b/lib/Command/Generate.php index 11b527339..2a07d2706 100644 --- a/lib/Command/Generate.php +++ b/lib/Command/Generate.php @@ -3,11 +3,11 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2017 Joas Schilling + * @copyright Copyright (c) 2017, Joas Schilling * * @author Joas Schilling * - * @license GNU AGPL version 3 or any later version + * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as diff --git a/lib/Command/TestPush.php b/lib/Command/TestPush.php index 41bc99ed4..3dcb6bdfe 100644 --- a/lib/Command/TestPush.php +++ b/lib/Command/TestPush.php @@ -3,11 +3,11 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2017 Joas Schilling + * @copyright Copyright (c) 2017, Joas Schilling * * @author Joas Schilling * - * @license GNU AGPL version 3 or any later version + * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as diff --git a/lib/Controller/APIController.php b/lib/Controller/APIController.php index 392c2de02..eb7a5ee1d 100644 --- a/lib/Controller/APIController.php +++ b/lib/Controller/APIController.php @@ -3,11 +3,11 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2017 Joas Schilling + * @copyright Copyright (c) 2017, Joas Schilling * * @author Joas Schilling * - * @license GNU AGPL version 3 or any later version + * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as diff --git a/lib/Controller/EndpointController.php b/lib/Controller/EndpointController.php index 2f83ffe7a..acbe1a795 100644 --- a/lib/Controller/EndpointController.php +++ b/lib/Controller/EndpointController.php @@ -3,9 +3,11 @@ declare(strict_types=1); /** + * @copyright Copyright (c) 2023, Joas Schilling + * @copyright Copyright (c) 2016, ownCloud, Inc. + * * @author Joas Schilling * - * @copyright Copyright (c) 2016, ownCloud, Inc. * @license AGPL-3.0 * * This code is free software: you can redistribute it and/or modify @@ -169,6 +171,35 @@ public function getNotification(string $apiVersion, int $id): DataResponse { return new DataResponse($this->notificationToArray($id, $notification, $apiVersion, $hasActiveTalkDesktop)); } + /** + * @NoAdminRequired + * + * @param string $apiVersion + * @param int[] $ids + * @return DataResponse + */ + public function confirmIdsForUser(string $apiVersion, array $ids): DataResponse { + if (!$this->manager->hasNotifiers()) { + return new DataResponse([], Http::STATUS_OK); + } + + if (empty($ids)) { + return new DataResponse([], Http::STATUS_OK); + } + + if (count($ids) > 200) { + return new DataResponse([], Http::STATUS_BAD_REQUEST); + } + + $ids = array_unique(array_filter(array_map( + static fn ($id) => is_numeric($id) ? (int) $id : 0, + $ids + ))); + + $existingIds = $this->handler->confirmIdsForUser($this->getCurrentUser(), $ids); + return new DataResponse($existingIds, Http::STATUS_OK); + } + /** * @NoAdminRequired * diff --git a/lib/Controller/PushController.php b/lib/Controller/PushController.php index 6693aaedf..6857a20dd 100644 --- a/lib/Controller/PushController.php +++ b/lib/Controller/PushController.php @@ -3,9 +3,11 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2017 Joas Schilling + * @copyright Copyright (c) 2017, Joas Schilling * - * @license GNU AGPL version 3 or any later version + * @author Joas Schilling + * + * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php index eb0992b51..f5d35cba7 100644 --- a/lib/Controller/SettingsController.php +++ b/lib/Controller/SettingsController.php @@ -3,9 +3,11 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2021 Julien Barnoin + * @copyright Copyright (c) 2021, Julien Barnoin * - * @license GNU AGPL version 3 or any later version + * @author Julien Barnoin + * + * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as diff --git a/lib/Exceptions/NotificationNotFoundException.php b/lib/Exceptions/NotificationNotFoundException.php index a0249075f..1f3f50271 100644 --- a/lib/Exceptions/NotificationNotFoundException.php +++ b/lib/Exceptions/NotificationNotFoundException.php @@ -7,7 +7,7 @@ * * @author Joas Schilling * - * @license GNU AGPL version 3 or any later version + * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as diff --git a/lib/FakeUser.php b/lib/FakeUser.php index 3a920a0c2..4ee7b6c15 100644 --- a/lib/FakeUser.php +++ b/lib/FakeUser.php @@ -2,9 +2,11 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2022 Joas Schilling + * @copyright Copyright (c) 2022, Joas Schilling * - * @license GNU AGPL version 3 or any later version + * @author Joas Schilling + * + * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as diff --git a/lib/Handler.php b/lib/Handler.php index 4601d0fdb..d1ca39928 100644 --- a/lib/Handler.php +++ b/lib/Handler.php @@ -3,9 +3,11 @@ declare(strict_types=1); /** + * @copyright Copyright (c) 2023, Joas Schilling + * @copyright Copyright (c) 2016, ownCloud, Inc. + * * @author Joas Schilling * - * @copyright Copyright (c) 2016, ownCloud, Inc. * @license AGPL-3.0 * * This code is free software: you can redistribute it and/or modify @@ -217,6 +219,30 @@ public function getById(int $id, string $user): INotification { } } + /** + * Confirm that the notification ids still exist for the user + * + * @param string $user + * @param int[] $ids + * @return int[] + */ + public function confirmIdsForUser(string $user, array $ids): array { + $query = $this->connection->getQueryBuilder(); + $query->select('notification_id') + ->from('notifications') + ->where($query->expr()->in('notification_id', $query->createNamedParameter($ids, IQueryBuilder::PARAM_INT_ARRAY))) + ->andWhere($query->expr()->eq('user', $query->createNamedParameter($user))); + $result = $query->executeQuery(); + + $existing = []; + while ($row = $result->fetch()) { + $existing[] = (int) $row['notification_id']; + } + $result->closeCursor(); + + return $existing; + } + /** * Get the notifications after (and excluding) the given id * diff --git a/lib/Listener/BeforeTemplateRenderedListener.php b/lib/Listener/BeforeTemplateRenderedListener.php index 5e7c86f30..4f5280644 100644 --- a/lib/Listener/BeforeTemplateRenderedListener.php +++ b/lib/Listener/BeforeTemplateRenderedListener.php @@ -3,11 +3,11 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2021 Joas Schilling + * @copyright Copyright (c) 2021, Joas Schilling * * @author Joas Schilling * - * @license GNU AGPL version 3 or any later version + * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as diff --git a/lib/Listener/PostLoginListener.php b/lib/Listener/PostLoginListener.php index 4eb379c7e..2cafdf768 100644 --- a/lib/Listener/PostLoginListener.php +++ b/lib/Listener/PostLoginListener.php @@ -3,11 +3,11 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2022 Nikita Toponen + * @copyright Copyright (c) 2022, Nikita Toponen * * @author Nikita Toponen * - * @license GNU AGPL version 3 or any later version + * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as diff --git a/lib/Listener/UserCreatedListener.php b/lib/Listener/UserCreatedListener.php index 5eb752852..7178a87e3 100644 --- a/lib/Listener/UserCreatedListener.php +++ b/lib/Listener/UserCreatedListener.php @@ -2,11 +2,11 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2022 Nikita Toponen + * @copyright Copyright (c) 2022, Nikita Toponen * * @author Nikita Toponen * - * @license GNU AGPL version 3 or any later version + * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as diff --git a/lib/Listener/UserDeletedListener.php b/lib/Listener/UserDeletedListener.php index a6d3494d5..5c31f04db 100644 --- a/lib/Listener/UserDeletedListener.php +++ b/lib/Listener/UserDeletedListener.php @@ -3,11 +3,11 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2020 Daniel Kesselberg + * @copyright Copyright (c) 2020, Daniel Kesselberg * * @author Daniel Kesselberg * - * @license GNU AGPL version 3 or any later version + * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as diff --git a/lib/MailNotifications.php b/lib/MailNotifications.php index 5ff3e9441..747b9e097 100644 --- a/lib/MailNotifications.php +++ b/lib/MailNotifications.php @@ -3,9 +3,11 @@ declare(strict_types=1); /** + * @copyright Copyright (c) 2021, Julien Barnoin + * * @author Julien Barnoin * - * @license GNU AGPL version 3 or any later version + * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as diff --git a/lib/Migration/Version2004Date20190107135757.php b/lib/Migration/Version2004Date20190107135757.php index 2e540aa9c..aafd78ad6 100644 --- a/lib/Migration/Version2004Date20190107135757.php +++ b/lib/Migration/Version2004Date20190107135757.php @@ -2,9 +2,11 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2019 Joas Schilling + * @copyright Copyright (c) 2019, Joas Schilling * - * @license GNU AGPL version 3 or any later version + * @author Joas Schilling + * + * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as diff --git a/lib/Migration/Version2010Date20210218082811.php b/lib/Migration/Version2010Date20210218082811.php index 5baf50e9f..c2510c9cd 100644 --- a/lib/Migration/Version2010Date20210218082811.php +++ b/lib/Migration/Version2010Date20210218082811.php @@ -2,9 +2,11 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2021 Joas Schilling + * @copyright Copyright (c) 2021, Joas Schilling * - * @license GNU AGPL version 3 or any later version + * @author Joas Schilling + * + * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as diff --git a/lib/Migration/Version2010Date20210218082855.php b/lib/Migration/Version2010Date20210218082855.php index af8d0c350..8eb5555bd 100644 --- a/lib/Migration/Version2010Date20210218082855.php +++ b/lib/Migration/Version2010Date20210218082855.php @@ -2,9 +2,11 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2021 Joas Schilling + * @copyright Copyright (c) 2021, Joas Schilling * - * @license GNU AGPL version 3 or any later version + * @author Joas Schilling + * + * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as diff --git a/lib/Migration/Version2011Date20210930134607.php b/lib/Migration/Version2011Date20210930134607.php index 0f87c944c..98833e720 100644 --- a/lib/Migration/Version2011Date20210930134607.php +++ b/lib/Migration/Version2011Date20210930134607.php @@ -3,9 +3,11 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2021 Joas Schilling + * @copyright Copyright (c) 2021, Joas Schilling * - * @license GNU AGPL version 3 or any later version + * @author Joas Schilling + * + * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as diff --git a/lib/Migration/Version2011Date20220826074907.php b/lib/Migration/Version2011Date20220826074907.php index 60119a7b3..f5c4ee607 100644 --- a/lib/Migration/Version2011Date20220826074907.php +++ b/lib/Migration/Version2011Date20220826074907.php @@ -3,9 +3,11 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2022 Joas Schilling + * @copyright Copyright (c) 2022, Joas Schilling * - * @license GNU AGPL version 3 or any later version + * @author Joas Schilling + * + * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as diff --git a/lib/Model/Settings.php b/lib/Model/Settings.php index 39496ba94..7f5322b01 100644 --- a/lib/Model/Settings.php +++ b/lib/Model/Settings.php @@ -2,9 +2,11 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2021 Joas Schilling + * @copyright Copyright (c) 2021, Joas Schilling * - * @license GNU AGPL version 3 or any later version + * @author Joas Schilling + * + * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as diff --git a/lib/Model/SettingsMapper.php b/lib/Model/SettingsMapper.php index 4925c9dd6..58c199221 100644 --- a/lib/Model/SettingsMapper.php +++ b/lib/Model/SettingsMapper.php @@ -2,9 +2,11 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2021 Joas Schilling + * @copyright Copyright (c) 2021, Joas Schilling * - * @license GNU AGPL version 3 or any later version + * @author Joas Schilling + * + * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as diff --git a/lib/Notifier/AdminNotifications.php b/lib/Notifier/AdminNotifications.php index b8923ce98..c15c9e9a3 100644 --- a/lib/Notifier/AdminNotifications.php +++ b/lib/Notifier/AdminNotifications.php @@ -3,11 +3,11 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2017 Joas Schilling + * @copyright Copyright (c) 2017, Joas Schilling * * @author Joas Schilling * - * @license GNU AGPL version 3 or any later version + * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as diff --git a/lib/Push.php b/lib/Push.php index 0d377f8e8..e9df58fde 100644 --- a/lib/Push.php +++ b/lib/Push.php @@ -3,9 +3,11 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2017 Joas Schilling + * @copyright Copyright (c) 2017, Joas Schilling * - * @license GNU AGPL version 3 or any later version + * @author Joas Schilling + * + * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as diff --git a/lib/Service/ClientService.php b/lib/Service/ClientService.php index 0a9636918..a436cb7db 100644 --- a/lib/Service/ClientService.php +++ b/lib/Service/ClientService.php @@ -2,11 +2,11 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2023 Joas Schilling + * @copyright Copyright (c) 2023, Joas Schilling * * @author Joas Schilling * - * @license GNU AGPL version 3 or any later version + * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as diff --git a/lib/Settings/Admin.php b/lib/Settings/Admin.php index 749e0a81e..70ccbe6cc 100644 --- a/lib/Settings/Admin.php +++ b/lib/Settings/Admin.php @@ -3,11 +3,11 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2022 Nikita Toponen + * @copyright Copyright (c) 2022, Nikita Toponen * * @author Nikita Toponen * - * @license GNU AGPL version 3 or any later version + * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -40,7 +40,7 @@ class Admin implements ISettings { protected IConfig $config; protected IL10N $l10n; - private SettingsMapper$settingsMapper; + private SettingsMapper $settingsMapper; private IUserSession $session; private IInitialState $initialState; diff --git a/lib/Settings/AdminSection.php b/lib/Settings/AdminSection.php index a90132c0a..51f68ae72 100644 --- a/lib/Settings/AdminSection.php +++ b/lib/Settings/AdminSection.php @@ -3,11 +3,11 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2022 Nikita Toponen + * @copyright Copyright (c) 2022, Nikita Toponen * * @author Nikita Toponen * - * @license GNU AGPL version 3 or any later version + * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as diff --git a/lib/Settings/Personal.php b/lib/Settings/Personal.php index a63ee8b50..824061ac2 100644 --- a/lib/Settings/Personal.php +++ b/lib/Settings/Personal.php @@ -3,9 +3,11 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2021 Julien Barnoin + * @copyright Copyright (c) 2021, Julien Barnoin * - * @license GNU AGPL version 3 or any later version + * @author Julien Barnoin + * + * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as diff --git a/lib/Settings/PersonalSection.php b/lib/Settings/PersonalSection.php index 16b544a56..8e5770828 100644 --- a/lib/Settings/PersonalSection.php +++ b/lib/Settings/PersonalSection.php @@ -3,9 +3,11 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2021 Julien Barnoin + * @copyright Copyright (c) 2021, Julien Barnoin * - * @license GNU AGPL version 3 or any later version + * @author Julien Barnoin + * + * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as diff --git a/tests/Integration/base-query-count.txt b/tests/Integration/base-query-count.txt index 520a8359c..5caff40c4 100644 --- a/tests/Integration/base-query-count.txt +++ b/tests/Integration/base-query-count.txt @@ -1 +1 @@ -9500 +10000 diff --git a/tests/Integration/features/bootstrap/FeatureContext.php b/tests/Integration/features/bootstrap/FeatureContext.php index 83c7b2781..e07c83aa0 100644 --- a/tests/Integration/features/bootstrap/FeatureContext.php +++ b/tests/Integration/features/bootstrap/FeatureContext.php @@ -149,11 +149,34 @@ public function checkNumNotifications(int $numNotifications) { } /** - * Parses the xml answer to get the array of users returned. - * @param ResponseInterface $response - * @return array + * @Then /^confirms previously fetched notification ids exist on (v\d+)$/ */ + public function checkNotificationsExists(string $api) { + $notificationIds = end($this->notificationIds); + + $sendingWithGarbage = $notificationIds; + // An array instead of int + $sendingWithGarbage[] = $notificationIds; + // A string instead of int + $sendingWithGarbage[] = '$notificationIds'; + // A duplicate + $sendingWithGarbage[] = reset($notificationIds); + + $this->sendingToWith('POST', '/apps/notifications/api/' . $api . '/notifications/exists?format=json', [ + 'ids' => $sendingWithGarbage, + ]); + + $this->assertStatusCode($this->response, 200); + $actualIds = $this->getDataFromOCSResponse($this->response); + + Assert::assertSame($notificationIds, $actualIds); + } + protected function getArrayOfNotificationsResponded(ResponseInterface $response): array { + return $this->getDataFromOCSResponse($response); + } + + protected function getDataFromOCSResponse(ResponseInterface $response): array { $jsonBody = json_decode($response->getBody()->getContents(), true); return $jsonBody['ocs']['data']; } diff --git a/tests/Integration/features/exists-notifications-v2.feature b/tests/Integration/features/exists-notifications-v2.feature new file mode 100644 index 000000000..2a821526c --- /dev/null +++ b/tests/Integration/features/exists-notifications-v2.feature @@ -0,0 +1,9 @@ +Feature: exists-notifications-v2 + Background: + Given user "test1" exists + Given as user "test1" + + Scenario: Check the notification ID is returned on exists-check + Given user "test1" has notifications + And user "test1" has 1 notifications on v2 + Then confirms previously fetched notification ids exist on v2 diff --git a/tests/Unit/AppInfo/RoutesTest.php b/tests/Unit/AppInfo/RoutesTest.php index 418694388..494df8b80 100644 --- a/tests/Unit/AppInfo/RoutesTest.php +++ b/tests/Unit/AppInfo/RoutesTest.php @@ -37,6 +37,6 @@ public function testRoutes() { $this->assertCount(1, $routes); $this->assertArrayHasKey('ocs', $routes); $this->assertIsArray($routes['ocs']); - $this->assertCount(9, $routes['ocs']); + $this->assertCount(10, $routes['ocs']); } } diff --git a/tests/Unit/CapabilitiesTest.php b/tests/Unit/CapabilitiesTest.php index 9dbed1a51..c90d4886a 100644 --- a/tests/Unit/CapabilitiesTest.php +++ b/tests/Unit/CapabilitiesTest.php @@ -39,6 +39,7 @@ public function testGetCapabilities() { 'rich-strings', 'action-web', 'user-status', + 'exists', ], 'push' => [ 'devices',