dc299709f7
OCS endpoint for support.f7cloud.ru, notification notifier, and ?ticket= URL opening in the client UI.
43 lines
922 B
PHP
43 lines
922 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace OCA\F7Support\Service;
|
|
|
|
use OCP\IConfig;
|
|
|
|
class ConfigService {
|
|
public const APP_ID = 'f7support';
|
|
|
|
public function __construct(
|
|
private IConfig $config,
|
|
) {
|
|
}
|
|
|
|
public function isPushEnabled(): bool {
|
|
return $this->config->getAppValue(self::APP_ID, 'push_enabled', 'yes') === 'yes';
|
|
}
|
|
|
|
public function getPushWebhookSecret(): string {
|
|
return trim($this->config->getAppValue(self::APP_ID, 'push_webhook_secret', ''));
|
|
}
|
|
|
|
public function verifyPushWebhookSecret(?string $provided): bool {
|
|
if ($provided === null || $provided === '') {
|
|
return false;
|
|
}
|
|
|
|
$own = $this->getPushWebhookSecret();
|
|
if ($own !== '' && hash_equals($own, $provided)) {
|
|
return true;
|
|
}
|
|
|
|
$f7pushSecret = trim($this->config->getAppValue('f7push', 'api_secret', ''));
|
|
if ($f7pushSecret !== '' && hash_equals($f7pushSecret, $provided)) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|