API: add private value (bool) to item results (#5647)

* API: add private value (bool) to item results

friendica:private for xml
friendica_privarte for json

* API Docs: add a section about custom value returned in status data
This commit is contained in:
fabrixxm 2018-08-23 16:09:50 +02:00 committed by Hypolite Petovan
parent dc3d2d5988
commit 93ba393559
2 changed files with 68 additions and 0 deletions

View file

@ -634,6 +634,73 @@ Friendica doesn't allow showing the friends of other users.
* trim_user * trim_user
* contributor_details * contributor_details
---
### Return values for statuses/* api calls
Returned status object is conform to GNU Social/Twitter api.
Friendica adds some addictional fields:
- owner: a user object, it's the owner of the item.
- private: boolean, true if the item is marked as private
- activities: map with activities related to the item. Every activity is a list of user objects.
This properties are prefixed with "friendica_" in JSON responses and namespaced under "http://friendi.ca/schema/api/1/" in XML responses
JSON:
```json
[
{
// ...
'friendica_owner' : {
// user object
},
'friendica_private' : true,
'friendica_activities': {
'like': [
{
// user object
},
// ...
],
'dislike': [],
'attendyes': [],
'attendno': [],
'attendmaybe': []
}
},
// ...
]
```
XML:
```xml
<statuses xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" xmlns:friendica="http://friendi.ca/schema/api/1/" xmlns:georss="http://www.georss.org/georss">
<status>
<!-- ... -->
<friendica:owner><!-- user object --></friendica:owner>
<friendica:private>true</friendica:private>
<friendica:activities>
<friendica:like>
<user>
<!-- user object -->
</user>
<!-- ... --->
</friendica:like>
<friendica:dislike/>
<friendica:attendyes/>
<friendica:attendno/>
<friendica:attendmaybe/>
</friendica:activities>
</status>
<!-- ... -->
</statuses>
```
--- ---
### statusnet/config (*) ### statusnet/config (*)

View file

@ -2888,6 +2888,7 @@ function api_format_items($r, $user_info, $filter_user = false, $type = "json")
'favorited' => $item['starred'] ? true : false, 'favorited' => $item['starred'] ? true : false,
'user' => $status_user , 'user' => $status_user ,
'friendica_owner' => $owner_user, 'friendica_owner' => $owner_user,
'friendica_private' => $item['private'] == 1,
//'entities' => NULL, //'entities' => NULL,
'statusnet_html' => $converted["html"], 'statusnet_html' => $converted["html"],
'statusnet_conversation_id' => $item['parent'], 'statusnet_conversation_id' => $item['parent'],