diff --git a/plugins/avatars/LICENSE b/plugins/avatars/LICENSE
new file mode 100644
index 000000000..f709b02e2
--- /dev/null
+++ b/plugins/avatars/LICENSE
@@ -0,0 +1,20 @@
+The MIT License (MIT)
+
+Copyright (c) 2016 RainLoop Team
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/plugins/avatars/avatars.js b/plugins/avatars/avatars.js
new file mode 100644
index 000000000..6d45dc376
--- /dev/null
+++ b/plugins/avatars/avatars.js
@@ -0,0 +1,43 @@
+(rl => {
+// if (rl.settings.get('Nextcloud'))
+ const
+ templateId = 'MailMessageView';
+// DATA_IMAGE_USER_DOT_PIC = 'data:image/svg+xml;utf8,';
+
+ addEventListener('rl-view-model.create', e => {
+ if (templateId === e.detail.viewModelTemplateID) {
+
+ const
+ template = document.getElementById(templateId),
+ messageItemHeader = template.content.querySelector('.messageItemHeader');
+
+ if (messageItemHeader) {
+ messageItemHeader.prepend(Element.fromHTML(
+ `
`
+ ));
+ }
+
+ let view = e.detail;
+ view.viewUserPic = ko.observable('');
+ view.viewUserPicVisible = ko.observable(false);
+
+ view.message.subscribe(msg => {
+ if (msg) {
+ let from = msg.from[0],
+ bimi = 'pass' == from.dkimStatus ? 1 : 0;
+// view.viewUserPic(`?Avatar/${bimi}/${encodeURIComponent(from.email)}`);
+ rl.pluginRemoteRequest((iError, data) => {
+ if (!iError && data?.Result.type) {
+ view.viewUserPic(`data:${data.Result.type};base64,${data.Result.data}`);
+ view.viewUserPicVisible(true);
+ }
+ }, 'Avatar', {
+ bimi: bimi,
+ email: from.email
+ });
+ }
+ });
+ }
+ });
+
+})(window.rl);
diff --git a/plugins/avatars/images/empty-contact.png b/plugins/avatars/images/empty-contact.png
new file mode 100644
index 000000000..b2f2071d1
Binary files /dev/null and b/plugins/avatars/images/empty-contact.png differ
diff --git a/plugins/avatars/images/services/amazon.com.png b/plugins/avatars/images/services/amazon.com.png
new file mode 100644
index 000000000..07ad04dff
Binary files /dev/null and b/plugins/avatars/images/services/amazon.com.png differ
diff --git a/plugins/avatars/images/services/apple.com.png b/plugins/avatars/images/services/apple.com.png
new file mode 100644
index 000000000..72b10f4df
Binary files /dev/null and b/plugins/avatars/images/services/apple.com.png differ
diff --git a/plugins/avatars/images/services/asana.com.png b/plugins/avatars/images/services/asana.com.png
new file mode 100644
index 000000000..35d3e1db5
Binary files /dev/null and b/plugins/avatars/images/services/asana.com.png differ
diff --git a/plugins/avatars/images/services/battle.net.png b/plugins/avatars/images/services/battle.net.png
new file mode 100644
index 000000000..f5baf8db8
Binary files /dev/null and b/plugins/avatars/images/services/battle.net.png differ
diff --git a/plugins/avatars/images/services/blizzard.com.png b/plugins/avatars/images/services/blizzard.com.png
new file mode 100644
index 000000000..f5baf8db8
Binary files /dev/null and b/plugins/avatars/images/services/blizzard.com.png differ
diff --git a/plugins/avatars/images/services/cnet.online.com.png b/plugins/avatars/images/services/cnet.online.com.png
new file mode 100644
index 000000000..b3f2b5325
Binary files /dev/null and b/plugins/avatars/images/services/cnet.online.com.png differ
diff --git a/plugins/avatars/images/services/connect.asana.com.png b/plugins/avatars/images/services/connect.asana.com.png
new file mode 100644
index 000000000..35d3e1db5
Binary files /dev/null and b/plugins/avatars/images/services/connect.asana.com.png differ
diff --git a/plugins/avatars/images/services/e.paypal.com.png b/plugins/avatars/images/services/e.paypal.com.png
new file mode 100644
index 000000000..7ddea03c9
Binary files /dev/null and b/plugins/avatars/images/services/e.paypal.com.png differ
diff --git a/plugins/avatars/images/services/ea.com.png b/plugins/avatars/images/services/ea.com.png
new file mode 100644
index 000000000..e88b641c6
Binary files /dev/null and b/plugins/avatars/images/services/ea.com.png differ
diff --git a/plugins/avatars/images/services/ebay.com.png b/plugins/avatars/images/services/ebay.com.png
new file mode 100644
index 000000000..b38920ca3
Binary files /dev/null and b/plugins/avatars/images/services/ebay.com.png differ
diff --git a/plugins/avatars/images/services/em.ea.com.png b/plugins/avatars/images/services/em.ea.com.png
new file mode 100644
index 000000000..e88b641c6
Binary files /dev/null and b/plugins/avatars/images/services/em.ea.com.png differ
diff --git a/plugins/avatars/images/services/email.blizzard.com.png b/plugins/avatars/images/services/email.blizzard.com.png
new file mode 100644
index 000000000..f5baf8db8
Binary files /dev/null and b/plugins/avatars/images/services/email.blizzard.com.png differ
diff --git a/plugins/avatars/images/services/email.microsoft.com.png b/plugins/avatars/images/services/email.microsoft.com.png
new file mode 100644
index 000000000..e058c2300
Binary files /dev/null and b/plugins/avatars/images/services/email.microsoft.com.png differ
diff --git a/plugins/avatars/images/services/email.skype.com.png b/plugins/avatars/images/services/email.skype.com.png
new file mode 100644
index 000000000..881b13cf8
Binary files /dev/null and b/plugins/avatars/images/services/email.skype.com.png differ
diff --git a/plugins/avatars/images/services/facebook.com.png b/plugins/avatars/images/services/facebook.com.png
new file mode 100644
index 000000000..2d416f898
Binary files /dev/null and b/plugins/avatars/images/services/facebook.com.png differ
diff --git a/plugins/avatars/images/services/facebookmail.com.png b/plugins/avatars/images/services/facebookmail.com.png
new file mode 100644
index 000000000..2d416f898
Binary files /dev/null and b/plugins/avatars/images/services/facebookmail.com.png differ
diff --git a/plugins/avatars/images/services/github.com.png b/plugins/avatars/images/services/github.com.png
new file mode 100644
index 000000000..6e3f84247
Binary files /dev/null and b/plugins/avatars/images/services/github.com.png differ
diff --git a/plugins/avatars/images/services/google.com.png b/plugins/avatars/images/services/google.com.png
new file mode 100644
index 000000000..143c40f4a
Binary files /dev/null and b/plugins/avatars/images/services/google.com.png differ
diff --git a/plugins/avatars/images/services/id.apple.com.png b/plugins/avatars/images/services/id.apple.com.png
new file mode 100644
index 000000000..72b10f4df
Binary files /dev/null and b/plugins/avatars/images/services/id.apple.com.png differ
diff --git a/plugins/avatars/images/services/intl.paypal.com.png b/plugins/avatars/images/services/intl.paypal.com.png
new file mode 100644
index 000000000..7ddea03c9
Binary files /dev/null and b/plugins/avatars/images/services/intl.paypal.com.png differ
diff --git a/plugins/avatars/images/services/microsoft.com.png b/plugins/avatars/images/services/microsoft.com.png
new file mode 100644
index 000000000..e058c2300
Binary files /dev/null and b/plugins/avatars/images/services/microsoft.com.png differ
diff --git a/plugins/avatars/images/services/microsoftonline.com.png b/plugins/avatars/images/services/microsoftonline.com.png
new file mode 100644
index 000000000..e058c2300
Binary files /dev/null and b/plugins/avatars/images/services/microsoftonline.com.png differ
diff --git a/plugins/avatars/images/services/myspace.com.png b/plugins/avatars/images/services/myspace.com.png
new file mode 100644
index 000000000..c29c00239
Binary files /dev/null and b/plugins/avatars/images/services/myspace.com.png differ
diff --git a/plugins/avatars/images/services/news.myspace.com.png b/plugins/avatars/images/services/news.myspace.com.png
new file mode 100644
index 000000000..c29c00239
Binary files /dev/null and b/plugins/avatars/images/services/news.myspace.com.png differ
diff --git a/plugins/avatars/images/services/news.onlive.com.png b/plugins/avatars/images/services/news.onlive.com.png
new file mode 100644
index 000000000..8207cd108
Binary files /dev/null and b/plugins/avatars/images/services/news.onlive.com.png differ
diff --git a/plugins/avatars/images/services/onlive.com.png b/plugins/avatars/images/services/onlive.com.png
new file mode 100644
index 000000000..8207cd108
Binary files /dev/null and b/plugins/avatars/images/services/onlive.com.png differ
diff --git a/plugins/avatars/images/services/paypal.com.png b/plugins/avatars/images/services/paypal.com.png
new file mode 100644
index 000000000..7ddea03c9
Binary files /dev/null and b/plugins/avatars/images/services/paypal.com.png differ
diff --git a/plugins/avatars/images/services/plus.google.com.png b/plugins/avatars/images/services/plus.google.com.png
new file mode 100644
index 000000000..12ccdc99e
Binary files /dev/null and b/plugins/avatars/images/services/plus.google.com.png differ
diff --git a/plugins/avatars/images/services/postmaster.twitter.com.png b/plugins/avatars/images/services/postmaster.twitter.com.png
new file mode 100644
index 000000000..18112e856
Binary files /dev/null and b/plugins/avatars/images/services/postmaster.twitter.com.png differ
diff --git a/plugins/avatars/images/services/reply.ebay.com.png b/plugins/avatars/images/services/reply.ebay.com.png
new file mode 100644
index 000000000..b38920ca3
Binary files /dev/null and b/plugins/avatars/images/services/reply.ebay.com.png differ
diff --git a/plugins/avatars/images/services/reply1.ebay.com.png b/plugins/avatars/images/services/reply1.ebay.com.png
new file mode 100644
index 000000000..b38920ca3
Binary files /dev/null and b/plugins/avatars/images/services/reply1.ebay.com.png differ
diff --git a/plugins/avatars/images/services/reply2.ebay.com.png b/plugins/avatars/images/services/reply2.ebay.com.png
new file mode 100644
index 000000000..b38920ca3
Binary files /dev/null and b/plugins/avatars/images/services/reply2.ebay.com.png differ
diff --git a/plugins/avatars/images/services/reply3.ebay.com.png b/plugins/avatars/images/services/reply3.ebay.com.png
new file mode 100644
index 000000000..b38920ca3
Binary files /dev/null and b/plugins/avatars/images/services/reply3.ebay.com.png differ
diff --git a/plugins/avatars/images/services/skype.com.png b/plugins/avatars/images/services/skype.com.png
new file mode 100644
index 000000000..881b13cf8
Binary files /dev/null and b/plugins/avatars/images/services/skype.com.png differ
diff --git a/plugins/avatars/images/services/steampowered.com.png b/plugins/avatars/images/services/steampowered.com.png
new file mode 100644
index 000000000..de6107010
Binary files /dev/null and b/plugins/avatars/images/services/steampowered.com.png differ
diff --git a/plugins/avatars/images/services/ted.com.png b/plugins/avatars/images/services/ted.com.png
new file mode 100644
index 000000000..bcc26f3b5
Binary files /dev/null and b/plugins/avatars/images/services/ted.com.png differ
diff --git a/plugins/avatars/images/services/twitter.com.png b/plugins/avatars/images/services/twitter.com.png
new file mode 100644
index 000000000..18112e856
Binary files /dev/null and b/plugins/avatars/images/services/twitter.com.png differ
diff --git a/plugins/avatars/images/services/youtube.com.png b/plugins/avatars/images/services/youtube.com.png
new file mode 100644
index 000000000..6bb581790
Binary files /dev/null and b/plugins/avatars/images/services/youtube.com.png differ
diff --git a/plugins/avatars/index.php b/plugins/avatars/index.php
new file mode 100644
index 000000000..038e21137
--- /dev/null
+++ b/plugins/avatars/index.php
@@ -0,0 +1,112 @@
+addCss('style.css');
+ $this->addJs('avatars.js');
+ $this->addJsonHook('Avatar', 'DoAvatar');
+ $this->addPartHook('Avatar', 'ServiceAvatar');
+ }
+
+ public function DoAvatar() : array
+ {
+ $bBimi = !empty($this->jsonParam('bimi'));
+ $sEmail = $this->jsonParam('email');
+ $aResult = static::getAvatar(\urldecode($sEmail), !empty($sEmail));
+ if ($aResult) {
+ $aResult = [
+ 'type' => $aResult[0],
+ 'data' => \base64_encode($aResult[1])
+ ];
+ }
+ return $this->jsonResponse(__FUNCTION__, $aResult);
+ }
+
+// public function ServiceAvatar(...$aParts)
+ public function ServiceAvatar(string $sServiceName, string $sBimi, string $sEmail)
+ {
+ $aResult = static::getAvatar(\urldecode($sEmail), !empty($sEmail));
+ if ($aResult) {
+ \header('Content-Type: '.$aResult[0]);
+ echo $aResult[1];
+ return true;
+ }
+ return false;
+ }
+
+ private static function getAvatar(string $sEmail, bool $bBimi) : ?array
+ {
+ if (!\strpos($sEmail, '@')) {
+ return null;
+ }
+
+// $this->verifyCacheByKey($sEmail);
+
+ // DATA_IMAGE_USER_DOT_PIC
+ $sDomain = \explode('@', $sEmail);
+ $sDomain = \array_pop($sDomain);
+
+ $BIMI = $bBimi ? \SnappyMail\DNS::BIMI($sDomain) : null;
+ // TODO: process $BIMI value
+
+ // TODO: lookup contacts vCard
+
+ // TODO: make this optional
+ $aResult = static::Gravatar($sEmail);
+
+ if (!$aResult && \file_exists(__DIR__ . '/images/services/'.$sDomain.'.png')) {
+ $aResult = [
+ 'image/png',
+ \file_get_contents(__DIR__ . '/images/services/'.$sDomain.'.png')
+ ];
+ }
+ if (!$aResult) {
+ $aResult = [
+ 'image/png',
+ \file_get_contents(__DIR__.'/images/empty-contact.png')
+ ];
+ }
+
+// $this->cacheByKey($sEmail);
+
+ return $aResult;
+ }
+
+ private static function Gravatar(string $sEmail) : ?array
+ {
+ $sEmail = \MailSo\Base\Utils::IdnToAscii($sEmail, true);
+ $sGravatarUrl = 'http://gravatar.com/avatar/'.\md5(\strtolower($sEmail)).'?s=80&d=404';
+ $oHTTP = \SnappyMail\HTTP\Request::factory(/*'socket' or 'curl'*/);
+ $oHTTP->proxy = \RainLoop\Api::Config()->Get('labs', 'curl_proxy', '');
+ $oHTTP->proxy_auth = \RainLoop\Api::Config()->Get('labs', 'curl_proxy_auth', '');
+ $oHTTP->max_response_kb = 0;
+ $oHTTP->timeout = 15; // timeout in seconds.
+ $oResponse = $oHTTP->doRequest('GET', $sGravatarUrl);
+ if ($oResponse) {
+ if (200 === $oResponse->status && \str_starts_with($oResponse->getHeader('content-type'), 'image/')) {
+ return [
+ $oResponse->getHeader('content-type'),
+ $oResponse->body
+ ];
+ }
+ \SnappyMail\Log::notice('Gravatar', "error {$oResponse->status} for {$sGravatarUrl}");
+ } else {
+ \SnappyMail\Log::warning('Gravatar', "failed for {$sGravatarUrl}");
+ }
+ return null;
+ }
+
+}
diff --git a/plugins/avatars/style.css b/plugins/avatars/style.css
new file mode 100644
index 000000000..dc7eeb2e3
--- /dev/null
+++ b/plugins/avatars/style.css
@@ -0,0 +1,11 @@
+.messageView .b-content .messageItemHeader .fromPic {
+ display: inline-block;
+ float: left;
+ width: 50px;
+ height: 50px;
+ padding: 2px;
+ margin: 0 5px 0 0;
+ background: #fff;
+ border: 1px solid #ccc;
+ border-radius: 6px;
+}
diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Mime/Email.php b/snappymail/v/0.0.0/app/libraries/MailSo/Mime/Email.php
index 047712430..a62b97daf 100644
--- a/snappymail/v/0.0.0/app/libraries/MailSo/Mime/Email.php
+++ b/snappymail/v/0.0.0/app/libraries/MailSo/Mime/Email.php
@@ -257,19 +257,12 @@ class Email implements \JsonSerializable
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
-/*
- $BIMI = '';
- if (Enumerations\DkimStatus::PASS == $this->GetDkimStatus()) {
- $BIMI = \SnappyMail\DNS\BIMI($this->GetDomain());
- }
-*/
return array(
'@Object' => 'Object/Email',
'Name' => \MailSo\Base\Utils::Utf8Clear($this->GetDisplayName()),
'Email' => \MailSo\Base\Utils::Utf8Clear($this->GetEmail(true)),
'DkimStatus' => $this->GetDkimStatus(),
'DkimValue' => $this->GetDkimValue()
-// 'BIMI' => $BIMI
);
}
}