Avoid local network requests

This commit is contained in:
Michael 2020-08-19 04:11:20 +00:00
parent 5c3d077dfb
commit 29494ea721

View file

@ -1576,6 +1576,19 @@ class Contact
return;
}
// Replace cached avatar pictures from the default avatar with the default avatars in different sizes
if (strpos($avatar, self::DEFAULT_AVATAR_PHOTO)) {
$fields = ['avatar' => $avatar, 'avatar-date' => DateTimeFormat::utcNow(),
'photo' => DI::baseUrl() . self::DEFAULT_AVATAR_PHOTO,
'thumb' => DI::baseUrl() . self::DEFAULT_AVATAR_THUMB,
'micro' => DI::baseUrl() . self::DEFAULT_AVATAR_MICRO];
if ($fields['photo'] . $fields['thumb'] . $fields['micro'] != $contact['photo'] . $contact['thumb'] . $contact['micro']) {
DBA::update('contact', $fields, ['id' => $cid]);
Photo::delete(['uid' => $uid, 'contact-id' => $cid, 'album' => Photo::CONTACT_PHOTOS]);
}
return;
}
$data = [
$contact['photo'] ?? '',
$contact['thumb'] ?? '',
@ -1584,16 +1597,6 @@ class Contact
$update = ($contact['avatar'] != $avatar) || $force;
if (strpos($avatar, self::DEFAULT_AVATAR_PHOTO)) {
$fields = ['avatar' => $avatar, 'avatar-date' => DateTimeFormat::utcNow(),
'photo' => DI::baseUrl() . self::DEFAULT_AVATAR_PHOTO,
'thumb' => DI::baseUrl() . self::DEFAULT_AVATAR_THUMB,
'micro' => DI::baseUrl() . self::DEFAULT_AVATAR_MICRO];
DBA::update('contact', $fields, ['id' => $cid]);
Photo::delete(['uid' => $uid, 'contact-id' => $cid, 'album' => Photo::CONTACT_PHOTOS]);
return;
}
if (!$update) {
foreach ($data as $image_uri) {
$image_rid = Photo::ridFromURI($image_uri);