mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 02:55:13 +00:00
refactor icon parse
This commit is contained in:
parent
11ad15d42e
commit
8f358b23ba
2 changed files with 32 additions and 20 deletions
|
@ -2304,24 +2304,8 @@ class Activity
|
|||
$webfinger = $username . '@' . $h['host'];
|
||||
}
|
||||
|
||||
if ($person_obj['icon']) {
|
||||
if (is_array($person_obj['icon'])) {
|
||||
if (array_key_exists('url', $person_obj['icon'])) {
|
||||
$icon = $person_obj['icon']['url'];
|
||||
} else {
|
||||
if (is_string($person_obj['icon'][0])) {
|
||||
$icon = $person_obj['icon'][0];
|
||||
} elseif (array_key_exists('url', $person_obj['icon'][0])) {
|
||||
$icon = $person_obj['icon'][0]['url'];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$icon = $person_obj['icon'];
|
||||
}
|
||||
}
|
||||
if (!(isset($icon) && $icon)) {
|
||||
$icon = z_root() . '/' . Channel::get_default_profile_photo();
|
||||
}
|
||||
$icon = self::getIcon($person_obj['icon']);
|
||||
|
||||
|
||||
$cover_photo = false;
|
||||
|
||||
|
@ -2674,6 +2658,35 @@ class Activity
|
|||
}
|
||||
}
|
||||
|
||||
public static function getIcon($element)
|
||||
{
|
||||
$icon = null;
|
||||
if (isset($element)) {
|
||||
if (is_string($element)) {
|
||||
$icon = $element;
|
||||
}
|
||||
if (is_array($element)) {
|
||||
if (!array_key_exists(0, $element)) {
|
||||
$element = [$element];
|
||||
}
|
||||
foreach ($element as $asobject) {
|
||||
if (is_string($asobject)) {
|
||||
$icon = $asobject;
|
||||
break;
|
||||
}
|
||||
if (!empty($asobject['url']) && is_string($asobject['url'])) {
|
||||
$icon = $asobject['url'];
|
||||
break;
|
||||
}
|
||||
if (!empty($asobject['href']) && is_string($asobject['href'])) {
|
||||
$icon = $asobject['href'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $icon;
|
||||
}
|
||||
|
||||
public static function drop($channel, $observer, $act)
|
||||
{
|
||||
|
|
|
@ -48,7 +48,6 @@ class Dav extends Controller
|
|||
$_SERVER['PHP_AUTH_USER'] = $name;
|
||||
$_SERVER['PHP_AUTH_PW'] = $password;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* Signature authentication */
|
||||
|
|
Loading…
Reference in a new issue