Skip to content

Commit

Permalink
Return false on more server issues regarding domains control #1513
Browse files Browse the repository at this point in the history
  • Loading branch information
the-djmaze committed Mar 24, 2024
1 parent 6df5802 commit 2a11661
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,27 @@ public function Load(string $sName, bool $bFindWithWildCard = false, bool $bChec

public function Save(\RainLoop\Model\Domain $oDomain) : bool
{
$this->Delete($oDomain->Name());
$sRealFileName = static::encodeFileName($oDomain->Name());
\RainLoop\Utils::saveFile($this->sDomainPath.'/'.$sRealFileName.'.json', \json_encode($oDomain, \JSON_PRETTY_PRINT));
if (!$sRealFileName) {
return false;
}
$this->Delete($oDomain->Name());
\RainLoop\Utils::saveFile("{$this->sDomainPath}/{$sRealFileName}.json", \json_encode($oDomain, \JSON_PRETTY_PRINT));
$this->oCacher && $this->oCacher->Delete(static::CACHE_KEY);
return true;
}

public function SaveAlias(string $sName, string $sTarget) : bool
{
// $this->Delete($sName);
// $sTarget = \SnappyMail\IDN::toAscii($sTarget);
// $sTarget = static::encodeFileName($sTarget);
$sTarget = \strtolower(\idn_to_ascii($sTarget));
$sRealFileName = static::encodeFileName($sName);
\RainLoop\Utils::saveFile($this->sDomainPath.'/'.$sRealFileName.'.alias', $sTarget);
if (!$sRealFileName || !$sTarget/* || !\is_readable("{$this->sDomainPath}/{$sTarget}.json")*/) {
return false;
}
// $this->Delete($sName);
\RainLoop\Utils::saveFile("{$this->sDomainPath}/{$sRealFileName}.alias", $sTarget);
$this->oCacher && $this->oCacher->Delete(static::CACHE_KEY);
return true;
}
Expand Down Expand Up @@ -170,7 +177,8 @@ public function Disable(string $sName, bool $bDisable) : bool
} else {
$aResult = \array_filter($aResult, fn($v) => $v !== $sName);
}
\RainLoop\Utils::saveFile($this->sDomainPath.'/disabled', \implode("\n", \array_unique($aResult)));
$aResult = \array_unique($aResult);
\RainLoop\Utils::saveFile($this->sDomainPath.'/disabled', \implode("\n", $aResult));
return $this->getDisabled() === $aResult;
}
return false;
Expand Down

0 comments on commit 2a11661

Please sign in to comment.