2021-01-24 06:10:44 +00:00
|
|
|
<?php
|
|
|
|
namespace OCA\CTAutoMailHooks;
|
|
|
|
use OCP\ILogger;
|
|
|
|
use \OCP\IConfig;
|
|
|
|
class Config {
|
|
|
|
const CONFIG_KEY = 'ct_auto_mail_hooks';
|
|
|
|
const CONFIG_KEY_GLESYS_KEYS="glesys_keys";
|
|
|
|
const CONFIG_KEY_EMAIL_ADDR_SUFFIX="email_suffix";
|
2021-01-24 07:40:17 +00:00
|
|
|
const CONFIG_KEY_EMAIL_ADDR_QUOTA_MB="quota";
|
|
|
|
const DEFAULT_EMAIL_ADDR_QUOTA_MB="200";
|
2021-01-24 06:10:44 +00:00
|
|
|
private $logger;
|
|
|
|
private $appConfiguration;
|
|
|
|
private $logContext = ['app' => 'ct_auto_mail_hooks'];
|
2021-02-22 03:06:57 +00:00
|
|
|
public function __construct(
|
|
|
|
ILogger $logger, IConfig $nextCloudConfiguration) {
|
2021-01-24 06:10:44 +00:00
|
|
|
$this->logger = $logger;
|
2021-02-22 03:06:57 +00:00
|
|
|
$this->appConfiguration =
|
|
|
|
$nextCloudConfiguration->getSystemValue(self::CONFIG_KEY);
|
2021-01-24 06:10:44 +00:00
|
|
|
}
|
|
|
|
public function getGlesysKeys() {
|
|
|
|
return $this->getConfValue(self::CONFIG_KEY_GLESYS_KEYS);
|
|
|
|
}
|
|
|
|
public function getEmailAddressSuffix() {
|
|
|
|
return $this->getConfValue(self::CONFIG_KEY_EMAIL_ADDR_SUFFIX);
|
|
|
|
}
|
2021-01-24 07:40:17 +00:00
|
|
|
public function getEmailQuotaMB() {
|
|
|
|
$quota = $this->getConfValue(self::CONFIG_KEY_EMAIL_ADDR_QUOTA_MB);
|
|
|
|
return is_null($quota) ? self::DEFAULT_EMAIL_ADDR_QUOTA_MB : $quota;
|
|
|
|
}
|
2021-01-24 06:10:44 +00:00
|
|
|
private function getConfValue($configKey) {
|
2021-01-24 07:40:17 +00:00
|
|
|
if(array_key_exists($configKey, $this->appConfiguration)){
|
|
|
|
return $this->appConfiguration[$configKey];
|
|
|
|
}
|
|
|
|
return NULL;
|
2021-01-24 06:10:44 +00:00
|
|
|
}
|
|
|
|
}
|