mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-23 16:33:17 +01:00
WIP improve avatar loading in mail app
currently ET2Avatar is NOT correctly handling contactId=email:<email>
This commit is contained in:
parent
2c4c99d00d
commit
83dd2d9ac1
@ -158,15 +158,18 @@ export class Et2Avatar extends Et2Widget(SlotMixin(SlAvatar)) implements et2_IDe
|
||||
return this._contactId;
|
||||
}
|
||||
|
||||
static RFC822EMAIL = /<([^<>]+)>$/;
|
||||
|
||||
/**
|
||||
* Function to set contactId
|
||||
* contactId could be in one of these formats:
|
||||
* 'number', will be consider as contact_id
|
||||
* 'number', will be considered as contact_id
|
||||
* 'contact:number', similar to above
|
||||
* 'account:number', will be consider as account id
|
||||
* 'account:number', will be considered as account id
|
||||
* 'email:<email>', will be considered as email address
|
||||
* @example: contactId = "account:4"
|
||||
*
|
||||
* @param {string} _contactId contact id could be as above mentioned formats
|
||||
* @param {string} _contactId contact id could be as above-mentioned formats
|
||||
*/
|
||||
set contactId(_contactId : string)
|
||||
{
|
||||
@ -177,10 +180,16 @@ export class Et2Avatar extends Et2Widget(SlotMixin(SlAvatar)) implements et2_IDe
|
||||
{
|
||||
_contactId = this.egw().user('account_id');
|
||||
}
|
||||
else if(_contactId.match(/account:/))
|
||||
else if(_contactId.substr(0, 8) === 'account:')
|
||||
{
|
||||
id = 'account_id';
|
||||
_contactId = _contactId.replace('account:','');
|
||||
_contactId = _contactId.substr(8);
|
||||
}
|
||||
else if(_contactId.substr(0, 6) === 'email:')
|
||||
{
|
||||
id = 'email';
|
||||
const matches = Et2Avatar.RFC822EMAIL.exec(_contactId);
|
||||
_contactId = matches ? matches[1] : _contactId.substr(6);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2745,7 +2745,7 @@ class Contacts extends Contacts\Storage
|
||||
ob_start();
|
||||
|
||||
$contact_id = isset($_GET['contact_id']) ? $_GET['contact_id'] :
|
||||
(isset($_GET['account_id']) ? 'account:'.$_GET['account_id'] : 0);
|
||||
(isset($_GET['account_id']) ? 'account:'.$_GET['account_id'] : null);
|
||||
|
||||
if (substr($contact_id,0,8) == 'account:')
|
||||
{
|
||||
@ -2753,11 +2753,29 @@ class Contacts extends Contacts\Storage
|
||||
$contact_id = $GLOBALS['egw']->accounts->id2name(substr($contact_id, 8), 'person_id');
|
||||
}
|
||||
|
||||
if (!$contact_id && !empty($_GET['email']))
|
||||
{
|
||||
$email = strtolower(current(Mail::stripRFC822Addresses([$_GET['email']])));
|
||||
|
||||
if (!($contact = current($this->search(['contact_email' => $email, 'contact_email_home' => $email],
|
||||
['contact_id', 'email', 'email_home', 'n_fn', 'n_given', 'n_family', 'contact_files', 'etag'],
|
||||
'contact_files & '.self::FILES_BIT_PHOTO.' DESC', '', '', false, 'OR', [0, 1]) ?: [])) ||
|
||||
!self::hasPhoto($contact))
|
||||
{
|
||||
Session::cache_control(86400); // cache for 1 day
|
||||
header('Content-type: image/jpeg');
|
||||
http_response_code(404);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$contact = $this->read($contact_id);
|
||||
}
|
||||
|
||||
if (!$contact || !self::hasPhoto($contact, $url, $size))
|
||||
{
|
||||
if(!$contact_id && $id < 0)
|
||||
if(!$contact_id && isset($id) && $id < 0)
|
||||
{
|
||||
$group = $GLOBALS['egw']->accounts->read($id);
|
||||
$contact = array(
|
||||
@ -2777,7 +2795,7 @@ class Contacts extends Contacts\Storage
|
||||
}
|
||||
|
||||
// use an etag over the image mapp
|
||||
$etag = '"'.$contact_id.':'.$contact['etag'].'"';
|
||||
$etag = '"'.$contact['id'].':'.$contact['etag'].'"';
|
||||
if (!ob_get_contents())
|
||||
{
|
||||
header('Content-type: image/jpeg');
|
||||
@ -2788,6 +2806,10 @@ class Contacts extends Contacts\Storage
|
||||
{
|
||||
Session::cache_control(30*86400); // cache for 30 days
|
||||
}
|
||||
else
|
||||
{
|
||||
Session::cache_control(7*86400); // cache for 7 days
|
||||
}
|
||||
// if servers send a If-None-Match header, response with 304 Not Modified, if etag matches
|
||||
if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] === $etag)
|
||||
{
|
||||
|
@ -41,7 +41,7 @@ class Avatar
|
||||
static function($email, $address)
|
||||
{
|
||||
if (($contacts = $GLOBALS['egw']->contacts->search(['contact_email' => $email, 'contact_email_home' => $email],
|
||||
['contact_id', 'email', 'email_home', 'n_fn', 'n_given', 'n_family'], '', '', '', false, 'OR', false)))
|
||||
['contact_id', 'email', 'email_home', 'n_fn', 'n_given', 'n_family'], '', '', '', false, 'OR', [0,1])))
|
||||
{
|
||||
return [$contacts[0]['photo'], ['lname' => $contacts[0]['n_family'], 'fname' => $contacts[0]['n_given']]];
|
||||
}
|
||||
|
@ -2131,17 +2131,9 @@ $filter['before']= date("d-M-Y", $cutoffdate2);
|
||||
if ($header['disposition-notification-to']) $data['dispositionnotificationto'] = $header['disposition-notification-to'];
|
||||
if (($header['mdnsent']||$header['mdnnotsent']|$header['seen'])&&isset($data['dispositionnotificationto'])) unset($data['dispositionnotificationto']);
|
||||
$data['attachmentsBlock'] = $imageHTMLBlock;
|
||||
if ($_folderType)
|
||||
{
|
||||
$data['fromavatar'] = Api\Mail\Avatar::getAvatar($data['fromaddress']);
|
||||
}
|
||||
$data['address'] = $_folderType ? $data["toaddress"] : $data["fromaddress"];
|
||||
$data['lavatar'] = Api\Mail\Avatar::getLavatar($data['address']);
|
||||
|
||||
if (($data['avatar'] = Api\Mail\Avatar::getAvatar($data['address'], $data['lavatar'])) && !$_folderType)
|
||||
{
|
||||
$data['fromavatar'] = $data['avatar'];
|
||||
}
|
||||
$data['fromlavatar'] = $_folderType ? Api\Mail\Avatar::getLavatar($data['fromaddress']) : $data['lavatar'];
|
||||
|
||||
if (in_array("bodypreview", $cols) && $header['bodypreview'])
|
||||
{
|
||||
|
@ -31,7 +31,7 @@
|
||||
<nextmatch-header statustext="security" label="Security" id="security"/>
|
||||
</row>
|
||||
<row class="$row_cont[class]">
|
||||
<et2-lavatar image="$row_cont[avatar]" fname="$row_cont[lavatar][fname]"
|
||||
<et2-lavatar contactId="email:$row_cont[address]" fname="$row_cont[lavatar][fname]"
|
||||
lname="$row_cont[lavatar][lname]" size="2.75em" shape="rounded"></et2-lavatar>
|
||||
<et2-description span="1" class="status_img"></et2-description>
|
||||
<html id="${row}[attachments]"/>
|
||||
|
@ -14,12 +14,11 @@
|
||||
</row>
|
||||
<row class="$row_cont[class]">
|
||||
<et2-hbox class="$row_cont[class] mobile_cat_col">
|
||||
<et2-lavatar image="$row_cont[avatar]" fname="$row_cont[lavatar][fname]"
|
||||
<et2-lavatar contactId="email:$row_cont[address]" fname="$row_cont[lavatar][fname]"
|
||||
lname="$row_cont[lavatar][lname]" size="2.75em" shape="rounded"></et2-lavatar>
|
||||
<et2-vbox>
|
||||
<et2-url-email id="${row}[address]" class="$row_cont[class]" readonly="true"></et2-url-email>
|
||||
<et2-hbox>
|
||||
|
||||
<et2-description id="${row}[subject]" class="$row_cont[class]" noLang="1"></et2-description>
|
||||
</et2-hbox>
|
||||
<et2-description id="${row}[bodypreview]" class="et2_label bodypreview" noLang="1"></et2-description>
|
||||
|
@ -25,7 +25,7 @@
|
||||
</et2-hbox>
|
||||
</et2-hbox>
|
||||
<et2-hbox width="100%" class="mailPreviewHeaders">
|
||||
<et2-lavatar src="@fromavatar" lname="@fromaddress" shape="rounded" size="2.75em"></et2-lavatar>
|
||||
<et2-lavatar contactId="email:$cont[fromaddress]" lname="$cont[fromlavatar][lname]" fname="$cont[fromlavatar][fname]" shape="rounded" size="2.75em"></et2-lavatar>
|
||||
<et2-vbox>
|
||||
<et2-vbox class="addresses">
|
||||
<et2-hbox>
|
||||
|
Loading…
Reference in New Issue
Block a user