Skip to content

Commit

Permalink
add an admin check for the preview max setting
Browse files Browse the repository at this point in the history
Signed-off-by: szaimen <[email protected]>
  • Loading branch information
szaimen authored and skjnldsv committed Jan 26, 2023
1 parent 4caa90d commit 2bf389e
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 0 deletions.
13 changes: 13 additions & 0 deletions apps/settings/lib/Controller/CheckSetupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,18 @@ protected function wasEmailTestSuccessful(): bool {
return true;
}

protected function isPreviewMaxSetCorrectly(): bool {
if ($this->config->getSystemValueInt('preview_max_x', 4096) < 4096) {
return false;
}

if ($this->config->getSystemValueInt('preview_max_y', 4096) < 4096) {
return false;
}

return true;
}

protected function hasValidTransactionIsolationLevel(): bool {
try {
if ($this->db->getDatabasePlatform() instanceof SqlitePlatform) {
Expand Down Expand Up @@ -865,6 +877,7 @@ public function check() {
'isReadOnlyConfig' => $this->isReadOnlyConfig(),
'hasValidTransactionIsolationLevel' => $this->hasValidTransactionIsolationLevel(),
'wasEmailTestSuccessful' => $this->wasEmailTestSuccessful(),
'isPreviewMaxSetCorrectly' => $this->isPreviewMaxSetCorrectly(),
'hasFileinfoInstalled' => $this->hasFileinfoInstalled(),
'hasWorkingFileLocking' => $this->hasWorkingFileLocking(),
'suggestedOverwriteCliURL' => $this->getSuggestedOverwriteCliURL(),
Expand Down
6 changes: 6 additions & 0 deletions apps/settings/tests/Controller/CheckSetupControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ protected function setUp(): void {
->setMethods([
'isReadOnlyConfig',
'wasEmailTestSuccessful',
'isPreviewMaxSetCorrectly',
'hasValidTransactionIsolationLevel',
'hasFileinfoInstalled',
'hasWorkingFileLocking',
Expand Down Expand Up @@ -490,6 +491,10 @@ public function testCheck() {
->expects($this->once())
->method('wasEmailTestSuccessful')
->willReturn(false);
$this->checkSetupController
->expects($this->once())
->method('isPreviewMaxSetCorrectly')
->willReturn(true);
$this->checkSetupController
->expects($this->once())
->method('hasValidTransactionIsolationLevel')
Expand Down Expand Up @@ -601,6 +606,7 @@ public function testCheck() {
'isGetenvServerWorking' => true,
'isReadOnlyConfig' => false,
'wasEmailTestSuccessful' => false,
'isPreviewMaxSetCorrectly' => true,
'hasValidTransactionIsolationLevel' => true,
'hasFileinfoInstalled' => true,
'hasWorkingFileLocking' => true,
Expand Down
6 changes: 6 additions & 0 deletions core/js/setupchecks.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@
type: OC.SetupChecks.MESSAGE_TYPE_INFO
});
}
if (!data.isPreviewMaxSetCorrectly) {
messages.push({
msg: t('core', 'Your max preview size settings are lower than 4K. Image previews may appear blurry to people using 4K screens.'),
type: OC.SetupChecks.MESSAGE_TYPE_INFO
});
}
if (!data.hasValidTransactionIsolationLevel) {
messages.push({
msg: t('core', 'Your database does not run with "READ COMMITTED" transaction isolation level. This can cause problems when multiple actions are executed in parallel.'),
Expand Down
81 changes: 81 additions & 0 deletions core/js/tests/specs/setupchecksSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -288,6 +289,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -350,6 +352,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -409,6 +412,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -467,6 +471,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -525,6 +530,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: false,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -570,6 +576,65 @@ describe('OC.SetupChecks tests', function() {
});
});

it('should return an info when preview max is not configured correctly', function(done) {
var async = OC.SetupChecks.checkSetup();

suite.server.requests[0].respond(
200,
{
'Content-Type': 'application/json'
},
JSON.stringify({
hasFileinfoInstalled: true,
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: false,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
isRandomnessSecure: true,
securityDocs: 'https://docs.nextcloud.com/myDocs.html',
isFairUseOfFreePushService: true,
serverHasInternetConnectionProblems: false,
isMemcacheConfigured: true,
forwardedForHeadersWorking: true,
isCorrectMemcachedPHPModuleInstalled: true,
hasPassedCodeIntegrityCheck: true,
OpcacheSetupRecommendations: [],
isSettimelimitAvailable: true,
hasFreeTypeSupport: true,
missingIndexes: [],
missingPrimaryKeys: [],
missingColumns: [],
cronErrors: [],
cronInfo: {
diffInSeconds: 0
},
isMemoryLimitSufficient: true,
appDirsWithDifferentOwner: [],
isImagickEnabled: true,
areWebauthnExtensionsEnabled: true,
is64bit: true,
recommendedPHPModules: [],
pendingBigIntConversionColumns: [],
isMysqlUsedWithoutUTF8MB4: false,
isDefaultPhoneRegionSet: true,
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
reverseProxyGeneratedURL: 'https://server',
temporaryDirectoryWritable: true,
})
);

async.done(function( data, s, x ){
expect(data).toEqual([{
msg: 'Your max preview size settings are lower than 4K. Image previews may appear blurry to people using 4K screens.',
type: OC.SetupChecks.MESSAGE_TYPE_INFO
}]);
done();
});
});

it('should return a warning if there are app directories with wrong permissions', function(done) {
var async = OC.SetupChecks.checkSetup();

Expand All @@ -583,6 +648,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -643,6 +709,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -701,6 +768,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -759,6 +827,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -837,6 +906,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -896,6 +966,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -954,6 +1025,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -1012,6 +1084,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -1074,6 +1147,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -1133,6 +1207,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -1189,6 +1264,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -1248,6 +1324,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -1307,6 +1384,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -1365,6 +1443,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -1423,6 +1502,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -1481,6 +1561,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down

0 comments on commit 2bf389e

Please sign in to comment.