Merge pull request #4122 from Rudloff/feature/cleanup_api

Various fixes in api.php
This commit is contained in:
Hypolite Petovan 2017-12-22 20:04:07 -05:00 committed by GitHub
commit 1fd62ee626
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -399,7 +399,7 @@ function api_call(App $a)
* *
* @param string $type Return type (xml, json, rss, as) * @param string $type Return type (xml, json, rss, as)
* @param object $e HTTPException Error object * @param object $e HTTPException Error object
* @return strin error message formatted as $type * @return string error message formatted as $type
*/ */
function api_error($type, $e) function api_error($type, $e)
{ {
@ -946,12 +946,10 @@ function api_create_xml($data, $root_element)
* @param string $type Return type (atom, rss, xml, json) * @param string $type Return type (atom, rss, xml, json)
* @param array $data JSON style array * @param array $data JSON style array
* *
* @return (string|object) XML data or JSON data * @return (string|object|array) XML data or JSON data
*/ */
function api_format_data($root_element, $type, $data) function api_format_data($root_element, $type, $data)
{ {
$a = get_app();
switch ($type) { switch ($type) {
case "atom": case "atom":
case "rss": case "rss":
@ -1496,7 +1494,7 @@ function api_users_search($type)
if (DBM::is_result($r)) { if (DBM::is_result($r)) {
$k = 0; $k = 0;
foreach ($r as $user) { foreach ($r as $user) {
$user_info = api_get_user($a, $user["id"], "json"); $user_info = api_get_user($a, $user["id"]);
if ($type == "xml") { if ($type == "xml") {
$userlist[$k++.":user"] = $user_info; $userlist[$k++.":user"] = $user_info;
@ -3167,10 +3165,10 @@ function api_statuses_f($qtype)
return false; return false;
} }
$sql_extra = '';
if ($qtype == 'friends') { if ($qtype == 'friends') {
$sql_extra = sprintf(" AND ( `rel` = %d OR `rel` = %d ) ", intval(CONTACT_IS_SHARING), intval(CONTACT_IS_FRIEND)); $sql_extra = sprintf(" AND ( `rel` = %d OR `rel` = %d ) ", intval(CONTACT_IS_SHARING), intval(CONTACT_IS_FRIEND));
} } elseif ($qtype == 'followers') {
if ($qtype == 'followers') {
$sql_extra = sprintf(" AND ( `rel` = %d OR `rel` = %d ) ", intval(CONTACT_IS_FOLLOWER), intval(CONTACT_IS_FRIEND)); $sql_extra = sprintf(" AND ( `rel` = %d OR `rel` = %d ) ", intval(CONTACT_IS_FOLLOWER), intval(CONTACT_IS_FRIEND));
} }
@ -3315,7 +3313,7 @@ function api_statusnet_config($type)
$private = ((Config::get('system', 'block_public')) ? 'true' : 'false'); $private = ((Config::get('system', 'block_public')) ? 'true' : 'false');
$textlimit = (string) (($a->config['max_import_size']) ? $a->config['max_import_size'] : 200000); $textlimit = (string) (($a->config['max_import_size']) ? $a->config['max_import_size'] : 200000);
if ($a->config['api_import_size']) { if ($a->config['api_import_size']) {
$texlimit = string($a->config['api_import_size']); $textlimit = (string) $a->config['api_import_size'];
} }
$ssl = ((Config::get('system', 'have_ssl')) ? 'true' : 'false'); $ssl = ((Config::get('system', 'have_ssl')) ? 'true' : 'false');
$sslserver = (($ssl === 'true') ? str_replace('http:', 'https:', System::baseUrl()) : ''); $sslserver = (($ssl === 'true') ? str_replace('http:', 'https:', System::baseUrl()) : '');
@ -3367,17 +3365,6 @@ function api_ff_ids($type,$qtype)
$user_info = api_get_user($a); $user_info = api_get_user($a);
if ($qtype == 'friends') {
$sql_extra = sprintf(" AND ( `rel` = %d OR `rel` = %d ) ", intval(CONTACT_IS_SHARING), intval(CONTACT_IS_FRIEND));
}
if ($qtype == 'followers') {
$sql_extra = sprintf(" AND ( `rel` = %d OR `rel` = %d ) ", intval(CONTACT_IS_FOLLOWER), intval(CONTACT_IS_FRIEND));
}
if (!$user_info["self"]) {
$sql_extra = " AND false ";
}
$stringify_ids = (x($_REQUEST, 'stringify_ids') ? $_REQUEST['stringify_ids'] : false); $stringify_ids = (x($_REQUEST, 'stringify_ids') ? $_REQUEST['stringify_ids'] : false);
$r = q( $r = q(
@ -4605,7 +4592,7 @@ api_register_func('api/friendica/remoteauth', 'api_friendica_remoteauth', true);
* @brief Return the item shared, if the item contains only the [share] tag * @brief Return the item shared, if the item contains only the [share] tag
* *
* @param array $item Sharer item * @param array $item Sharer item
* @return array Shared item or false if not a reshare * @return array|false Shared item or false if not a reshare
*/ */
function api_share_as_retweet(&$item) function api_share_as_retweet(&$item)
{ {