]> source.dussan.org Git - nextcloud-server.git/commitdiff
Rename to "Push service" and enable on all instances to avoid trouble 42939/head
authorCôme Chilliet <come.chilliet@nextcloud.com>
Thu, 25 Jan 2024 14:23:54 +0000 (15:23 +0100)
committerCôme Chilliet <come.chilliet@nextcloud.com>
Thu, 25 Jan 2024 14:23:54 +0000 (15:23 +0100)
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
apps/settings/composer/composer/autoload_classmap.php
apps/settings/composer/composer/autoload_static.php
apps/settings/lib/AppInfo/Application.php
apps/settings/lib/SetupChecks/FairUseOfFreePushService.php [deleted file]
apps/settings/lib/SetupChecks/PushService.php [new file with mode: 0644]

index 866c27f0f25a84c240843b1163c463a341e03283..0d8e177c1fde25416da4b352e796e734c197854b 100644 (file)
@@ -88,7 +88,6 @@ return array(
     'OCA\\Settings\\SetupChecks\\DatabasePendingBigIntConversions' => $baseDir . '/../lib/SetupChecks/DatabasePendingBigIntConversions.php',
     'OCA\\Settings\\SetupChecks\\DefaultPhoneRegionSet' => $baseDir . '/../lib/SetupChecks/DefaultPhoneRegionSet.php',
     'OCA\\Settings\\SetupChecks\\EmailTestSuccessful' => $baseDir . '/../lib/SetupChecks/EmailTestSuccessful.php',
-    'OCA\\Settings\\SetupChecks\\FairUseOfFreePushService' => $baseDir . '/../lib/SetupChecks/FairUseOfFreePushService.php',
     'OCA\\Settings\\SetupChecks\\FileLocking' => $baseDir . '/../lib/SetupChecks/FileLocking.php',
     'OCA\\Settings\\SetupChecks\\ForwardedForHeaders' => $baseDir . '/../lib/SetupChecks/ForwardedForHeaders.php',
     'OCA\\Settings\\SetupChecks\\InternetConnectivity' => $baseDir . '/../lib/SetupChecks/InternetConnectivity.php',
@@ -107,6 +106,7 @@ return array(
     'OCA\\Settings\\SetupChecks\\PhpOpcacheSetup' => $baseDir . '/../lib/SetupChecks/PhpOpcacheSetup.php',
     'OCA\\Settings\\SetupChecks\\PhpOutdated' => $baseDir . '/../lib/SetupChecks/PhpOutdated.php',
     'OCA\\Settings\\SetupChecks\\PhpOutputBuffering' => $baseDir . '/../lib/SetupChecks/PhpOutputBuffering.php',
+    'OCA\\Settings\\SetupChecks\\PushService' => $baseDir . '/../lib/SetupChecks/PushService.php',
     'OCA\\Settings\\SetupChecks\\RandomnessSecure' => $baseDir . '/../lib/SetupChecks/RandomnessSecure.php',
     'OCA\\Settings\\SetupChecks\\ReadOnlyConfig' => $baseDir . '/../lib/SetupChecks/ReadOnlyConfig.php',
     'OCA\\Settings\\SetupChecks\\SupportedDatabase' => $baseDir . '/../lib/SetupChecks/SupportedDatabase.php',
index 99dd68250c126ee26509e8960f9e895955e64f23..1b95d35a9063fd563bf4661be8e3b871e5359b16 100644 (file)
@@ -103,7 +103,6 @@ class ComposerStaticInitSettings
         'OCA\\Settings\\SetupChecks\\DatabasePendingBigIntConversions' => __DIR__ . '/..' . '/../lib/SetupChecks/DatabasePendingBigIntConversions.php',
         'OCA\\Settings\\SetupChecks\\DefaultPhoneRegionSet' => __DIR__ . '/..' . '/../lib/SetupChecks/DefaultPhoneRegionSet.php',
         'OCA\\Settings\\SetupChecks\\EmailTestSuccessful' => __DIR__ . '/..' . '/../lib/SetupChecks/EmailTestSuccessful.php',
-        'OCA\\Settings\\SetupChecks\\FairUseOfFreePushService' => __DIR__ . '/..' . '/../lib/SetupChecks/FairUseOfFreePushService.php',
         'OCA\\Settings\\SetupChecks\\FileLocking' => __DIR__ . '/..' . '/../lib/SetupChecks/FileLocking.php',
         'OCA\\Settings\\SetupChecks\\ForwardedForHeaders' => __DIR__ . '/..' . '/../lib/SetupChecks/ForwardedForHeaders.php',
         'OCA\\Settings\\SetupChecks\\InternetConnectivity' => __DIR__ . '/..' . '/../lib/SetupChecks/InternetConnectivity.php',
@@ -122,6 +121,7 @@ class ComposerStaticInitSettings
         'OCA\\Settings\\SetupChecks\\PhpOpcacheSetup' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpOpcacheSetup.php',
         'OCA\\Settings\\SetupChecks\\PhpOutdated' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpOutdated.php',
         'OCA\\Settings\\SetupChecks\\PhpOutputBuffering' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpOutputBuffering.php',
+        'OCA\\Settings\\SetupChecks\\PushService' => __DIR__ . '/..' . '/../lib/SetupChecks/PushService.php',
         'OCA\\Settings\\SetupChecks\\RandomnessSecure' => __DIR__ . '/..' . '/../lib/SetupChecks/RandomnessSecure.php',
         'OCA\\Settings\\SetupChecks\\ReadOnlyConfig' => __DIR__ . '/..' . '/../lib/SetupChecks/ReadOnlyConfig.php',
         'OCA\\Settings\\SetupChecks\\SupportedDatabase' => __DIR__ . '/..' . '/../lib/SetupChecks/SupportedDatabase.php',
index 6c6b430fdb3cdce63270667e8c1a653ac053dca6..35e5009f1e8722f29ba2b6fc9c595cfe37482a34 100644 (file)
@@ -60,7 +60,6 @@ use OCA\Settings\SetupChecks\DatabaseHasMissingPrimaryKeys;
 use OCA\Settings\SetupChecks\DatabasePendingBigIntConversions;
 use OCA\Settings\SetupChecks\DefaultPhoneRegionSet;
 use OCA\Settings\SetupChecks\EmailTestSuccessful;
-use OCA\Settings\SetupChecks\FairUseOfFreePushService;
 use OCA\Settings\SetupChecks\FileLocking;
 use OCA\Settings\SetupChecks\ForwardedForHeaders;
 use OCA\Settings\SetupChecks\InternetConnectivity;
@@ -79,6 +78,7 @@ use OCA\Settings\SetupChecks\PhpModules;
 use OCA\Settings\SetupChecks\PhpOpcacheSetup;
 use OCA\Settings\SetupChecks\PhpOutdated;
 use OCA\Settings\SetupChecks\PhpOutputBuffering;
+use OCA\Settings\SetupChecks\PushService;
 use OCA\Settings\SetupChecks\RandomnessSecure;
 use OCA\Settings\SetupChecks\ReadOnlyConfig;
 use OCA\Settings\SetupChecks\SupportedDatabase;
@@ -210,9 +210,7 @@ class Application extends App implements IBootstrap {
                $context->registerSetupCheck(SystemIs64bit::class);
                $context->registerSetupCheck(TempSpaceAvailable::class);
                $context->registerSetupCheck(TransactionIsolation::class);
-               if (!\OCP\Server::get(\OCP\Support\Subscription\IRegistry::class)->delegateHasValidSubscription()) {
-                       $context->registerSetupCheck(FairUseOfFreePushService::class);
-               }
+               $context->registerSetupCheck(PushService::class);
 
                $context->registerUserMigrator(AccountMigrator::class);
        }
diff --git a/apps/settings/lib/SetupChecks/FairUseOfFreePushService.php b/apps/settings/lib/SetupChecks/FairUseOfFreePushService.php
deleted file mode 100644 (file)
index 431d1be..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-/**
- * @copyright Copyright (c) 2023 Côme Chilliet <come.chilliet@nextcloud.com>
- *
- * @author Côme Chilliet <come.chilliet@nextcloud.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-namespace OCA\Settings\SetupChecks;
-
-use OCP\IConfig;
-use OCP\IL10N;
-use OCP\Notification\IManager;
-use OCP\SetupCheck\ISetupCheck;
-use OCP\SetupCheck\SetupResult;
-
-class FairUseOfFreePushService implements ISetupCheck {
-       public function __construct(
-               private IL10N $l10n,
-               private IConfig $config,
-               private IManager $notificationsManager,
-       ) {
-       }
-
-       public function getName(): string {
-               return $this->l10n->t('Free push service');
-       }
-
-       public function getCategory(): string {
-               return 'system';
-       }
-
-       /**
-        * Check if is fair use of free push service
-        */
-       private function isFairUseOfFreePushService(): bool {
-               $rateLimitReached = (int) $this->config->getAppValue('notifications', 'rate_limit_reached', '0');
-               if ($rateLimitReached >= (time() - 7 * 24 * 3600)) {
-                       // Notifications app is showing a message already
-                       return true;
-               }
-               return $this->notificationsManager->isFairUseOfFreePushService();
-       }
-
-       public function run(): SetupResult {
-               if ($this->isFairUseOfFreePushService()) {
-                       return SetupResult::success();
-               }
-
-               return SetupResult::error(
-                       $this->l10n->t('This is the unsupported community build of Nextcloud. Given the size of this instance, performance, reliability and scalability cannot be guaranteed. Push notifications are limited to avoid overloading our free service. Learn more about the benefits of Nextcloud Enterprise at {link}.'),
-                       descriptionParameters:[
-                               'link' => [
-                                       'type' => 'highlight',
-                                       'id' => 'link',
-                                       'name' => 'https://nextcloud.com/enterprise',
-                                       'link' => 'https://nextcloud.com/enterprise',
-                               ],
-                       ],
-               );
-       }
-}
diff --git a/apps/settings/lib/SetupChecks/PushService.php b/apps/settings/lib/SetupChecks/PushService.php
new file mode 100644 (file)
index 0000000..3f9f993
--- /dev/null
@@ -0,0 +1,87 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2023 Côme Chilliet <come.chilliet@nextcloud.com>
+ *
+ * @author Côme Chilliet <come.chilliet@nextcloud.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+namespace OCA\Settings\SetupChecks;
+
+use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\IConfig;
+use OCP\IL10N;
+use OCP\Notification\IManager;
+use OCP\SetupCheck\ISetupCheck;
+use OCP\SetupCheck\SetupResult;
+use OCP\Support\Subscription\IRegistry;
+
+class PushService implements ISetupCheck {
+       public function __construct(
+               private IL10N $l10n,
+               private IConfig $config,
+               private IManager $notificationsManager,
+               private IRegistry $subscriptionRegistry,
+               private ITimeFactory $timeFactory,
+       ) {
+       }
+
+       public function getName(): string {
+               return $this->l10n->t('Push service');
+       }
+
+       public function getCategory(): string {
+               return 'system';
+       }
+
+       /**
+        * Check if is fair use of free push service
+        */
+       private function isFairUseOfFreePushService(): bool {
+               $rateLimitReached = (int) $this->config->getAppValue('notifications', 'rate_limit_reached', '0');
+               if ($rateLimitReached >= ($this->timeFactory->now()->getTimestamp() - 7 * 24 * 3600)) {
+                       // Notifications app is showing a message already
+                       return true;
+               }
+               return $this->notificationsManager->isFairUseOfFreePushService();
+       }
+
+       public function run(): SetupResult {
+               if ($this->subscriptionRegistry->delegateHasValidSubscription()) {
+                       return SetupResult::success($this->l10n->t('Valid enterprise license'));
+               }
+
+               if ($this->isFairUseOfFreePushService()) {
+                       return SetupResult::success($this->l10n->t('Free push service'));
+               }
+
+               return SetupResult::error(
+                       $this->l10n->t('This is the unsupported community build of Nextcloud. Given the size of this instance, performance, reliability and scalability cannot be guaranteed. Push notifications are limited to avoid overloading our free service. Learn more about the benefits of Nextcloud Enterprise at {link}.'),
+                       descriptionParameters:[
+                               'link' => [
+                                       'type' => 'highlight',
+                                       'id' => 'link',
+                                       'name' => 'https://nextcloud.com/enterprise',
+                                       'link' => 'https://nextcloud.com/enterprise',
+                               ],
+                       ],
+               );
+       }
+}