Bugfix: Export contacts failed

This commit is contained in:
the-djmaze 2022-05-18 23:43:29 +02:00
parent 33f0e6febf
commit 01e5916bf3
2 changed files with 32 additions and 25 deletions

View file

@ -297,10 +297,11 @@ trait Contacts
\header('Accept-Ranges: none');
\header('Content-Transfer-Encoding: binary');
$this->oHttp->ServerNoCache();
$this->Http()->ServerNoCache();
return $this->AddressBookProvider($oAccount)->IsActive() ?
$this->AddressBookProvider($oAccount)->Export($this->GetMainEmail($oAccount), 'vcf') : false;
$oAddressBookProvider = $this->AddressBookProvider($oAccount);
return $oAddressBookProvider->IsActive() ?
$oAddressBookProvider->Export($this->GetMainEmail($oAccount), 'vcf') : false;
}
public function RawContactsCsv() : bool
@ -312,10 +313,11 @@ trait Contacts
\header('Accept-Ranges: none');
\header('Content-Transfer-Encoding: binary');
$this->oHttp->ServerNoCache();
$this->Http()->ServerNoCache();
return $this->AddressBookProvider($oAccount)->IsActive() ?
$this->AddressBookProvider($oAccount)->Export($this->GetMainEmail($oAccount), 'csv') : false;
$oAddressBookProvider = $this->AddressBookProvider($oAccount);
return $oAddressBookProvider->IsActive() ?
$oAddressBookProvider->Export($this->GetMainEmail($oAccount), 'csv') : false;
}
private function importContactsFromVcfFile(\RainLoop\Model\Account $oAccount, /*resource*/ $rFile): int

View file

@ -394,28 +394,33 @@ class ServiceActions
try
{
$sRawError = 'Invalid action';
if (0 !== \strlen($sAction))
if (\strlen($sAction))
{
$sMethodName = 'Raw'.$sAction;
if (\method_exists($this->oActions, $sMethodName))
{
\header('X-Raw-Action: '.$sMethodName);
\header('Content-Security-Policy: script-src \'none\'; child-src \'none\'');
$sRawError = '';
$this->oActions->SetActionParams(array(
'RawKey' => empty($this->aPaths[3]) ? '' : $this->aPaths[3],
'Params' => $this->aPaths
), $sMethodName);
if (!$this->oActions->{$sMethodName}())
try {
$sMethodName = 'Raw'.$sAction;
if (\method_exists($this->oActions, $sMethodName))
{
$sRawError = 'False result';
\header('X-Raw-Action: '.$sMethodName);
\header('Content-Security-Policy: script-src \'none\'; child-src \'none\'');
$sRawError = '';
$this->oActions->SetActionParams(array(
'RawKey' => empty($this->aPaths[3]) ? '' : $this->aPaths[3],
'Params' => $this->aPaths
), $sMethodName);
if (!$this->oActions->{$sMethodName}())
{
$sRawError = 'False result';
}
}
}
else
{
$sRawError = 'Unknown action "'.$sAction.'"';
else
{
$sRawError = 'Unknown action "'.$sAction.'"';
}
} catch (\Throwable $e) {
// error_log(print_r($e,1));
$sRawError = $e->getMessage();
}
}
else