Use gravity instead of verb

This commit is contained in:
Michael 2018-06-27 18:09:33 +00:00
parent 8c2f91573a
commit 76dab3b2d7
14 changed files with 59 additions and 56 deletions

View file

@ -1064,8 +1064,8 @@ class Contact extends BaseObject
$contact = ($r[0]["contact-type"] == ACCOUNT_TYPE_COMMUNITY ? 'owner-id' : 'author-id');
$condition = ["`$contact` = ? AND `verb` = ? AND " . $sql,
$author_id, ACTIVITY_POST, local_user()];
$condition = ["`$contact` = ? AND `gravity` IN (?, ?) AND " . $sql,
$author_id, GRAVITY_PARENT, GRAVITY_COMMENT, local_user()];
$params = ['order' => ['created' => true],
'limit' => [$a->pager['start'], $a->pager['itemspage']]];
$r = Item::selectForUser(local_user(), [], $condition, $params);

View file

@ -953,18 +953,21 @@ class Item extends BaseObject
$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
@ -1219,7 +1222,7 @@ class Item extends BaseObject
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;
@ -2644,7 +2647,7 @@ EOT;
'type' => 'activity',
'wall' => $item['wall'],
'origin' => 1,
'gravity' => GRAVITY_LIKE,
'gravity' => GRAVITY_ACTIVITY,
'parent' => $item['id'],
'parent-uri' => $item['uri'],
'thr-parent' => $item['uri'],