From e025eb27343b989c72a9cc4ccb21cbdef6f34340 Mon Sep 17 00:00:00 2001 From: theronakpatel Date: Thu, 28 Aug 2025 19:29:24 +0530 Subject: [PATCH 1/5] removed unncessary loggers --- lib/Command/RecoveryWarningNotificationCommand.php | 9 +-------- lib/Notification/Notifier.php | 2 +- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/lib/Command/RecoveryWarningNotificationCommand.php b/lib/Command/RecoveryWarningNotificationCommand.php index 4f8e756..b897673 100644 --- a/lib/Command/RecoveryWarningNotificationCommand.php +++ b/lib/Command/RecoveryWarningNotificationCommand.php @@ -112,8 +112,6 @@ class RecoveryWarningNotificationCommand extends Command { return Command::FAILURE; } - $output->writeln('Starting user identification process...'); - // Initialize arrays $this->uids = []; $this->disableUids = []; @@ -124,12 +122,10 @@ class RecoveryWarningNotificationCommand extends Command { $this->sendNotificationsAndEmails($output); if ($disableAccounts) { - $output->writeln('Starting account disable process...'); $this->disableUnverifiedUsers($output); } if ($deleteAccounts) { - $output->writeln('Starting account deletion process...'); $this->deleteExpiredDisabledUsers($output); } @@ -155,8 +151,6 @@ class RecoveryWarningNotificationCommand extends Command { return; } - $output->writeln('Found ' . count($users) . ' users without recovery email'); - // Limit to user-limit for test mode if ($this->testMode && count($users) > $this->testModeUserLimit) { $users = array_slice($users, 0, $this->testModeUserLimit); @@ -316,7 +310,6 @@ class RecoveryWarningNotificationCommand extends Command { // Send email $this->sendEmailToUserIfValid($user, $emailAddress, $stats, $output); } catch (\Throwable $e) { - $output->writeln('Error processing user ' . $uid . ': ' . $e->getMessage() . ''); $stats['notificationFailedCount']++; $stats['emailFailedCount']++; } @@ -381,7 +374,7 @@ class RecoveryWarningNotificationCommand extends Command { $translations = $this->notificationService->getTranslatedSubjectAndMessage($this->messageId, $language); $message = $translations['message']; - $disableDate = $this->recoveryEmailService->getUnverifiedUserDisableAt($username); + $disableDate = $this->recoveryEmailService->getUnverifiedUserDisableAt($username) ?? ''; $parsedMessage = $this->notificationService->getParsedString($message, $username, $disableDate); return $parsedMessage['message']; } diff --git a/lib/Notification/Notifier.php b/lib/Notification/Notifier.php index f218135..7a0edb9 100644 --- a/lib/Notification/Notifier.php +++ b/lib/Notification/Notifier.php @@ -102,7 +102,7 @@ class Notifier implements INotifier { $plainSubject = $parsedSubject['message']; $richSubject = $parsedSubject['richString']; - $disableDate = $this->recoveryEmailService->getUnverifiedUserDisableAt($username); + $disableDate = $this->recoveryEmailService->getUnverifiedUserDisableAt($username) ?? ''; $parsedMessage = $this->NotificationService->getParsedString($message, $username, $disableDate); $messageParameters = $parsedMessage['parameters']; $plainMessage = $parsedMessage['message']; -- GitLab From 6a39a6d0bafb864bf96ac5c585a011a06ead0dfc Mon Sep 17 00:00:00 2001 From: theronakpatel Date: Thu, 28 Aug 2025 19:32:20 +0530 Subject: [PATCH 2/5] removed unncessary loggers --- lib/Command/RecoveryWarningNotificationCommand.php | 2 +- lib/Notification/Notifier.php | 2 +- lib/Service/RecoveryEmailService.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Command/RecoveryWarningNotificationCommand.php b/lib/Command/RecoveryWarningNotificationCommand.php index b897673..1548fc1 100644 --- a/lib/Command/RecoveryWarningNotificationCommand.php +++ b/lib/Command/RecoveryWarningNotificationCommand.php @@ -374,7 +374,7 @@ class RecoveryWarningNotificationCommand extends Command { $translations = $this->notificationService->getTranslatedSubjectAndMessage($this->messageId, $language); $message = $translations['message']; - $disableDate = $this->recoveryEmailService->getUnverifiedUserDisableAt($username) ?? ''; + $disableDate = $this->recoveryEmailService->getUnverifiedUserDisableAt($username); $parsedMessage = $this->notificationService->getParsedString($message, $username, $disableDate); return $parsedMessage['message']; } diff --git a/lib/Notification/Notifier.php b/lib/Notification/Notifier.php index 7a0edb9..f218135 100644 --- a/lib/Notification/Notifier.php +++ b/lib/Notification/Notifier.php @@ -102,7 +102,7 @@ class Notifier implements INotifier { $plainSubject = $parsedSubject['message']; $richSubject = $parsedSubject['richString']; - $disableDate = $this->recoveryEmailService->getUnverifiedUserDisableAt($username) ?? ''; + $disableDate = $this->recoveryEmailService->getUnverifiedUserDisableAt($username); $parsedMessage = $this->NotificationService->getParsedString($message, $username, $disableDate); $messageParameters = $parsedMessage['parameters']; $plainMessage = $parsedMessage['message']; diff --git a/lib/Service/RecoveryEmailService.php b/lib/Service/RecoveryEmailService.php index 4232d5a..b08cbcd 100644 --- a/lib/Service/RecoveryEmailService.php +++ b/lib/Service/RecoveryEmailService.php @@ -659,8 +659,8 @@ class RecoveryEmailService { $this->config->deleteUserValue($uid, $this->appName, self::RECOVERY_EMAIL_REMINDER_START_DATE); } /** Unverified user disable At **/ - public function getUnverifiedUserDisableAt(string $uid): ?string { - return $this->config->getUserValue($uid, $this->appName, self::UNVERIFIED_USER_DISABLE_AT, null); + public function getUnverifiedUserDisableAt(string $uid): string { + return $this->config->getUserValue($uid, $this->appName, self::UNVERIFIED_USER_DISABLE_AT, '') ?? ''; } public function setUnverifiedUserDisableAt(string $uid, string $disableDate): void { $this->config->setUserValue($uid, $this->appName, self::UNVERIFIED_USER_DISABLE_AT, $disableDate); -- GitLab From 5df7d0a87c5d31ab547e2c332b787c806817b7cb Mon Sep 17 00:00:00 2001 From: theronakpatel Date: Thu, 28 Aug 2025 22:57:44 +0530 Subject: [PATCH 3/5] disableDate missing when first-run --- lib/Command/RecoveryWarningNotificationCommand.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/Command/RecoveryWarningNotificationCommand.php b/lib/Command/RecoveryWarningNotificationCommand.php index 1548fc1..b549597 100644 --- a/lib/Command/RecoveryWarningNotificationCommand.php +++ b/lib/Command/RecoveryWarningNotificationCommand.php @@ -196,6 +196,10 @@ class RecoveryWarningNotificationCommand extends Command { if ($firstRunDate === null) { $firstRunDate = time(); $this->config->setUserValue($uid, Application::APP_ID, 'first-run-date', $firstRunDate); + + // Set the disable date using config variable + $disableDate = date('Y-m-d', strtotime($firstRunDate . ' +' . $this->disableUserAfterUnverifiedDays . ' days')); + $this->recoveryEmailService->setUnverifiedUserDisableAt($uid, $disableDate); } // Calculate age and process @@ -483,6 +487,7 @@ class RecoveryWarningNotificationCommand extends Command { $this->config->deleteUserValue($uid, Application::APP_ID, 'first-run-date'); $this->config->deleteUserValue($uid, Application::APP_ID, 'account-disabled-at'); + $this->recoveryEmailService->deleteUnverifiedUserDisableAt($uid); $user->delete(); $deletedCount++; -- GitLab From a2144bb564cf63a3fd6803593d9c02512ec0c395 Mon Sep 17 00:00:00 2001 From: theronakpatel Date: Fri, 29 Aug 2025 00:13:23 +0530 Subject: [PATCH 4/5] changes --- lib/Command/RecoveryWarningNotificationCommand.php | 11 +++++++++-- lib/Service/RecoveryEmailService.php | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/Command/RecoveryWarningNotificationCommand.php b/lib/Command/RecoveryWarningNotificationCommand.php index b549597..fb7a7cf 100644 --- a/lib/Command/RecoveryWarningNotificationCommand.php +++ b/lib/Command/RecoveryWarningNotificationCommand.php @@ -193,12 +193,20 @@ class RecoveryWarningNotificationCommand extends Command { // Get or set first run date $firstRunDate = $this->config->getUserValue($uid, Application::APP_ID, 'first-run-date', null); + // Ensure firstRunDate is an integer timestamp + $firstRunDate = $firstRunDate ? (int)$firstRunDate : null; + if ($firstRunDate === null) { $firstRunDate = time(); $this->config->setUserValue($uid, Application::APP_ID, 'first-run-date', $firstRunDate); + } + // Check if disable date is already set, if not set it + $existingDisableDate = $this->recoveryEmailService->getUnverifiedUserDisableAt($uid); + + if (empty($existingDisableDate)) { // Set the disable date using config variable - $disableDate = date('Y-m-d', strtotime($firstRunDate . ' +' . $this->disableUserAfterUnverifiedDays . ' days')); + $disableDate = date('Y-m-d', $firstRunDate + ($this->disableUserAfterUnverifiedDays * 24 * 60 * 60)); $this->recoveryEmailService->setUnverifiedUserDisableAt($uid, $disableDate); } @@ -388,7 +396,6 @@ class RecoveryWarningNotificationCommand extends Command { private function sendNotificationToUser(string $messageId, $user, $notification, OutputInterface $output): void { $uid = $user->getUID(); $displayName = $user->getDisplayName(); - try { $notification->setSubject('cli', [$messageId, $displayName]) ->setMessage('cli', [$messageId, $displayName]) diff --git a/lib/Service/RecoveryEmailService.php b/lib/Service/RecoveryEmailService.php index b08cbcd..1367ea6 100644 --- a/lib/Service/RecoveryEmailService.php +++ b/lib/Service/RecoveryEmailService.php @@ -660,7 +660,7 @@ class RecoveryEmailService { } /** Unverified user disable At **/ public function getUnverifiedUserDisableAt(string $uid): string { - return $this->config->getUserValue($uid, $this->appName, self::UNVERIFIED_USER_DISABLE_AT, '') ?? ''; + return $this->config->getUserValue($uid, $this->appName, self::UNVERIFIED_USER_DISABLE_AT, ''); } public function setUnverifiedUserDisableAt(string $uid, string $disableDate): void { $this->config->setUserValue($uid, $this->appName, self::UNVERIFIED_USER_DISABLE_AT, $disableDate); -- GitLab From f70ef5e926a6100350360b99c009790ffe132f6a Mon Sep 17 00:00:00 2001 From: theronakpatel Date: Fri, 29 Aug 2025 01:32:45 +0530 Subject: [PATCH 5/5] date issue --- lib/Notification/Notifier.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/Notification/Notifier.php b/lib/Notification/Notifier.php index f218135..af645f8 100644 --- a/lib/Notification/Notifier.php +++ b/lib/Notification/Notifier.php @@ -91,19 +91,22 @@ class Notifier implements INotifier { try { $subjectParams = $notification->getSubjectParameters(); $messageId = $subjectParams[0]; - $username = $subjectParams[1]; + $displayName = $subjectParams[1]; + + // Get the actual user ID from the notification + $userId = $notification->getUser(); $translations = $this->NotificationService->getTranslatedSubjectAndMessage($messageId, $languageCode); $subject = $translations['subject']; $message = $translations['message']; - $parsedSubject = $this->NotificationService->getParsedString($subject, $username); + $parsedSubject = $this->NotificationService->getParsedString($subject, $displayName); $subjectParameters = $parsedSubject['parameters']; $plainSubject = $parsedSubject['message']; $richSubject = $parsedSubject['richString']; - $disableDate = $this->recoveryEmailService->getUnverifiedUserDisableAt($username); - $parsedMessage = $this->NotificationService->getParsedString($message, $username, $disableDate); + $disableDate = $this->recoveryEmailService->getUnverifiedUserDisableAt($userId); + $parsedMessage = $this->NotificationService->getParsedString($message, $displayName, $disableDate); $messageParameters = $parsedMessage['parameters']; $plainMessage = $parsedMessage['message']; $richMessage = $parsedMessage['richString']; -- GitLab