api: item owner and activities details
return new fileld for items 'friendica_owner'. 'user' is always the author of the item. Items activitites now returns array of contacts details: {'name','url'}
This commit is contained in:
parent
95b7de6313
commit
3cd2ed54eb
1 changed files with 34 additions and 13 deletions
|
@ -664,18 +664,20 @@
|
||||||
|
|
||||||
// Comments in threads may appear as wall-to-wall postings.
|
// Comments in threads may appear as wall-to-wall postings.
|
||||||
// So only take the owner at the top posting.
|
// So only take the owner at the top posting.
|
||||||
if ($item["id"] == $item["parent"])
|
#if ($item["id"] == $item["parent"])
|
||||||
$status_user = api_get_user($a,$item["owner-link"]);
|
# $status_user = api_get_user($a,$item["owner-link"]);
|
||||||
else
|
#else
|
||||||
$status_user = api_get_user($a,$item["author-link"]);
|
|
||||||
|
|
||||||
|
$status_user = api_get_user($a,$item["author-link"]);
|
||||||
$status_user["protected"] = (($item["allow_cid"] != "") OR
|
$status_user["protected"] = (($item["allow_cid"] != "") OR
|
||||||
($item["allow_gid"] != "") OR
|
($item["allow_gid"] != "") OR
|
||||||
($item["deny_cid"] != "") OR
|
($item["deny_cid"] != "") OR
|
||||||
($item["deny_gid"] != "") OR
|
($item["deny_gid"] != "") OR
|
||||||
$item["private"]);
|
$item["private"]);
|
||||||
|
|
||||||
return ($status_user);
|
$owner_user = api_get_user($a,$item["owner-link"]);
|
||||||
|
|
||||||
|
return (array($status_user, $owner_user));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2278,6 +2280,24 @@
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief return <a href='url'>name</a> as array
|
||||||
|
*
|
||||||
|
* @param string $txt
|
||||||
|
* @return array
|
||||||
|
* name => 'name'
|
||||||
|
* 'url => 'url'
|
||||||
|
*/
|
||||||
|
function api_contactlink_to_array($txt) {
|
||||||
|
$elm = new SimpleXMLElement($txt);
|
||||||
|
return array(
|
||||||
|
'name' => $elm->__toString(),
|
||||||
|
'url' => $elm->attributes()['href']->__toString()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief return likes, dislikes and attend status for item
|
* @brief return likes, dislikes and attend status for item
|
||||||
*
|
*
|
||||||
|
@ -2286,7 +2306,7 @@
|
||||||
* likes => int count
|
* likes => int count
|
||||||
* dislikes => int count
|
* dislikes => int count
|
||||||
*/
|
*/
|
||||||
function api_format_items_likes(&$item) {
|
function api_format_items_activities(&$item) {
|
||||||
$activities = array(
|
$activities = array(
|
||||||
'like' => array(),
|
'like' => array(),
|
||||||
'dislike' => array(),
|
'dislike' => array(),
|
||||||
|
@ -2303,9 +2323,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = array();
|
$res = array();
|
||||||
$uri = $item['uri'];
|
$uri = $item['uri']."-l";
|
||||||
foreach($activities as $k => $v) {
|
foreach($activities as $k => $v) {
|
||||||
$res[$k] = (x($v,$uri)?$v[$uri]:0);
|
$res[$k] = ( x($v,$uri) ? array_map("api_contactlink_to_array", $v[$uri]) : array() );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
|
@ -2327,7 +2347,7 @@
|
||||||
api_share_as_retweet($item);
|
api_share_as_retweet($item);
|
||||||
|
|
||||||
localize_item($item);
|
localize_item($item);
|
||||||
$status_user = api_item_get_user($a,$item);
|
list($status_user, $owner_user) = api_item_get_user($a,$item);
|
||||||
|
|
||||||
// Look if the posts are matching if they should be filtered by user id
|
// Look if the posts are matching if they should be filtered by user id
|
||||||
if ($filter_user AND ($status_user["id"] != $user_info["id"]))
|
if ($filter_user AND ($status_user["id"] != $user_info["id"]))
|
||||||
|
@ -2388,10 +2408,11 @@
|
||||||
'geo' => NULL,
|
'geo' => NULL,
|
||||||
'favorited' => $item['starred'] ? true : false,
|
'favorited' => $item['starred'] ? true : false,
|
||||||
'user' => $status_user ,
|
'user' => $status_user ,
|
||||||
|
'friendica_owner' => $owner_user,
|
||||||
//'entities' => NULL,
|
//'entities' => NULL,
|
||||||
'statusnet_html' => $converted["html"],
|
'statusnet_html' => $converted["html"],
|
||||||
'statusnet_conversation_id' => $item['parent'],
|
'statusnet_conversation_id' => $item['parent'],
|
||||||
'friendica_activities' => api_format_items_likes($item),
|
'friendica_activities' => api_format_items_activities($item),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (count($converted["attachments"]) > 0)
|
if (count($converted["attachments"]) > 0)
|
||||||
|
|
Loading…
Reference in a new issue