Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/notifications.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2021-09-29 17:35:48 +0300
committerJoas Schilling <coding@schilljs.com>2021-10-11 17:03:32 +0300
commit22debdf70b7917a65625c73a6f8464f62f3ecb38 (patch)
tree6522764deef98dff51ed36e9fb6937013683247a /lib
parent06cf1ee5f24a783ba7fe6d658fd403a5220c0ab3 (diff)
Move constants and don't use deprecated class
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Controller/SettingsController.php10
-rw-r--r--lib/MailNotifications.php4
-rw-r--r--lib/Settings/Personal.php30
3 files changed, 22 insertions, 22 deletions
diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php
index 9e5bf08..4c19373 100644
--- a/lib/Controller/SettingsController.php
+++ b/lib/Controller/SettingsController.php
@@ -24,7 +24,7 @@ declare(strict_types=1);
namespace OCA\Notifications\Controller;
-use OCA\Notifications\Settings\Personal;
+use OCA\Notifications\MailNotifications;
use OCP\AppFramework\OCSController;
use OCP\AppFramework\Http\DataResponse;
use OCP\IConfig;
@@ -54,15 +54,15 @@ class SettingsController extends OCSController {
* @return DataResponse
*/
public function personal(
- int $notify_setting_batchtime = Personal::EMAIL_SEND_HOURLY,
+ int $notify_setting_batchtime = MailNotifications::EMAIL_SEND_HOURLY,
bool $notifications_email_enabled = false
): DataResponse {
$email_batch_time = 3600;
- if ($notify_setting_batchtime === Personal::EMAIL_SEND_DAILY) {
+ if ($notify_setting_batchtime === MailNotifications::EMAIL_SEND_DAILY) {
$email_batch_time = 3600 * 24;
- } elseif ($notify_setting_batchtime === Personal::EMAIL_SEND_WEEKLY) {
+ } elseif ($notify_setting_batchtime === MailNotifications::EMAIL_SEND_WEEKLY) {
$email_batch_time = 3600 * 24 * 7;
- } elseif ($notify_setting_batchtime === Personal::EMAIL_SEND_ASAP) {
+ } elseif ($notify_setting_batchtime === MailNotifications::EMAIL_SEND_ASAP) {
$email_batch_time = 0;
}
diff --git a/lib/MailNotifications.php b/lib/MailNotifications.php
index a5960f1..f3bf2ce 100644
--- a/lib/MailNotifications.php
+++ b/lib/MailNotifications.php
@@ -41,6 +41,10 @@ use OCP\Util;
use Psr\Log\LoggerInterface;
class MailNotifications {
+ public const EMAIL_SEND_ASAP = 3;
+ public const EMAIL_SEND_DAILY = 1;
+ public const EMAIL_SEND_WEEKLY = 2;
+ public const EMAIL_SEND_HOURLY = 0;
/** @var IConfig */
private $config;
diff --git a/lib/Settings/Personal.php b/lib/Settings/Personal.php
index 5e7aaa6..4233dee 100644
--- a/lib/Settings/Personal.php
+++ b/lib/Settings/Personal.php
@@ -24,12 +24,13 @@ declare(strict_types=1);
namespace OCA\Notifications\Settings;
+use OCA\Notifications\MailNotifications;
use OCP\AppFramework\Http\TemplateResponse;
+use OCP\AppFramework\Services\IInitialState;
use OCP\IConfig;
use OCP\IL10N;
use OCP\Settings\ISettings;
use OCP\IUserSession;
-use OCP\IInitialStateService;
use OCP\Util;
class Personal implements ISettings {
@@ -42,23 +43,18 @@ class Personal implements ISettings {
/** @var IUserSession */
private $session;
- /** @var IInitialStateService */
- private $initialStateService;
-
- public const EMAIL_SEND_HOURLY = 0;
- public const EMAIL_SEND_DAILY = 1;
- public const EMAIL_SEND_WEEKLY = 2;
- public const EMAIL_SEND_ASAP = 3;
+ /** @var IInitialState */
+ private $initialState;
public function __construct(IConfig $config,
IL10N $l10n,
IUserSession $session,
- IInitialStateService $initialStateService) {
+ IInitialState $initialState) {
$this->config = $config;
$this->l10n = $l10n;
$this->session = $session;
- $this->initialStateService = $initialStateService;
+ $this->initialState = $initialState;
}
/**
@@ -66,22 +62,22 @@ class Personal implements ISettings {
*/
public function getForm(): TemplateResponse {
Util::addScript('notifications', 'notifications-userSettings');
-
- $settingBatchTime = Personal::EMAIL_SEND_HOURLY;
+
+ $settingBatchTime = MailNotifications::EMAIL_SEND_HOURLY;
$user = $this->session->getUser()->getUID();
$currentSetting = (int) $this->config->getUserValue($user, 'notifications', 'notify_setting_batchtime', 3600 * 24);
if ($currentSetting === 3600 * 24 * 7) {
- $settingBatchTime = Personal::EMAIL_SEND_WEEKLY;
+ $settingBatchTime = MailNotifications::EMAIL_SEND_WEEKLY;
} elseif ($currentSetting === 3600 * 24) {
- $settingBatchTime = Personal::EMAIL_SEND_DAILY;
+ $settingBatchTime = MailNotifications::EMAIL_SEND_DAILY;
} elseif ($currentSetting === 0) {
- $settingBatchTime = Personal::EMAIL_SEND_ASAP;
+ $settingBatchTime = MailNotifications::EMAIL_SEND_ASAP;
}
$emailEnabled = true;
-
- $this->initialStateService->provideInitialState('notifications', 'config', [
+
+ $this->initialState->provideInitialState('config', [
'setting' => 'personal',
'is_email_set' => !empty($this->config->getUserValue($user, 'settings', 'email', '')),
'email_enabled' => $emailEnabled,