Loading lib/Command/RecoveryWarningNotificationCommand.php +26 −12 Original line number Diff line number Diff line Loading @@ -230,6 +230,7 @@ class RecoveryWarningNotificationCommand extends Command { // Set the disable date using config variable $disableDate = date('Y-m-d', $firstRunDate + ($this->disableUserAfterUnverifiedDays * 24 * 60 * 60)); $this->recoveryEmailService->setUnverifiedUserDisableAt($uid, $disableDate); $existingDisableDate = $disableDate; } // Calculate age and process Loading @@ -242,6 +243,19 @@ class RecoveryWarningNotificationCommand extends Command { $this->identifyForDisable($user, $age); $this->identifyForDelete($user, $age); $disabledAtTimestamp = strtotime($existingDisableDate); $deleteDate = date('Y-m-d', $disabledAtTimestamp + ($this->deleteUserAfterDisableDays * 24 * 60 * 60)); // Output summary $output->writeln(sprintf( "User: %s | Age: %d days | Disable date: %s | Delete date: %s", $username, $age, $existingDisableDate ?? 'N/A', $deleteDate ?? 'N/A' )); $processedCount++; } catch (\Throwable $e) { $errorCount++; Loading Loading @@ -410,7 +424,7 @@ class RecoveryWarningNotificationCommand extends Command { $translations = $this->notificationService->getTranslatedSubjectAndMessage($this->messageId, $language); $message = $translations['message']; $disableDate = $this->recoveryEmailService->getUnverifiedUserDisableAt($username); $disableDate = $this->recoveryEmailService->getUnverifiedUserDisableAt($uid); $parsedMessage = $this->notificationService->getParsedString($message, $username, $disableDate); return $parsedMessage['message']; } Loading @@ -434,9 +448,6 @@ class RecoveryWarningNotificationCommand extends Command { private function sendEmail(string $subject, string $message, string $emailAddress, OutputInterface $output): void { try { // Convert Markdown-style links to HTML anchor tags $message = preg_replace('/\[(.*?)\]\((.*?)\)/', "<a href='$2'>$1</a>", $message); $template = $this->mailer->createEMailTemplate(Application::APP_ID . '::sendMail'); $template->setSubject($subject); $template->addHeader(); Loading @@ -456,19 +467,22 @@ class RecoveryWarningNotificationCommand extends Command { } private function setMailBody(IEMailTemplate $template, string $message): void { $lines = explode("\n", $message); $finalHtml = ""; $finalText = ""; $lines = preg_split('/\R/', $message); foreach ($lines as $line) { if (trim($line) === '') { $trimmed = trim($line); if ($trimmed === '') { continue; } $finalHtml .= "<p>" . $line . "</p>"; $finalText .= $line; if (preg_match('/^\[(.*?)\]\((.*?)\)$/', $trimmed, $matches) === 1) { $template->addBodyButton($matches[1], $matches[2]); continue; } $template->addBodyText($finalHtml, $finalText); $template->addBodyText($trimmed); } } private function disableUnverifiedUsers(OutputInterface $output): void { Loading lib/Service/NotificationService.php +7 −4 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ use OCP\L10N\IFactory; class NotificationService { /** @var IFactory */ protected $l10nFactory; public const SUPPORTED_LANGUAGES = ['en', 'de', 'de_DE', 'es', 'fr', 'it']; public function __construct(IFactory $l10nFactory) { $this->l10nFactory = $l10nFactory; Loading Loading @@ -133,11 +134,13 @@ class NotificationService { * @param string $messageId * @param string|null $language */ public function getTranslatedSubjectAndMessage(string $messageId, $language) { if (is_null($language)) { public function getTranslatedSubjectAndMessage(string $messageId, ?string $language = null) { if (!in_array($language, self::SUPPORTED_LANGUAGES)) { $language = 'en'; } $l = $this->l10nFactory->get(Application::APP_ID, $language); return ['subject' => $l->t($messageId . '_subject'), 'message' => $l->t($messageId . '_body')]; $l10n = $this->l10nFactory->get(Application::APP_ID, $language); $subjectKey = $messageId . '_subject'; $bodyKey = $messageId . '_body'; return ['subject' => $l10n->t($subjectKey), 'message' => $l10n->t($bodyKey)]; } } Loading
lib/Command/RecoveryWarningNotificationCommand.php +26 −12 Original line number Diff line number Diff line Loading @@ -230,6 +230,7 @@ class RecoveryWarningNotificationCommand extends Command { // Set the disable date using config variable $disableDate = date('Y-m-d', $firstRunDate + ($this->disableUserAfterUnverifiedDays * 24 * 60 * 60)); $this->recoveryEmailService->setUnverifiedUserDisableAt($uid, $disableDate); $existingDisableDate = $disableDate; } // Calculate age and process Loading @@ -242,6 +243,19 @@ class RecoveryWarningNotificationCommand extends Command { $this->identifyForDisable($user, $age); $this->identifyForDelete($user, $age); $disabledAtTimestamp = strtotime($existingDisableDate); $deleteDate = date('Y-m-d', $disabledAtTimestamp + ($this->deleteUserAfterDisableDays * 24 * 60 * 60)); // Output summary $output->writeln(sprintf( "User: %s | Age: %d days | Disable date: %s | Delete date: %s", $username, $age, $existingDisableDate ?? 'N/A', $deleteDate ?? 'N/A' )); $processedCount++; } catch (\Throwable $e) { $errorCount++; Loading Loading @@ -410,7 +424,7 @@ class RecoveryWarningNotificationCommand extends Command { $translations = $this->notificationService->getTranslatedSubjectAndMessage($this->messageId, $language); $message = $translations['message']; $disableDate = $this->recoveryEmailService->getUnverifiedUserDisableAt($username); $disableDate = $this->recoveryEmailService->getUnverifiedUserDisableAt($uid); $parsedMessage = $this->notificationService->getParsedString($message, $username, $disableDate); return $parsedMessage['message']; } Loading @@ -434,9 +448,6 @@ class RecoveryWarningNotificationCommand extends Command { private function sendEmail(string $subject, string $message, string $emailAddress, OutputInterface $output): void { try { // Convert Markdown-style links to HTML anchor tags $message = preg_replace('/\[(.*?)\]\((.*?)\)/', "<a href='$2'>$1</a>", $message); $template = $this->mailer->createEMailTemplate(Application::APP_ID . '::sendMail'); $template->setSubject($subject); $template->addHeader(); Loading @@ -456,19 +467,22 @@ class RecoveryWarningNotificationCommand extends Command { } private function setMailBody(IEMailTemplate $template, string $message): void { $lines = explode("\n", $message); $finalHtml = ""; $finalText = ""; $lines = preg_split('/\R/', $message); foreach ($lines as $line) { if (trim($line) === '') { $trimmed = trim($line); if ($trimmed === '') { continue; } $finalHtml .= "<p>" . $line . "</p>"; $finalText .= $line; if (preg_match('/^\[(.*?)\]\((.*?)\)$/', $trimmed, $matches) === 1) { $template->addBodyButton($matches[1], $matches[2]); continue; } $template->addBodyText($finalHtml, $finalText); $template->addBodyText($trimmed); } } private function disableUnverifiedUsers(OutputInterface $output): void { Loading
lib/Service/NotificationService.php +7 −4 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ use OCP\L10N\IFactory; class NotificationService { /** @var IFactory */ protected $l10nFactory; public const SUPPORTED_LANGUAGES = ['en', 'de', 'de_DE', 'es', 'fr', 'it']; public function __construct(IFactory $l10nFactory) { $this->l10nFactory = $l10nFactory; Loading Loading @@ -133,11 +134,13 @@ class NotificationService { * @param string $messageId * @param string|null $language */ public function getTranslatedSubjectAndMessage(string $messageId, $language) { if (is_null($language)) { public function getTranslatedSubjectAndMessage(string $messageId, ?string $language = null) { if (!in_array($language, self::SUPPORTED_LANGUAGES)) { $language = 'en'; } $l = $this->l10nFactory->get(Application::APP_ID, $language); return ['subject' => $l->t($messageId . '_subject'), 'message' => $l->t($messageId . '_body')]; $l10n = $this->l10nFactory->get(Application::APP_ID, $language); $subjectKey = $messageId . '_subject'; $bodyKey = $messageId . '_body'; return ['subject' => $l10n->t($subjectKey), 'message' => $l10n->t($bodyKey)]; } }