// now that we have the img url in bbcode we can add it to the status and insert the wall item.
$_REQUEST['body'] = $txt . "\n\n" . '[url=' . $picture["albumpage"] . '][img]' . $picture["preview"] . "[/img][/url]";
- item_post($a);
+ $item_id = item_post($a);
- // this should output the last post (the one we just posted).
- return api_status_show($type);
+ // output the post that we just posted.
+ return api_status_show($type, $item_id);
}
/// @TODO move this to top of file or somewhere better!
*/
function api_statuses_update($type)
{
-
$a = get_app();
if (api_user() === false) {
if ($throttle_day > 0) {
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60);
- $condition = ["`uid` = ? AND `wall` AND `created` > ? AND `id` = `parent`", api_user(), $datefrom];
+ $condition = ["`uid` = ? AND `wall` AND `changed` > ? AND `gravity` = ?", api_user(), $datefrom, GRAVITY_PARENT];
$posts_day = DBA::count('item', $condition);
if ($posts_day > $throttle_day) {
if ($throttle_week > 0) {
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*7);
- $condition = ["`uid` = ? AND `wall` AND `created` > ? AND `id` = `parent`", api_user(), $datefrom];
+ $condition = ["`uid` = ? AND `wall` AND `changed` > ? AND `gravity` = ?", api_user(), $datefrom, GRAVITY_PARENT];
$posts_week = DBA::count('item', $condition);
if ($posts_week > $throttle_week) {
if ($throttle_month > 0) {
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*30);
- $condition = ["`uid` = ? AND `wall` AND `created` > ? AND `id` = `parent`", api_user(), $datefrom];
+ $condition = ["`uid` = ? AND `wall` AND `changed` > ? AND `gravity` = ?", api_user(), $datefrom, GRAVITY_PARENT];
$posts_month = DBA::count('item', $condition);
if ($posts_month > $throttle_month) {
}
// call out normal post function
- item_post($a);
+ $item_id = item_post($a);
- // this should output the last post (the one we just posted).
- return api_status_show($type);
+ // output the post that we just posted.
+ return api_status_show($type, $item_id);
}
/// @TODO move to top of file or somewhere better
*
* @return array|string
*/
-function api_status_show($type)
+function api_status_show($type, $item_id = 0)
{
$a = get_app();
$privacy_sql = "";
}
- // get last public wall message
- $condition = ['owner-id' => $user_info['pid'], 'uid' => api_user(),
- 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]];
+ if (!empty($item_id)) {
+ // Get the item with the given id
+ $condition = ['id' => $item_id];
+ } else {
+ // get last public wall message
+ $condition = ['owner-id' => $user_info['pid'], 'uid' => api_user(),
+ 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]];
+ }
$lastwall = Item::selectFirst(Item::ITEM_FIELDLIST, $condition, ['order' => ['id' => true]]);
if (DBA::isResult($lastwall)) {
$_REQUEST["source"] = api_source();
}
- item_post($a);
+ $item_id = item_post($a);
} else {
throw new ForbiddenException();
}
- // this should output the last post (the one we just posted).
+ // output the last post tha we just posted.
$called_api = [];
- return api_status_show($type);
+ return api_status_show($type, $item_id);
}
/// @TODO move to top of file or somewhere better