diff --git a/include/api.php b/include/api.php index 579449fc85..651d46f33c 100644 --- a/include/api.php +++ b/include/api.php @@ -34,8 +34,11 @@ function api_register_func($path, $func, $auth=false){ global $API; - $API[$path] = array('func'=>$func, - 'auth'=>$auth); + $API[$path] = array('func'=>$func, 'auth'=>$auth); + + // Workaround for hotot + $path = str_replace("api/", "api/1.1/", $path); + $API[$path] = array('func'=>$func, 'auth'=>$auth); } /** @@ -340,6 +343,7 @@ $ret = array( 'id' => $r[0]["id"], + 'id_str' => (string) $r[0]["id"], 'name' => $r[0]["name"], 'screen_name' => (($r[0]['nick']) ? $r[0]['nick'] : $r[0]['name']), 'location' => NULL, @@ -381,7 +385,7 @@ ); // count public wall messages - $r = q("SELECT COUNT(`id`) as `count` FROM `item` USE INDEX (uid, type) + $r = q("SELECT COUNT(`id`) as `count` FROM `item` WHERE `uid` = %d AND `type`='wall' AND `allow_cid`='' AND `allow_gid`='' AND `deny_cid`='' AND `deny_gid`=''", @@ -448,11 +452,15 @@ $r = q("SELECT id FROM unique_contacts WHERE url='%s' LIMIT 1", dbesc(normalise_link($uinfo[0]['url']))); } + require_once('include/contact_selectors.php'); + $network_name = network_to_name($uinfo[0]['network']); + $ret = Array( 'id' => intval($r[0]['id']), + 'id_str' => (string) intval($r[0]['id']), 'name' => (($uinfo[0]['name']) ? $uinfo[0]['name'] : $uinfo[0]['nick']), 'screen_name' => (($uinfo[0]['nick']) ? $uinfo[0]['nick'] : $uinfo[0]['name']), - 'location' => ($usr) ? $usr[0]['default-location'] : NULL, + 'location' => ($usr) ? $usr[0]['default-location'] : $network_name, 'description' => (($profile) ? $profile[0]['pdesc'] : NULL), 'profile_image_url' => $uinfo[0]['micro'], 'profile_image_url_https' => $uinfo[0]['micro'], @@ -460,13 +468,13 @@ 'protected' => false, 'followers_count' => intval($countfollowers), 'friends_count' => intval($countfriends), - 'created_at' => api_date($uinfo[0]['name-date']), + 'created_at' => api_date($uinfo[0]['created']), 'favourites_count' => intval($starred), - 'utc_offset' => "0", // To-Do - 'time_zone' => 'UTC', // To-Do $uinfo[0]['timezone'], + 'utc_offset' => "0", + 'time_zone' => 'UTC', 'statuses_count' => intval($countitms), - 'following' => true, //#XXX: fix me - 'verified' => true, //#XXX: fix me + 'following' => (($uinfo[0]['rel'] == CONTACT_IS_FOLLOWER) OR ($uinfo[0]['rel'] == CONTACT_IS_FRIEND)), + 'verified' => true, 'statusnet_blocking' => false, 'notifications' => false, 'statusnet_profile_url' => $a->get_baseurl()."/contacts/".$uinfo[0]['cid'], @@ -732,7 +740,8 @@ // get last public wall message $lastwall = q("SELECT `item`.*, `i`.`contact-id` as `reply_uid`, `c`.`nick` as `reply_author`, `i`.`author-link` AS `item-author` FROM `item`, `contact`, `item` as `i`, `contact` as `c` - WHERE `item`.`contact-id` = %d AND `item`.`owner-link` = '%s' + WHERE `item`.`contact-id` = %d + AND ((`item`.`author-link` IN ('%s', '%s')) OR (`item`.`owner-link` IN ('%s', '%s'))) AND `i`.`id` = `item`.`parent` AND `contact`.`id`=`item`.`contact-id` AND `c`.`id`=`i`.`contact-id` AND `contact`.`self`=1 AND `item`.`type`!='activity' @@ -740,7 +749,10 @@ ORDER BY `item`.`created` DESC LIMIT 1", intval($user_info['cid']), - dbesc($user_info['url']) + dbesc($user_info['url']), + dbesc(normalise_link($user_info['url'])), + dbesc($user_info['url']), + dbesc(normalise_link($user_info['url'])) ); if (count($lastwall)>0){ @@ -748,9 +760,12 @@ $in_reply_to_status_id = NULL; $in_reply_to_user_id = NULL; + $in_reply_to_status_id_str = NULL; + $in_reply_to_user_id_str = NULL; $in_reply_to_screen_name = NULL; if ($lastwall['parent']!=$lastwall['id']) { - $in_reply_to_status_id=$lastwall['parent']; + $in_reply_to_status_id= intval($lastwall['parent']); + $in_reply_to_status_id_str = (string) intval($lastwall['parent']); //$in_reply_to_user_id = $lastwall['reply_uid']; //$in_reply_to_screen_name = $lastwall['reply_author']; @@ -760,7 +775,8 @@ $r[0]['nick'] = api_get_nick($r[0]["url"]); $in_reply_to_screen_name = (($r[0]['nick']) ? $r[0]['nick'] : $r[0]['name']); - $in_reply_to_user_id = $r[0]['id']; + $in_reply_to_user_id = intval($r[0]['id']); + $in_reply_to_user_id_str = (string) intval($r[0]['id']); } } @@ -769,9 +785,12 @@ 'truncated' => false, 'created_at' => api_date($lastwall['created']), 'in_reply_to_status_id' => $in_reply_to_status_id, + 'in_reply_to_status_id_str' => $in_reply_to_status_id_str, 'source' => (($lastwall['app']) ? $lastwall['app'] : 'web'), - 'id' => $lastwall['id'], + 'id' => intval($lastwall['id']), + 'id_str' => (string) $lastwall['id'], 'in_reply_to_user_id' => $in_reply_to_user_id, + 'in_reply_to_user_id_str' => $in_reply_to_user_id_str, 'in_reply_to_screen_name' => $in_reply_to_screen_name, 'geo' => NULL, 'favorited' => false, @@ -812,36 +831,43 @@ $lastwall = q("SELECT `item`.* FROM `item`, `contact` - WHERE `item`.`contact-id` = %d AND `item`.`owner-link` = '%s' + WHERE `item`.`contact-id` = %d + AND ((`item`.`author-link` IN ('%s', '%s')) OR (`item`.`owner-link` IN ('%s', '%s'))) AND `contact`.`id`=`item`.`contact-id` AND `type`!='activity' AND `item`.`allow_cid`='' AND `item`.`allow_gid`='' AND `item`.`deny_cid`='' AND `item`.`deny_gid`='' ORDER BY `created` DESC LIMIT 1", intval($user_info['cid']), - dbesc($user_info['url']) + dbesc($user_info['url']), + dbesc(normalise_link($user_info['url'])), + dbesc($user_info['url']), + dbesc(normalise_link($user_info['url'])) ); - +//print_r($user_info); if (count($lastwall)>0){ $lastwall = $lastwall[0]; $in_reply_to_status_id = NULL; $in_reply_to_user_id = NULL; + $in_reply_to_status_id_str = NULL; + $in_reply_to_user_id_str = NULL; $in_reply_to_screen_name = NULL; if ($lastwall['parent']!=$lastwall['id']) { $reply = q("SELECT `item`.`id`, `item`.`contact-id` as `reply_uid`, `contact`.`nick` as `reply_author`, `item`.`author-link` AS `item-author` FROM `item`,`contact` WHERE `contact`.`id`=`item`.`contact-id` AND `item`.`id` = %d", intval($lastwall['parent'])); if (count($reply)>0) { - $in_reply_to_status_id=$lastwall['parent']; - //$in_reply_to_user_id = $reply[0]['reply_uid']; - //$in_reply_to_screen_name = $reply[0]['reply_author']; + $in_reply_to_status_id = intval($lastwall['parent']); + $in_reply_to_status_id_str = (string) intval($lastwall['parent']); + $r = q("SELECT * FROM unique_contacts WHERE `url` = '%s'", dbesc(normalise_link($reply[0]['item-author']))); if ($r) { if ($r[0]['nick'] == "") $r[0]['nick'] = api_get_nick($r[0]["url"]); $in_reply_to_screen_name = (($r[0]['nick']) ? $r[0]['nick'] : $r[0]['name']); - $in_reply_to_user_id = $r[0]['id']; + $in_reply_to_user_id = intval($r[0]['id']); + $in_reply_to_user_id_str = (string) intval($r[0]['id']); } } } @@ -850,9 +876,12 @@ 'truncated' => false, 'created_at' => api_date($lastwall['created']), 'in_reply_to_status_id' => $in_reply_to_status_id, + 'in_reply_to_status_id_str' => $in_reply_to_status_id_str, 'source' => (($lastwall['app']) ? $lastwall['app'] : 'web'), - 'id' => $lastwall['contact-id'], + 'id' => intval($lastwall['contact-id']), + 'id_str' => (string) $lastwall['contact-id'], 'in_reply_to_user_id' => $in_reply_to_user_id, + 'in_reply_to_user_id_str' => $in_reply_to_user_id_str, 'in_reply_to_screen_name' => $in_reply_to_screen_name, 'geo' => NULL, 'favorited' => false, @@ -1050,6 +1079,10 @@ if ($id == 0) $id = intval($_REQUEST["id"]); + // Hotot workaround + if ($id == 0) + $id = intval($a->argv[4]); + logger('API: api_statuses_show: '.$id); //$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false); @@ -1110,6 +1143,10 @@ if ($id == 0) $id = intval($_REQUEST["id"]); + // Hotot workaround + if ($id == 0) + $id = intval($a->argv[4]); + logger('API: api_statuses_repeat: '.$id); //$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false); @@ -1172,6 +1209,10 @@ if ($id == 0) $id = intval($_REQUEST["id"]); + // Hotot workaround + if ($id == 0) + $id = intval($a->argv[4]); + logger('API: api_statuses_destroy: '.$id); $ret = api_statuses_show($a, $type); @@ -1526,12 +1567,15 @@ intval(api_user()), dbesc($item['thr-parent'])); if ($r) - $in_reply_to_status_id = $r[0]['id']; + $in_reply_to_status_id = intval($r[0]['id']); else - $in_reply_to_status_id = $item['parent']; + $in_reply_to_status_id = intval($item['parent']); + + $in_reply_to_status_id_str = (string) intval($item['parent']); $in_reply_to_screen_name = NULL; $in_reply_to_user_id = NULL; + $in_reply_to_user_id_str = NULL; $r = q("SELECT `author-link` FROM item WHERE uid=%d AND id=%d LIMIT 1", intval(api_user()), @@ -1544,13 +1588,16 @@ $r[0]['nick'] = api_get_nick($r[0]["url"]); $in_reply_to_screen_name = (($r[0]['nick']) ? $r[0]['nick'] : $r[0]['name']); - $in_reply_to_user_id = $r[0]['id']; + $in_reply_to_user_id = intval($r[0]['id']); + $in_reply_to_user_id_str = (string) intval($r[0]['id']); } } } else { $in_reply_to_screen_name = NULL; $in_reply_to_user_id = NULL; $in_reply_to_status_id = NULL; + $in_reply_to_user_id_str = NULL; + $in_reply_to_status_id_str = NULL; } // Workaround for ostatus messages where the title is identically to the body @@ -1571,9 +1618,12 @@ 'truncated' => False, 'created_at'=> api_date($item['created']), 'in_reply_to_status_id' => $in_reply_to_status_id, + 'in_reply_to_status_id_str' => $in_reply_to_status_id, 'source' => (($item['app']) ? $item['app'] : 'web'), 'id' => intval($item['id']), + 'id_str' => (string) intval($item['id']), 'in_reply_to_user_id' => $in_reply_to_user_id, + 'in_reply_to_user_id_str' => $in_reply_to_user_id, 'in_reply_to_screen_name' => $in_reply_to_screen_name, 'geo' => NULL, 'favorited' => $item['starred'] ? true : false,