mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Make Gravatar and BIMI optional #115
This commit is contained in:
parent
0deedbecf5
commit
59cd22625a
1 changed files with 24 additions and 9 deletions
|
|
@ -47,6 +47,18 @@ class AvatarsPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function configMapping() : array
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
\RainLoop\Plugins\Property::NewInstance('bimi')->SetLabel('Use BIMI (https://bimigroup.org/)')
|
||||||
|
->SetType(\RainLoop\Enumerations\PluginPropertyType::BOOL)
|
||||||
|
->SetDefaultValue(false),
|
||||||
|
\RainLoop\Plugins\Property::NewInstance('gravatar')->SetLabel('Use Gravatar')
|
||||||
|
->SetType(\RainLoop\Enumerations\PluginPropertyType::BOOL)
|
||||||
|
->SetDefaultValue(false)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private static function getAvatar(string $sEmail, bool $bBimi) : ?array
|
private static function getAvatar(string $sEmail, bool $bBimi) : ?array
|
||||||
{
|
{
|
||||||
if (!\strpos($sEmail, '@')) {
|
if (!\strpos($sEmail, '@')) {
|
||||||
|
|
@ -97,6 +109,7 @@ class AvatarsPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
|
|
||||||
$aUrls = [];
|
$aUrls = [];
|
||||||
|
|
||||||
|
if ($this->Config()->Get('plugin', 'bimi', false)) {
|
||||||
$BIMI = $bBimi ? \SnappyMail\DNS::BIMI($sDomain) : null;
|
$BIMI = $bBimi ? \SnappyMail\DNS::BIMI($sDomain) : null;
|
||||||
if ($BIMI) {
|
if ($BIMI) {
|
||||||
$aUrls[] = $BIMI;
|
$aUrls[] = $BIMI;
|
||||||
|
|
@ -105,9 +118,11 @@ class AvatarsPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
} else {
|
} else {
|
||||||
\SnappyMail\Log::notice('Avatar', "BIMI 404 for {$sDomain}");
|
\SnappyMail\Log::notice('Avatar', "BIMI 404 for {$sDomain}");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: make Gravatar optional
|
if ($this->Config()->Get('plugin', 'gravatar', false)) {
|
||||||
$aUrls[] = 'http://gravatar.com/avatar/'.\md5(\strtolower($sAsciiEmail)).'?s=80&d=404';
|
$aUrls[] = 'http://gravatar.com/avatar/'.\md5(\strtolower($sAsciiEmail)).'?s=80&d=404';
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($aUrls as $sUrl) {
|
foreach ($aUrls as $sUrl) {
|
||||||
if ($aResult = static::getUrl($sUrl)) {
|
if ($aResult = static::getUrl($sUrl)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue