Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions lib/Repair/ResetEmails.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
use OCP\IUserManager;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
use Psr\Log\LoggerInterface;

class ResetEmails implements IRepairStep {
public function __construct(
private readonly GuestManager $guestManager,
private readonly IUserManager $userManager,
private readonly IAppConfig $appConfig,
private readonly IConfig $config,
private readonly LoggerInterface $logger,
) {
}

Expand All @@ -39,9 +41,17 @@ public function run(IOutput $output) {

foreach ($this->guestManager->listGuests() as $guestId) {
$guest = $this->userManager->get($guestId);
if ($guest === null) {
$output->warning('Unable to find user object for guest with id "' . $guestId . '"');
$this->logger->warning('Unable to find user object for guest', ['guestId' => $guestId]);
continue;
}

$expectedEmail = $this->config->getUserValue($guestId, Application::APP_ID, 'email', strtolower($guestId));
if (strtolower($guest?->getSystemEMailAddress() ?? '') !== $expectedEmail) {
$this->config->setUserValue($guestId, 'guests', 'old_email', $guest?->getSystemEMailAddress() ?? '');
$currentEmail = $guest->getSystemEMailAddress() ?? '';

if (strtolower($currentEmail) !== $expectedEmail) {
$this->config->setUserValue($guestId, 'guests', 'old_email', $currentEmail);
$guest->setSystemEMailAddress($expectedEmail);
}
}
Expand Down
Loading