From a476328ddc4c5df95aa22d9ab4675201dfdb1a7c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 8 Oct 2024 10:07:26 +0200 Subject: [PATCH] feat(max-duration): Add setupcheck for misconfiguration Signed-off-by: Joas Schilling --- lib/AppInfo/Application.php | 2 ++ lib/SetupCheck/Configuration.php | 55 ++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 lib/SetupCheck/Configuration.php diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index eb0eb165f8b..42dc847d0e8 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -108,6 +108,7 @@ use OCA\Talk\Search\UnifiedSearchFilterPlugin; use OCA\Talk\Settings\Personal; use OCA\Talk\SetupCheck\BackgroundBlurLoading; +use OCA\Talk\SetupCheck\Configuration; use OCA\Talk\SetupCheck\FederationLockCache; use OCA\Talk\SetupCheck\HighPerformanceBackend; use OCA\Talk\SetupCheck\RecordingBackend; @@ -338,6 +339,7 @@ public function register(IRegistrationContext $context): void { $context->registerTeamResourceProvider(TalkTeamResourceProvider::class); + $context->registerSetupCheck(Configuration::class); $context->registerSetupCheck(HighPerformanceBackend::class); $context->registerSetupCheck(FederationLockCache::class); $context->registerSetupCheck(RecordingBackend::class); diff --git a/lib/SetupCheck/Configuration.php b/lib/SetupCheck/Configuration.php new file mode 100644 index 00000000000..d788da0a079 --- /dev/null +++ b/lib/SetupCheck/Configuration.php @@ -0,0 +1,55 @@ +l10n->t('Talk configuration'); + } + + public function run(): SetupResult { + $errors = $warnings = []; + $maxCallDuration = $this->appConfig->getAppValueInt('max_call_duration'); + if ($maxCallDuration > 0) { + if ($this->config->getAppValue('core', 'backgroundjobs_mode', 'ajax') !== 'cron') { + $errors[] = $this->l10n->t('Forcing a call duration is only supported with system cron. Please enable system cron or remove the `max_call_duration` configuration.'); + } elseif ($maxCallDuration < 3600) { + $warnings[] = $this->l10n->t('Small `max_call_duration` values (currently set to %d) are not enforceable due to technical limitations. The background job is only executed every 5 minutes, so use at own risk.', [$maxCallDuration]); + } + } + + if (!empty($errors)) { + return SetupResult::error(implode("\n", $errors)); + } + if (!empty($warnings)) { + return SetupResult::warning(implode("\n", $warnings)); + } + return SetupResult::success(); + } +}