Merge branch 'dev/sync-nextcloud-addressbook' into draft/dev_sync-nextcloud-addressbook

This commit is contained in:
Fahim Salam Chowdhury 2024-09-03 11:30:33 +06:00
commit 2e3fbe0a12
87 changed files with 3360 additions and 402 deletions

View file

@ -186,6 +186,10 @@
if (msg?.from?.[0]) {
let url = getAvatar(msg),
fn = url=>{element.src = url};
element.onerror = ()=>{
element.onerror = null;
setIdenticon(msg.from[0], fn);
};
if (url) {
fn(url);
} else if (msg.avatar?.startsWith('data:')) {

View file

@ -10,8 +10,8 @@ class AvatarsPlugin extends \RainLoop\Plugins\AbstractPlugin
NAME = 'Avatars',
AUTHOR = 'SnappyMail',
URL = 'https://snappymail.eu/',
VERSION = '1.19',
RELEASE = '2024-07-08',
VERSION = '1.20',
RELEASE = '2024-08-26',
REQUIRED = '2.33.0',
CATEGORY = 'Contacts',
LICENSE = 'MIT',
@ -116,12 +116,16 @@ class AvatarsPlugin extends \RainLoop\Plugins\AbstractPlugin
* Nextcloud Mail uses insecure unencrypted 'index.php/apps/mail/api/avatars/url/local%40example.com'
*/
// public function ServiceAvatar(...$aParts)
public function ServiceAvatar(string $sServiceName, string $sBimi, string $sEmail)
public function ServiceAvatar(string $sServiceName, string $sBimi, string $sEncryptedEmail)
{
$sEmail = \SnappyMail\Crypt::DecryptUrlSafe($sEmail);
$maxAge = 86400;
$sEmail = \SnappyMail\Crypt::DecryptUrlSafe($sEncryptedEmail);
$aBimi = \explode('-', $sBimi, 2);
$sBimiSelector = isset($aBimi[1]) ? $aBimi[1] : 'default';
// $sEmail && \MailSo\Base\Http::setETag("{$sBimiSelector}-{$sEncryptedEmail}");
if ($sEmail && ($aResult = $this->getAvatar($sEmail, !empty($aBimi[0]), $sBimiSelector))) {
\header("Cache-Control: max-age={$maxAge}, private");
\header('Expires: '.\gmdate('D, j M Y H:i:s', $maxAge + \time()).' UTC');
\header('Content-Type: '.$aResult[0]);
echo $aResult[1];
} else {

View file

@ -99,11 +99,6 @@ class KolabAddressBook implements \RainLoop\Providers\AddressBook\AddressBookInt
return true;
}
public function IsExternal(): bool
{
return false;
}
public function SetEmail(string $sEmail) : bool
{
return true;

View file

@ -60,13 +60,7 @@ class NextcloudAddressBook implements \RainLoop\Providers\AddressBook\AddressBoo
return true;
}
public function IsExternal(): bool
{
return true;
}
public function SetEmail(string $sEmail): bool
{
public function SetEmail(string $sEmail) : bool {
return true;
}

View file

@ -451,7 +451,7 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
$ignoreSystemAddressbook
);
}
/*
/*
if ($this->Config()->Get('plugin', 'storage', false) && ('storage' === $sName || 'storage-local' === $sName)) {
require_once __DIR__ . '/storage.php';
$oDriver = new \NextcloudStorage(APP_PRIVATE_DATA.'storage', $sName === 'storage-local');