API: Beautifying the code, only showing posts (not likes), don't show own posts in mentions.
This commit is contained in:
parent
b64ddcce96
commit
22772876a9
2 changed files with 91 additions and 129 deletions
|
@ -436,9 +436,6 @@
|
|||
// Add a nick if it isn't present there
|
||||
if (($uinfo[0]['nick'] == "") OR ($uinfo[0]['name'] == $uinfo[0]['nick'])) {
|
||||
$uinfo[0]['nick'] = api_get_nick($uinfo[0]["url"]);
|
||||
//if ($uinfo[0]['nick'] != "")
|
||||
// q("UPDATE contact SET nick = '%s' WHERE id = %d",
|
||||
// dbesc($uinfo[0]['nick']), intval($uinfo[0]["id"]));
|
||||
}
|
||||
|
||||
// Fetching unique id
|
||||
|
@ -746,22 +743,6 @@
|
|||
logger('api_status_show: user_info: '.print_r($user_info, true), LOGGER_DEBUG);
|
||||
|
||||
// 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`.`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'
|
||||
// AND `item`.`allow_cid`='' AND `item`.`allow_gid`='' AND `item`.`deny_cid`='' AND `item`.`deny_gid`=''
|
||||
// ORDER BY `item`.`created` DESC
|
||||
// LIMIT 1",
|
||||
// intval($user_info['cid']),
|
||||
// dbesc($user_info['url']),
|
||||
// dbesc(normalise_link($user_info['url'])),
|
||||
// dbesc($user_info['url']),
|
||||
// dbesc(normalise_link($user_info['url']))
|
||||
//);
|
||||
$lastwall = q("SELECT `item`.*, `i`.`contact-id` as `reply_uid`, `i`.`author-link` AS `item-author`
|
||||
FROM `item`, `item` as `i`
|
||||
WHERE `item`.`contact-id` = %d
|
||||
|
@ -859,7 +840,7 @@
|
|||
|
||||
$lastwall = q("SELECT `item`.*
|
||||
FROM `item`, `contact`
|
||||
WHERE `item`.`uid` = %d AND `item`.`contact-id` = %d
|
||||
WHERE `item`.`uid` = %d AND `verb` = '%s' AND `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'
|
||||
|
@ -867,13 +848,13 @@
|
|||
ORDER BY `created` DESC
|
||||
LIMIT 1",
|
||||
intval(api_user()),
|
||||
dbesc(ACTIVITY_POST),
|
||||
intval($user_info['cid']),
|
||||
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];
|
||||
|
||||
|
@ -986,15 +967,15 @@
|
|||
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
|
||||
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
|
||||
FROM `item`, `contact`
|
||||
WHERE `item`.`uid` = %d
|
||||
WHERE `item`.`uid` = %d AND `verb` = '%s'
|
||||
AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
|
||||
AND `contact`.`id` = `item`.`contact-id`
|
||||
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
||||
$sql_extra
|
||||
AND `item`.`id`>%d
|
||||
ORDER BY `item`.`id` DESC LIMIT %d ,%d ",
|
||||
//intval($user_info['uid']),
|
||||
intval(api_user()),
|
||||
dbesc(ACTIVITY_POST),
|
||||
intval($since_id),
|
||||
intval($start), intval($count)
|
||||
);
|
||||
|
@ -1062,9 +1043,9 @@
|
|||
`contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
|
||||
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`,
|
||||
`user`.`nickname`, `user`.`hidewall`
|
||||
FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
|
||||
INNER JOIN `user` ON `user`.`uid` = `item`.`uid`
|
||||
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
|
||||
FROM `item` STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
|
||||
STRAIGHT_JOIN `user` ON `user`.`uid` = `item`.`uid`
|
||||
WHERE `verb` = '%s' AND `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
|
||||
AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
|
||||
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
|
||||
AND `item`.`private` = 0 AND `item`.`wall` = 1 AND `user`.`hidewall` = 0
|
||||
|
@ -1072,6 +1053,7 @@
|
|||
$sql_extra
|
||||
AND `item`.`id`>%d
|
||||
ORDER BY `item`.`id` DESC LIMIT %d, %d ",
|
||||
dbesc(ACTIVITY_POST),
|
||||
intval($since_id),
|
||||
intval($start),
|
||||
intval($count));
|
||||
|
@ -1197,11 +1179,12 @@
|
|||
FROM `item` INNER JOIN (SELECT `uri`,`parent` FROM `item` WHERE `id` = %d) AS `temp1`
|
||||
ON (`item`.`thr-parent` = `temp1`.`uri` AND `item`.`parent` = `temp1`.`parent`), `contact`
|
||||
WHERE `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
|
||||
AND `item`.`uid` = %d AND `contact`.`id` = `item`.`contact-id`
|
||||
AND `item`.`uid` = %d AND `item`.`verb` = '%s' AND `contact`.`id` = `item`.`contact-id`
|
||||
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
||||
AND `item`.`id`>%d $sql_extra
|
||||
ORDER BY `item`.`id` DESC LIMIT %d ,%d",
|
||||
intval($id), intval(api_user()),
|
||||
dbesc(ACTIVITY_POST),
|
||||
intval($since_id),
|
||||
intval($start), intval($count)
|
||||
);
|
||||
|
@ -1347,27 +1330,27 @@
|
|||
$myurl = str_replace('www.','',$myurl);
|
||||
$diasp_url = str_replace('/profile/','/u/',$myurl);
|
||||
|
||||
$sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where `author-link` IN ('https://%s', 'http://%s') OR `mention`)",
|
||||
dbesc(protect_sprintf($myurl)),
|
||||
dbesc(protect_sprintf($myurl))
|
||||
);
|
||||
|
||||
if ($max_id > 0)
|
||||
$sql_extra .= ' AND `item`.`id` <= '.intval($max_id);
|
||||
$sql_extra = ' AND `item`.`id` <= '.intval($max_id);
|
||||
|
||||
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
|
||||
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
|
||||
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
|
||||
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
|
||||
FROM `item`, `contact`
|
||||
WHERE `item`.`uid` = %d
|
||||
WHERE `item`.`uid` = %d AND `verb` = '%s'
|
||||
AND NOT (`item`.`author-link` IN ('https://%s', 'http://%s'))
|
||||
AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
|
||||
AND `contact`.`id` = `item`.`contact-id`
|
||||
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
||||
AND `item`.`parent` IN (SELECT `iid` from thread where uid = %d AND `mention`)
|
||||
$sql_extra
|
||||
AND `item`.`id`>%d
|
||||
ORDER BY `item`.`id` DESC LIMIT %d ,%d ",
|
||||
//intval($user_info['uid']),
|
||||
intval(api_user()),
|
||||
dbesc(ACTIVITY_POST),
|
||||
dbesc(protect_sprintf($myurl)),
|
||||
dbesc(protect_sprintf($myurl)),
|
||||
intval(api_user()),
|
||||
intval($since_id),
|
||||
intval($start), intval($count)
|
||||
|
@ -1432,7 +1415,7 @@
|
|||
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
|
||||
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
|
||||
FROM `item`, `contact`
|
||||
WHERE `item`.`uid` = %d
|
||||
WHERE `item`.`uid` = %d AND `verb` = '%s'
|
||||
AND `item`.`contact-id` = %d
|
||||
AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
|
||||
AND `contact`.`id` = `item`.`contact-id`
|
||||
|
@ -1441,6 +1424,7 @@
|
|||
AND `item`.`id`>%d
|
||||
ORDER BY `item`.`id` DESC LIMIT %d ,%d ",
|
||||
intval(api_user()),
|
||||
dbesc(ACTIVITY_POST),
|
||||
intval($user_info['cid']),
|
||||
intval($since_id),
|
||||
intval($start), intval($count)
|
||||
|
@ -1496,7 +1480,7 @@
|
|||
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
|
||||
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
|
||||
FROM `item`, `contact`
|
||||
WHERE `item`.`uid` = %d
|
||||
WHERE `item`.`uid` = %d AND `verb` = '%s'
|
||||
AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
|
||||
AND `item`.`starred` = 1
|
||||
AND `contact`.`id` = `item`.`contact-id`
|
||||
|
@ -1504,8 +1488,8 @@
|
|||
$sql_extra
|
||||
AND `item`.`id`>%d
|
||||
ORDER BY `item`.`id` DESC LIMIT %d ,%d ",
|
||||
//intval($user_info['uid']),
|
||||
intval(api_user()),
|
||||
dbesc(ACTIVITY_POST),
|
||||
intval($since_id),
|
||||
intval($start), intval($count)
|
||||
);
|
||||
|
@ -1882,28 +1866,6 @@
|
|||
// 'coordinates' => array((float) $notice->lat,
|
||||
// (float) $notice->lon));
|
||||
|
||||
// Seesmic doesn't like the following content
|
||||
// completely disabled to make friendica totally compatible to the statusnet API
|
||||
/*if ($_SERVER['HTTP_USER_AGENT'] != 'Seesmic') {
|
||||
$status2 = array(
|
||||
'updated' => api_date($item['edited']),
|
||||
'published' => api_date($item['created']),
|
||||
'message_id' => $item['uri'],
|
||||
'url' => ($item['plink']!=''?$item['plink']:$item['author-link']),
|
||||
'coordinates' => $item['coord'],
|
||||
'place' => $item['location'],
|
||||
'contributors' => '',
|
||||
'annotations' => '',
|
||||
'entities' => '',
|
||||
'objecttype' => (($item['object-type']) ? $item['object-type'] : ACTIVITY_OBJ_NOTE),
|
||||
'verb' => (($item['verb']) ? $item['verb'] : ACTIVITY_POST),
|
||||
'self' => $a->get_baseurl()."/api/statuses/show/".$item['id'].".".$type,
|
||||
'edit' => $a->get_baseurl()."/api/statuses/show/".$item['id'].".".$type,
|
||||
);
|
||||
|
||||
$status = array_merge($status, $status2);
|
||||
}*/
|
||||
|
||||
$ret[] = $status;
|
||||
};
|
||||
return $ret;
|
||||
|
|
Loading…
Reference in a new issue