Pass the "force" parameter to the avatar update
This commit is contained in:
parent
e793438e0d
commit
0a43fe857c
|
@ -44,11 +44,12 @@ class Avatar
|
||||||
/**
|
/**
|
||||||
* Returns a field array with locally cached avatar pictures
|
* Returns a field array with locally cached avatar pictures
|
||||||
*
|
*
|
||||||
* @param array $contact
|
* @param array $contact Contact array
|
||||||
* @param string $avatar
|
* @param string $avatar Link to avatar picture
|
||||||
|
* @param bool $force force picture update
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function fetchAvatarContact(array $contact, string $avatar): array
|
public static function fetchAvatarContact(array $contact, string $avatar, bool $force = false): array
|
||||||
{
|
{
|
||||||
$fields = ['avatar' => $avatar, 'avatar-date' => DateTimeFormat::utcNow(), 'photo' => '', 'thumb' => '', 'micro' => ''];
|
$fields = ['avatar' => $avatar, 'avatar-date' => DateTimeFormat::utcNow(), 'photo' => '', 'thumb' => '', 'micro' => ''];
|
||||||
|
|
||||||
|
@ -61,7 +62,7 @@ class Avatar
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($avatar != $contact['avatar']) {
|
if (($avatar != $contact['avatar']) || $force) {
|
||||||
self::deleteCache($contact);
|
self::deleteCache($contact);
|
||||||
Logger::debug('Avatar file name changed', ['new' => $avatar, 'old' => $contact['avatar']]);
|
Logger::debug('Avatar file name changed', ['new' => $avatar, 'old' => $contact['avatar']]);
|
||||||
} elseif (self::isCacheFile($contact['photo']) && self::isCacheFile($contact['thumb']) && self::isCacheFile($contact['micro'])) {
|
} elseif (self::isCacheFile($contact['photo']) && self::isCacheFile($contact['thumb']) && self::isCacheFile($contact['micro'])) {
|
||||||
|
|
|
@ -2049,7 +2049,7 @@ class Contact
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Photo::delete(['uid' => $uid, 'contact-id' => $cid, 'photo-type' => Photo::CONTACT_AVATAR]);
|
Photo::delete(['uid' => $uid, 'contact-id' => $cid, 'photo-type' => Photo::CONTACT_AVATAR]);
|
||||||
$fields = Avatar::fetchAvatarContact($contact, $avatar);
|
$fields = Avatar::fetchAvatarContact($contact, $avatar, $force);
|
||||||
$update = ($avatar . $fields['photo'] . $fields['thumb'] . $fields['micro'] != $contact['avatar'] . $contact['photo'] . $contact['thumb'] . $contact['micro']) || $force;
|
$update = ($avatar . $fields['photo'] . $fields['thumb'] . $fields['micro'] != $contact['avatar'] . $contact['photo'] . $contact['thumb'] . $contact['micro']) || $force;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user