Added description to Avatars extension

This commit is contained in:
the-djmaze 2022-11-23 11:35:34 +01:00
parent b7fd933499
commit 2053749b54
2 changed files with 11 additions and 3 deletions

View file

@ -7,7 +7,7 @@
getAvatarUid = msg => { getAvatarUid = msg => {
let from = msg.from[0], let from = msg.from[0],
bimi = 'pass' == from.dkimStatus ? 1 : 0; bimi = 'pass' == from.dkimStatus ? 1 : 0;
return `${bimi}/${from.email}`; return `${bimi}/${from.email.toLowerCase()}`;
}, },
getAvatar = msg => avatars.get(getAvatarUid(msg)), getAvatar = msg => avatars.get(getAvatarUid(msg)),
runQueue = (() => { runQueue = (() => {

View file

@ -7,11 +7,11 @@ class AvatarsPlugin extends \RainLoop\Plugins\AbstractPlugin
AUTHOR = 'SnappyMail', AUTHOR = 'SnappyMail',
URL = 'https://snappymail.eu/', URL = 'https://snappymail.eu/',
VERSION = '1.0', VERSION = '1.0',
RELEASE = '2022-11-11', RELEASE = '2022-11-23',
REQUIRED = '2.22.0', REQUIRED = '2.22.0',
CATEGORY = 'Contacts', CATEGORY = 'Contacts',
LICENSE = 'MIT', LICENSE = 'MIT',
DESCRIPTION = ''; DESCRIPTION = 'Show photo of sender in message and messages list (supports BIMI and Gravatar, Contacts is still TODO)';
public function Init() : void public function Init() : void
{ {
@ -21,6 +21,9 @@ class AvatarsPlugin extends \RainLoop\Plugins\AbstractPlugin
$this->addPartHook('Avatar', 'ServiceAvatar'); $this->addPartHook('Avatar', 'ServiceAvatar');
} }
/**
* POST method handling
*/
public function DoAvatar() : array public function DoAvatar() : array
{ {
$bBimi = !empty($this->jsonParam('bimi')); $bBimi = !empty($this->jsonParam('bimi'));
@ -35,6 +38,11 @@ class AvatarsPlugin extends \RainLoop\Plugins\AbstractPlugin
return $this->jsonResponse(__FUNCTION__, $aResult); return $this->jsonResponse(__FUNCTION__, $aResult);
} }
/**
* GET /?Avatar/${bimi}/${from.email}
* Not fond of this idea because email address is exposed
* Maybe use btoa(from.email) or Crypto.subtle.encrypt({name:'AES-GCM',iv:''}, token, from.email)
*/
// public function ServiceAvatar(...$aParts) // public function ServiceAvatar(...$aParts)
public function ServiceAvatar(string $sServiceName, string $sBimi, string $sEmail) public function ServiceAvatar(string $sServiceName, string $sBimi, string $sEmail)
{ {