mirror of
https://github.com/friendica/friendica
synced 2025-04-27 15:10:11 +00:00
Just some more fixes to the protocol and the avatar stuff
This commit is contained in:
parent
ee817e81a2
commit
eb0a701590
3 changed files with 46 additions and 87 deletions
|
@ -29,42 +29,6 @@ class ostatus {
|
|||
const OSTATUS_DEFAULT_POLL_TIMEFRAME = 1440; // given in minutes
|
||||
const OSTATUS_DEFAULT_POLL_TIMEFRAME_MENTIONS = 14400; // given in minutes
|
||||
|
||||
/**
|
||||
* @brief Mix two paths together to possibly fix missing parts
|
||||
*
|
||||
* @param string $avatar Path to the avatar
|
||||
* @param string $base Another path that is hopefully complete
|
||||
*
|
||||
* @return string fixed avatar path
|
||||
*/
|
||||
public static function fix_avatar($avatar, $base) {
|
||||
$base_parts = parse_url($base);
|
||||
|
||||
// Remove all parts that could create a problem
|
||||
unset($base_parts['path']);
|
||||
unset($base_parts['query']);
|
||||
unset($base_parts['fragment']);
|
||||
|
||||
$avatar_parts = parse_url($avatar);
|
||||
|
||||
// Now we mix them
|
||||
$parts = array_merge($base_parts, $avatar_parts);
|
||||
|
||||
// And put them together again
|
||||
$scheme = isset($parts['scheme']) ? $parts['scheme'] . '://' : '';
|
||||
$host = isset($parts['host']) ? $parts['host'] : '';
|
||||
$port = isset($parts['port']) ? ':' . $parts['port'] : '';
|
||||
$path = isset($parts['path']) ? $parts['path'] : '';
|
||||
$query = isset($parts['query']) ? '?' . $parts['query'] : '';
|
||||
$fragment = isset($parts['fragment']) ? '#' . $parts['fragment'] : '';
|
||||
|
||||
$fixed = $scheme.$host.$port.$path.$query.$fragment;
|
||||
|
||||
logger('Base: '.$base.' - Avatar: '.$avatar.' - Fixed: '.$fixed, LOGGER_DATA);
|
||||
|
||||
return $fixed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Fetches author data
|
||||
*
|
||||
|
@ -135,7 +99,7 @@ class ostatus {
|
|||
}
|
||||
if (count($avatarlist) > 0) {
|
||||
krsort($avatarlist);
|
||||
$author["author-avatar"] = self::fix_avatar(current($avatarlist), $author["author-link"]);
|
||||
$author["author-avatar"] = Probe::fix_avatar(current($avatarlist), $author["author-link"]);
|
||||
}
|
||||
|
||||
$displayname = $xpath->evaluate('atom:author/poco:displayName/text()', $context)->item(0)->nodeValue;
|
||||
|
@ -1196,7 +1160,7 @@ class ostatus {
|
|||
$arr["owner-name"] = $single_conv->actor->portablecontacts_net->displayName;
|
||||
|
||||
$arr["owner-link"] = $actor;
|
||||
$arr["owner-avatar"] = self::fix_avatar($single_conv->actor->image->url, $arr["owner-link"]);
|
||||
$arr["owner-avatar"] = Probe::fix_avatar($single_conv->actor->image->url, $arr["owner-link"]);
|
||||
|
||||
$arr["author-name"] = $arr["owner-name"];
|
||||
$arr["author-link"] = $arr["owner-link"];
|
||||
|
@ -1261,7 +1225,7 @@ class ostatus {
|
|||
$arr["author-name"] = $single_conv->object->actor->contact->displayName;
|
||||
}
|
||||
$arr["author-link"] = $single_conv->object->actor->url;
|
||||
$arr["author-avatar"] = self::fix_avatar($single_conv->object->actor->image->url, $arr["author-link"]);
|
||||
$arr["author-avatar"] = Probe::fix_avatar($single_conv->object->actor->image->url, $arr["author-link"]);
|
||||
|
||||
$arr["app"] = $single_conv->object->provider->displayName."#";
|
||||
//$arr["verb"] = $single_conv->object->verb;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue