We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit cf46de6c authored by mattl's avatar mattl

Ostatus_profile smarter test if avatar exists

If you accidentally deleted a remote user's avatar from filesystem,
it'd take until its URL was updated that you got it back. Now it
happens if the local avatar file doesn't exist.
parent 697a00d8
......@@ -1231,14 +1231,22 @@ class Ostatus_profile extends Managed_DataObject
* Download and update given avatar image
* @param string $url
* @return Avatar The Avatar we have on disk. (seldom used)
* @throws Exception in various failure cases
public function updateAvatar($url, $force)
if ($url == $this->avatar && !$force) {
// We've already got this one.
try {
// If avatar URL differs: update. If URLs were identical but we're forced: update.
if ($url == $this->avatar && !$force) {
// If there's no locally stored avatar, throw an exception and continue fetching below.
$avatar = Avatar::getUploaded($this->localProfile()) instanceof Avatar;
return $avatar;
} catch (NoAvatarException $e) {
// No avatar available, let's fetch it.
if (!common_valid_http_url($url)) {
// TRANS: Server exception. %s is a URL.
throw new ServerException(sprintf(_m('Invalid avatar URL %s.'), $url));
......@@ -1301,6 +1309,8 @@ class Ostatus_profile extends Managed_DataObject
$orig = clone($this);
$this->avatar = $url;
return Avatar::getUploaded($self);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment