Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ac9c9756 authored by Ronak Patel's avatar Ronak Patel
Browse files

Merge branch 'dev/remove-output' into 'main'

disableDate missing when first-run

See merge request !106
parents 01092c90 428956a6
Loading
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -193,11 +193,23 @@ 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', $firstRunDate + ($this->disableUserAfterUnverifiedDays * 24 * 60 * 60));
					$this->recoveryEmailService->setUnverifiedUserDisableAt($uid, $disableDate);
				}

				// Calculate age and process
				$age = (int) ((time() - $firstRunDate) / (24 * 60 * 60));

@@ -384,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])
@@ -483,6 +494,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++;
+7 −4
Original line number Diff line number Diff line
@@ -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'];
+1 −1
Original line number Diff line number Diff line
@@ -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);