Fix exceptions with bad gravatar URLs

This commit is contained in:
Evan Prodromou 2010-04-21 18:19:16 -07:00
parent e28214bfe9
commit a129c455a2

View File

@ -1001,7 +1001,7 @@ class Ostatus_profile extends Memcached_DataObject
return; return;
} }
if (!common_valid_http_url($url)) { if (!common_valid_http_url($url)) {
throw new ServerException(_m("Invalid avatar URL %s"), $url); throw new ServerException(sprintf(_m("Invalid avatar URL %s"), $url));
} }
if ($this->isGroup()) { if ($this->isGroup()) {
@ -1303,15 +1303,23 @@ class Ostatus_profile extends Memcached_DataObject
$ok = $oprofile->insert(); $ok = $oprofile->insert();
if ($ok) { if (!$ok) {
$avatar = self::getActivityObjectAvatar($object, $hints);
if ($avatar) {
$oprofile->updateAvatar($avatar);
}
return $oprofile;
} else {
throw new ServerException("Can't save OStatus profile"); throw new ServerException("Can't save OStatus profile");
} }
$avatar = self::getActivityObjectAvatar($object, $hints);
if ($avatar) {
try {
$oprofile->updateAvatar($avatar);
} catch (Exception $ex) {
// Profile is saved, but Avatar is messed up. We're
// just going to continue.
common_log(LOG_WARNING, "Exception saving OStatus profile avatar: ". $ex->getMessage());
}
}
return $oprofile;
} }
/** /**
@ -1330,7 +1338,11 @@ class Ostatus_profile extends Memcached_DataObject
} }
$avatar = self::getActivityObjectAvatar($object, $hints); $avatar = self::getActivityObjectAvatar($object, $hints);
if ($avatar) { if ($avatar) {
$this->updateAvatar($avatar); try {
$this->updateAvatar($avatar);
} catch (Exception $ex) {
common_log(LOG_WARNING, "Exception saving OStatus profile avatar: " . $ex->getMessage());
}
} }
} }