From 01aca58c26fad60922d47afcb3cdf8d9a6309cb1 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 21 Dec 2023 16:06:48 -0800 Subject: [PATCH 1/3] Weekly reminder --- lib/Listeners/UserConfigChangedListener.php | 1 + lib/Service/RecoveryEmailService.php | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/Listeners/UserConfigChangedListener.php b/lib/Listeners/UserConfigChangedListener.php index bfce357..02b8207 100644 --- a/lib/Listeners/UserConfigChangedListener.php +++ b/lib/Listeners/UserConfigChangedListener.php @@ -29,6 +29,7 @@ class UserConfigChangedListener implements IEventListener { if ($newRecoveryEmail !== '') { $this->recoveryEmailService->setRecoveryEmail($user, ''); $this->recoveryEmailService->sendVerificationEmail($user, $newRecoveryEmail); + $this->recoveryEmailService->addToJobList($user); } } } diff --git a/lib/Service/RecoveryEmailService.php b/lib/Service/RecoveryEmailService.php index 31f3156..aa61b35 100644 --- a/lib/Service/RecoveryEmailService.php +++ b/lib/Service/RecoveryEmailService.php @@ -20,6 +20,8 @@ use OCP\L10N\IFactory; use OCP\IURLGenerator; use OCP\Defaults; use OCP\Security\VerificationToken\IVerificationToken; +use OCA\MurenaNotifications\BackgroundJob\EmailNotificationJob; +use OCP\BackgroundJob\IJobList; class RecoveryEmailService { private ILogger $logger; @@ -33,8 +35,9 @@ class RecoveryEmailService { private Defaults $themingDefaults; private IVerificationToken $verificationToken; protected const TOKEN_LIFETIME = 60 * 30; // 30 minutes + private IJobList $jobList; - public function __construct(string $appName, ILogger $logger, IConfig $config, LDAPConnectionService $LDAPConnectionService, IUserManager $userManager, IMailer $mailer, IFactory $l10nFactory, IURLGenerator $urlGenerator, Defaults $themingDefaults, IVerificationToken $verificationToken) { + public function __construct(string $appName, ILogger $logger, IConfig $config, LDAPConnectionService $LDAPConnectionService, IUserManager $userManager, IMailer $mailer, IFactory $l10nFactory, IURLGenerator $urlGenerator, Defaults $themingDefaults, IVerificationToken $verificationToken,IJobList $jobList) { $this->logger = $logger; $this->config = $config; $this->appName = $appName; @@ -45,6 +48,7 @@ class RecoveryEmailService { $this->urlGenerator = $urlGenerator; $this->themingDefaults = $themingDefaults; $this->verificationToken = $verificationToken; + $this->jobList = $jobList; } public function setRecoveryEmail(string $username, string $value = '') : void { $this->config->setUserValue($username, $this->appName, 'recovery-email', $value); @@ -196,4 +200,14 @@ class RecoveryEmailService { $this->deleteUnverifiedRecoveryEmail($userId); } } + public function addToJobList(string $users): void { + // Add user to job list if not already there + // email job + $messageId = '20240101_weekly_reminder'; + $this->jobList->add(EmailNotificationJob::class, [ + 'users' => $users, + 'groups' => '', + 'messageId' => $messageId + ]); + } } -- GitLab From 0e45fcd35d004dd7082c1a64dd4d27f6d359c5a1 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 21 Dec 2023 16:09:41 -0800 Subject: [PATCH 2/3] temp change --- lib/Service/RecoveryEmailService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Service/RecoveryEmailService.php b/lib/Service/RecoveryEmailService.php index aa61b35..31231ee 100644 --- a/lib/Service/RecoveryEmailService.php +++ b/lib/Service/RecoveryEmailService.php @@ -37,7 +37,7 @@ class RecoveryEmailService { protected const TOKEN_LIFETIME = 60 * 30; // 30 minutes private IJobList $jobList; - public function __construct(string $appName, ILogger $logger, IConfig $config, LDAPConnectionService $LDAPConnectionService, IUserManager $userManager, IMailer $mailer, IFactory $l10nFactory, IURLGenerator $urlGenerator, Defaults $themingDefaults, IVerificationToken $verificationToken,IJobList $jobList) { + public function __construct(string $appName, ILogger $logger, IConfig $config, LDAPConnectionService $LDAPConnectionService, IUserManager $userManager, IMailer $mailer, IFactory $l10nFactory, IURLGenerator $urlGenerator, Defaults $themingDefaults, IVerificationToken $verificationToken, IJobList $jobList) { $this->logger = $logger; $this->config = $config; $this->appName = $appName; -- GitLab From 65012506117486fc412f8d3e893adf996c22cad2 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 21 Dec 2023 16:20:04 -0800 Subject: [PATCH 3/3] recovery email change --- lib/Service/RecoveryEmailService.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/Service/RecoveryEmailService.php b/lib/Service/RecoveryEmailService.php index 31231ee..51439d9 100644 --- a/lib/Service/RecoveryEmailService.php +++ b/lib/Service/RecoveryEmailService.php @@ -20,7 +20,7 @@ use OCP\L10N\IFactory; use OCP\IURLGenerator; use OCP\Defaults; use OCP\Security\VerificationToken\IVerificationToken; -use OCA\MurenaNotifications\BackgroundJob\EmailNotificationJob; +use OCA\MurenaNotifications\BackgroundJob\WeeklyRecoveryNotificationJob; use OCP\BackgroundJob\IJobList; class RecoveryEmailService { @@ -204,9 +204,8 @@ class RecoveryEmailService { // Add user to job list if not already there // email job $messageId = '20240101_weekly_reminder'; - $this->jobList->add(EmailNotificationJob::class, [ + $this->jobList->add(WeeklyRecoveryNotificationJob::class, [ 'users' => $users, - 'groups' => '', 'messageId' => $messageId ]); } -- GitLab