Skip to content

Commit

Permalink
Show warning on admin settings page
Browse files Browse the repository at this point in the history
Signed-off-by: Vitor Mattos <vitor@php.rio>
  • Loading branch information
vitormattos authored and nickvergessen committed Oct 22, 2021
1 parent b6d1ca8 commit cb3f3ac
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
16 changes: 15 additions & 1 deletion apps/settings/lib/Controller/CheckSetupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
use OCP\ITempManager;
use OCP\IURLGenerator;
use OCP\Lock\ILockingProvider;
use OCP\Notification\IManager;
use OCP\Security\ISecureRandom;
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
Expand Down Expand Up @@ -114,6 +115,8 @@ class CheckSetupController extends Controller {
private $connection;
/** @var ITempManager */
private $tempManager;
/** @var IManager */
private $manager;

public function __construct($AppName,
IRequest $request,
Expand All @@ -131,7 +134,8 @@ public function __construct($AppName,
ISecureRandom $secureRandom,
IniGetWrapper $iniGetWrapper,
IDBConnection $connection,
ITempManager $tempManager) {
ITempManager $tempManager,
IManager $manager) {
parent::__construct($AppName, $request);
$this->config = $config;
$this->clientService = $clientService;
Expand All @@ -148,6 +152,15 @@ public function __construct($AppName,
$this->iniGetWrapper = $iniGetWrapper;
$this->connection = $connection;
$this->tempManager = $tempManager;
$this->manager = $manager;
}

/**
* Check if is fair use of free push service
* @return bool
*/
private function isFairUseOfFreePushService(): bool {
return $this->manager->isFairUseOfFreePushService();
}

/**
Expand Down Expand Up @@ -761,6 +774,7 @@ public function check() {
'suggestedOverwriteCliURL' => $this->getSuggestedOverwriteCliURL(),
'cronInfo' => $this->getLastCronInfo(),
'cronErrors' => $this->getCronErrors(),
'isFairUseOfFreePushService' => $this->isFairUseOfFreePushService(),
'serverHasInternetConnectionProblems' => $this->hasInternetConnectivityProblems(),
'isMemcacheConfigured' => $this->isMemcacheConfigured(),
'memcacheDocs' => $this->urlGenerator->linkToDocs('admin-performance'),
Expand Down
6 changes: 6 additions & 0 deletions core/js/setupchecks.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,12 @@
type: OC.SetupChecks.MESSAGE_TYPE_ERROR
});
}
if (!data.isFairUseOfFreePushService) {
messages.push({
msg: t('core', 'This is the unsupported community build of Nextcloud, not designed to for performance, reliability and scalability at the size of this instance. Push notifications have been disabled to not overload our free service. Learn more on nextcloud.com/enterprise about the benefits of Nextcloud Enterprise.'),
type: OC.SetupChecks.MESSAGE_TYPE_ERROR
});
}
if (data.serverHasInternetConnectionProblems) {
messages.push({
msg: t('core', 'This server has no working internet connection: Multiple endpoints could not be reached. This means that some of the features like mounting external storage, notifications about updates or installation of third-party apps will not work. Accessing files remotely and sending of notification emails might not work, either. Establish a connection from this server to the internet to enjoy all features.'),
Expand Down
19 changes: 19 additions & 0 deletions core/js/tests/specs/setupchecksSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ describe('OC.SetupChecks tests', function() {
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
isRandomnessSecure: true,
isFairUseOfFreePushService: true,
serverHasInternetConnectionProblems: true,
memcacheDocs: 'https://docs.nextcloud.com/server/go.php?to=admin-performance',
forwardedForHeadersWorking: true,
Expand Down Expand Up @@ -287,6 +288,7 @@ describe('OC.SetupChecks tests', function() {
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
isRandomnessSecure: true,
isFairUseOfFreePushService: true,
serverHasInternetConnectionProblems: true,
memcacheDocs: 'https://docs.nextcloud.com/server/go.php?to=admin-performance',
forwardedForHeadersWorking: true,
Expand Down Expand Up @@ -345,6 +347,7 @@ describe('OC.SetupChecks tests', function() {
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
isRandomnessSecure: true,
isFairUseOfFreePushService: true,
serverHasInternetConnectionProblems: true,
isMemcacheConfigured: true,
forwardedForHeadersWorking: true,
Expand Down Expand Up @@ -401,6 +404,7 @@ describe('OC.SetupChecks tests', function() {
suggestedOverwriteCliURL: '',
isRandomnessSecure: false,
securityDocs: 'https://docs.nextcloud.com/myDocs.html',
isFairUseOfFreePushService: true,
serverHasInternetConnectionProblems: false,
isMemcacheConfigured: true,
forwardedForHeadersWorking: true,
Expand Down Expand Up @@ -455,6 +459,7 @@ describe('OC.SetupChecks tests', function() {
suggestedOverwriteCliURL: '',
isRandomnessSecure: true,
securityDocs: 'https://docs.nextcloud.com/myDocs.html',
isFairUseOfFreePushService: true,
serverHasInternetConnectionProblems: false,
isMemcacheConfigured: true,
forwardedForHeadersWorking: true,
Expand Down Expand Up @@ -509,6 +514,7 @@ describe('OC.SetupChecks tests', function() {
suggestedOverwriteCliURL: '',
isRandomnessSecure: true,
securityDocs: 'https://docs.nextcloud.com/myDocs.html',
isFairUseOfFreePushService: true,
serverHasInternetConnectionProblems: false,
isMemcacheConfigured: true,
forwardedForHeadersWorking: true,
Expand Down Expand Up @@ -564,6 +570,7 @@ describe('OC.SetupChecks tests', function() {
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
isRandomnessSecure: true,
isFairUseOfFreePushService: true,
serverHasInternetConnectionProblems: false,
isMemcacheConfigured: true,
forwardedForHeadersWorking: false,
Expand Down Expand Up @@ -618,6 +625,7 @@ describe('OC.SetupChecks tests', function() {
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
isRandomnessSecure: true,
isFairUseOfFreePushService: true,
serverHasInternetConnectionProblems: false,
isMemcacheConfigured: true,
forwardedForHeadersWorking: true,
Expand Down Expand Up @@ -672,6 +680,7 @@ describe('OC.SetupChecks tests', function() {
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
isRandomnessSecure: true,
isFairUseOfFreePushService: true,
serverHasInternetConnectionProblems: false,
isMemcacheConfigured: true,
forwardedForHeadersWorking: true,
Expand Down Expand Up @@ -747,6 +756,7 @@ describe('OC.SetupChecks tests', function() {
suggestedOverwriteCliURL: '',
isRandomnessSecure: true,
securityDocs: 'https://docs.nextcloud.com/myDocs.html',
isFairUseOfFreePushService: true,
serverHasInternetConnectionProblems: false,
isMemcacheConfigured: true,
forwardedForHeadersWorking: true,
Expand Down Expand Up @@ -802,6 +812,7 @@ describe('OC.SetupChecks tests', function() {
suggestedOverwriteCliURL: '',
isRandomnessSecure: true,
securityDocs: 'https://docs.nextcloud.com/myDocs.html',
isFairUseOfFreePushService: true,
serverHasInternetConnectionProblems: false,
isMemcacheConfigured: true,
forwardedForHeadersWorking: true,
Expand Down Expand Up @@ -857,6 +868,7 @@ describe('OC.SetupChecks tests', function() {
suggestedOverwriteCliURL: '',
isRandomnessSecure: true,
securityDocs: 'https://docs.nextcloud.com/myDocs.html',
isFairUseOfFreePushService: true,
serverHasInternetConnectionProblems: false,
isMemcacheConfigured: true,
forwardedForHeadersWorking: true,
Expand Down Expand Up @@ -912,6 +924,7 @@ describe('OC.SetupChecks tests', function() {
suggestedOverwriteCliURL: '',
isRandomnessSecure: true,
securityDocs: 'https://docs.nextcloud.com/myDocs.html',
isFairUseOfFreePushService: true,
serverHasInternetConnectionProblems: false,
isMemcacheConfigured: true,
forwardedForHeadersWorking: true,
Expand Down Expand Up @@ -967,6 +980,7 @@ describe('OC.SetupChecks tests', function() {
suggestedOverwriteCliURL: '',
isRandomnessSecure: true,
securityDocs: 'https://docs.nextcloud.com/myDocs.html',
isFairUseOfFreePushService: true,
serverHasInternetConnectionProblems: false,
isMemcacheConfigured: true,
forwardedForHeadersWorking: true,
Expand Down Expand Up @@ -1025,6 +1039,7 @@ describe('OC.SetupChecks tests', function() {
suggestedOverwriteCliURL: '',
isRandomnessSecure: true,
securityDocs: 'https://docs.nextcloud.com/myDocs.html',
isFairUseOfFreePushService: true,
serverHasInternetConnectionProblems: false,
isMemcacheConfigured: true,
forwardedForHeadersWorking: true,
Expand Down Expand Up @@ -1080,6 +1095,7 @@ describe('OC.SetupChecks tests', function() {
suggestedOverwriteCliURL: '',
isRandomnessSecure: true,
securityDocs: 'https://docs.nextcloud.com/myDocs.html',
isFairUseOfFreePushService: true,
serverHasInternetConnectionProblems: false,
isMemcacheConfigured: true,
forwardedForHeadersWorking: true,
Expand Down Expand Up @@ -1132,6 +1148,7 @@ describe('OC.SetupChecks tests', function() {
suggestedOverwriteCliURL: '',
isRandomnessSecure: true,
securityDocs: 'https://docs.nextcloud.com/myDocs.html',
isFairUseOfFreePushService: true,
serverHasInternetConnectionProblems: false,
isMemcacheConfigured: true,
forwardedForHeadersWorking: true,
Expand Down Expand Up @@ -1186,6 +1203,7 @@ describe('OC.SetupChecks tests', function() {
suggestedOverwriteCliURL: '',
isRandomnessSecure: true,
securityDocs: 'https://docs.nextcloud.com/myDocs.html',
isFairUseOfFreePushService: true,
serverHasInternetConnectionProblems: false,
isMemcacheConfigured: true,
forwardedForHeadersWorking: true,
Expand Down Expand Up @@ -1240,6 +1258,7 @@ describe('OC.SetupChecks tests', function() {
suggestedOverwriteCliURL: '',
isRandomnessSecure: true,
securityDocs: 'https://docs.nextcloud.com/myDocs.html',
isFairUseOfFreePushService: true,
serverHasInternetConnectionProblems: false,
isMemcacheConfigured: true,
forwardedForHeadersWorking: true,
Expand Down

0 comments on commit cb3f3ac

Please sign in to comment.