}
// get last public wall message
- $condition = ["`owner-id` = ? AND `uid` = ? AND `type` != 'activity' ".$privacy_sql,
- $user_info['pid'], api_user()];
+ $condition = ['owner-id' => $user_info['pid'], 'uid' => api_user(),
+ 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]];
$lastwall = dba::selectFirst('item', [], $condition, ['order' => ['id' => true]]);
if (DBM::is_result($lastwall)) {
$user_info = api_get_user($a);
- $condition = ["`owner-id` = ? AND `uid` = ? AND `verb` = ? AND `type` != 'activity' AND NOT `private`",
- $user_info['pid'], api_user(), ACTIVITY_POST];
+ $condition = ['owner-id' => $user_info['pid'], 'uid' => api_user(),
+ 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT], 'private' => false];
$lastwall = dba::selectFirst('item', [], $condition, ['order' => ['id' => true]]);
if (DBM::is_result($lastwall)) {
$start = $page * $count;
- $condition = ["`verb` = ? AND `item`.`id` > ?
+ $condition = ["`gravity` IN (?, ?) AND `item`.`id` > ?
AND (`item`.`uid` = 0 OR (`item`.`uid` = ? AND NOT `item`.`global`))
AND `item`.`body` LIKE CONCAT('%',?,'%')",
- ACTIVITY_POST, $since_id, api_user(), $_REQUEST['q']];
+ GRAVITY_PARENT, GRAVITY_COMMENT, $since_id, api_user(), $_REQUEST['q']];
if ($max_id > 0) {
$condition[0] .= " AND `item`.`id` <= ?";
$start = $page * $count;
- $condition = ["`uid` = ? AND `verb` = ? AND `item`.`id` > ?", api_user(), ACTIVITY_POST, $since_id];
+ $condition = ["`uid` = ? AND `gravity` IN (?, ?) AND `item`.`id` > ?",
+ api_user(), GRAVITY_PARENT, GRAVITY_COMMENT, $since_id];
if ($max_id > 0) {
$condition[0] .= " AND `item`.`id` <= ?";
$sql_extra = '';
if ($exclude_replies && !$conversation_id) {
- $condition = ["`verb` = ? AND `iid` > ? AND NOT `private` AND `wall` AND NOT `user`.`hidewall`",
- ACTIVITY_POST, $since_id];
+ $condition = ["`gravity` IN (?, ?) AND `iid` > ? AND NOT `private` AND `wall` AND NOT `user`.`hidewall`",
+ GRAVITY_PARENT, GRAVITY_COMMENT, $since_id];
if ($max_id > 0) {
$condition[0] .= " AND `thread`.`iid` <= ?";
$r = Item::inArray($statuses);
} else {
- $condition = ["`verb` = ? AND `id` > ? AND NOT `private` AND `wall` AND NOT `user`.`hidewall` AND `item`.`origin`",
- ACTIVITY_POST, $since_id];
+ $condition = ["`gravity` IN (?, ?) AND `id` > ? AND NOT `private` AND `wall` AND NOT `user`.`hidewall` AND `item`.`origin`",
+ GRAVITY_PARENT, GRAVITY_COMMENT, $since_id];
if ($max_id > 0) {
$condition[0] .= " AND `item`.`id` <= ?";
}
$start = ($page - 1) * $count;
- $condition = ["`uid` = 0 AND `verb` = ? AND `thread`.`iid` > ? AND NOT `private`",
- ACTIVITY_POST, $since_id];
+ $condition = ["`uid` = 0 AND `gravity` IN (?, ?) AND `thread`.`iid` > ? AND NOT `private`",
+ GRAVITY_PARENT, GRAVITY_COMMENT, $since_id];
if ($max_id > 0) {
$condition[0] .= " AND `thread`.`iid` <= ?";
$id = $item['id'];
if ($conversation) {
- $condition = ['parent' => $id, 'verb' => ACTIVITY_POST];
+ $condition = ['parent' => $id, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]];
$params = ['order' => ['id' => true]];
} else {
- $condition = ['id' => $id, 'verb' => ACTIVITY_POST];
+ $condition = ['id' => $id, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]];
$params = [];
}
$id = $parent['id'];
- $condition = ["`parent` = ? AND `uid` IN (0, ?) AND `verb` = ? AND `item`.`id` > ?",
- $id, api_user(), ACTIVITY_POST, $since_id];
+ $condition = ["`parent` = ? AND `uid` IN (0, ?) AND `gravity` IN (?, ?) AND `item`.`id` > ?",
+ $id, api_user(), GRAVITY_PARENT, GRAVITY_COMMENT, $since_id];
if ($max_id > 0) {
$condition[0] .= " AND `item`.`id` <= ?";
$start = ($page - 1) * $count;
- $condition = ["`uid` = ? AND `verb` = ? AND `item`.`id` > ? AND `author-id` != ?
+ $condition = ["`uid` = ? AND `gravity` IN (?, ?) AND `item`.`id` > ? AND `author-id` != ?
AND `item`.`parent` IN (SELECT `iid` FROM `thread` WHERE `thread`.`uid` = ? AND `thread`.`mention` AND NOT `thread`.`ignored`)",
- api_user(), ACTIVITY_POST, $since_id, $user_info['pid'], api_user()];
+ api_user(), GRAVITY_PARENT, GRAVITY_COMMENT, $since_id, $user_info['pid'], api_user()];
if ($max_id > 0) {
$condition[0] .= " AND `item`.`id` <= ?";
}
$start = ($page - 1) * $count;
- $condition = ["`uid` = ? AND `verb` = ? AND `item`.`id` > ? AND `item`.`contact-id` = ?",
- api_user(), ACTIVITY_POST, $since_id, $user_info['cid']];
+ $condition = ["`uid` = ? AND `gravity` IN (?, ?) AND `item`.`id` > ? AND `item`.`contact-id` = ?",
+ api_user(), GRAVITY_PARENT, GRAVITY_COMMENT, $since_id, $user_info['cid']];
if ($user_info['self'] == 1) {
$condition[0] .= ' AND `item`.`wall` ';
$start = $page*$count;
- $condition = ["`uid` = ? AND `verb` = ? AND `id` > ? AND `starred`",
- api_user(), ACTIVITY_POST, $since_id];
+ $condition = ["`uid` = ? AND `gravity` IN (?, ?) AND `id` > ? AND `starred`",
+ api_user(), GRAVITY_PARENT, GRAVITY_COMMENT, $since_id];
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
$start = $page * $count;
- $condition = ["`uid` = ? AND `verb` = ? AND `id` > ? AND `group_member`.`gid` = ?",
- api_user(), ACTIVITY_POST, $since_id, $_REQUEST['list_id']];
+ $condition = ["`uid` = ? AND `gravity` IN (?, ?) AND `id` > ? AND `group_member`.`gid` = ?",
+ api_user(), GRAVITY_PARENT, GRAVITY_COMMENT, $since_id, $_REQUEST['list_id']];
if ($max_id > 0) {
$condition[0] .= " AND `item`.`id` <= ?";
$data['photo']['friendica_activities'] = api_format_items_activities($item, $type);
// retrieve comments on photo
- $condition = ["`parent` = ? AND `uid` = ? AND (`verb` = ? OR `type`='photo')",
- $item[0]['parent'], api_user(), ACTIVITY_POST];
+ $condition = ["`parent` = ? AND `uid` = ? AND (`gravity` IN (?, ?) OR `type`='photo')",
+ $item[0]['parent'], api_user(), GRAVITY_PARENT, GRAVITY_COMMENT];
$statuses = Item::selectForUser(api_user(), [], $condition);
$item['parent-uri'] = $item['thr-parent'];
}
- if (x($item, 'gravity')) {
+ $item['type'] = defaults($item, 'type', 'remote');
+
+ if (isset($item['gravity'])) {
$item['gravity'] = intval($item['gravity']);
} elseif ($item['parent-uri'] === $item['uri']) {
- $item['gravity'] = 0;
- } elseif (activity_match($item['verb'],ACTIVITY_POST)) {
- $item['gravity'] = 6;
+ $item['gravity'] = GRAVITY_PARENT;
+ } elseif (activity_match($item['verb'], ACTIVITY_POST)) {
+ $item['gravity'] = GRAVITY_COMMENT;
+ } elseif ($item['type'] == 'activity') {
+ $item['gravity'] = GRAVITY_ACTIVITY;
} else {
- $item['gravity'] = 6; // extensible catchall
+ $item['gravity'] = GRAVITY_UNKNOWN; // Should not happen
+ logger('Unknown gravity for verb: ' . $item['verb'] . ' - type: ' . $item['type'], LOGGER_DEBUG);
}
- $item['type'] = defaults($item, 'type', 'remote');
-
$uid = intval($item['uid']);
// check for create date and expire time
logger('$force_parent=true, reply converted to top-level post.');
$parent_id = 0;
$item['parent-uri'] = $item['uri'];
- $item['gravity'] = 0;
+ $item['gravity'] = GRAVITY_PARENT;
} else {
logger('item parent '.$item['parent-uri'].' for '.$item['uid'].' was not found - ignoring item');
return 0;
'type' => 'activity',
'wall' => $item['wall'],
'origin' => 1,
- 'gravity' => GRAVITY_LIKE,
+ 'gravity' => GRAVITY_ACTIVITY,
'parent' => $item['id'],
'parent-uri' => $item['uri'],
'thr-parent' => $item['uri'],