Replace "id = parent" checks with "gravity" checks

This commit is contained in:
Michael 2020-05-27 12:19:06 +00:00
commit 973abb6196
13 changed files with 56 additions and 56 deletions

View file

@ -54,7 +54,7 @@ function display_init(App $a)
$item = null;
$item_user = local_user();
$fields = ['id', 'parent', 'author-id', 'body', 'uid', 'guid'];
$fields = ['id', 'parent', 'author-id', 'body', 'uid', 'guid', 'gravity'];
// If there is only one parameter, then check if this parameter could be a guid
if ($a->argc == 2) {
@ -101,12 +101,12 @@ function display_init(App $a)
}
if (!empty($_SERVER['HTTP_ACCEPT']) && strstr($_SERVER['HTTP_ACCEPT'], 'application/atom+xml')) {
Logger::log('Directly serving XML for id '.$item["id"], Logger::DEBUG);
displayShowFeed($item["id"], false);
Logger::log('Directly serving XML for id '.$item['id'], Logger::DEBUG);
displayShowFeed($item['id'], false);
}
if ($item["id"] != $item["parent"]) {
$parent = Item::selectFirstForUser($item_user, $fields, ['id' => $item["parent"]]);
if ($item['gravity'] != GRAVITY_PARENT) {
$parent = Item::selectFirstForUser($item_user, $fields, ['id' => $item['parent']]);
$item = $parent ?: $item;
}
@ -205,8 +205,8 @@ function display_content(App $a, $update = false, $update_uid = 0)
$condition = ['guid' => $a->argv[1], 'uid' => local_user()];
$item = Item::selectFirstForUser(local_user(), $fields, $condition);
if (DBA::isResult($item)) {
$item_id = $item["id"];
$item_parent = $item["parent"];
$item_id = $item['id'];
$item_parent = $item['parent'];
$item_parent_uri = $item['parent-uri'];
}
}
@ -214,8 +214,8 @@ function display_content(App $a, $update = false, $update_uid = 0)
if (($item_parent == 0) && remote_user()) {
$item = Item::selectFirst($fields, ['guid' => $a->argv[1], 'private' => Item::PRIVATE, 'origin' => true]);
if (DBA::isResult($item) && Contact::isFollower(remote_user(), $item['uid'])) {
$item_id = $item["id"];
$item_parent = $item["parent"];
$item_id = $item['id'];
$item_parent = $item['parent'];
$item_parent_uri = $item['parent-uri'];
}
}
@ -224,8 +224,8 @@ function display_content(App $a, $update = false, $update_uid = 0)
$condition = ['private' => [Item::PUBLIC, Item::UNLISTED], 'guid' => $a->argv[1], 'uid' => 0];
$item = Item::selectFirstForUser(local_user(), $fields, $condition);
if (DBA::isResult($item)) {
$item_id = $item["id"];
$item_parent = $item["parent"];
$item_id = $item['id'];
$item_parent = $item['parent'];
$item_parent_uri = $item['parent-uri'];
}
}

View file

@ -119,7 +119,7 @@ function item_post(App $a) {
// The URI and the contact is taken from the direct parent which needn't to be the top parent
$thr_parent_uri = $toplevel_item['uri'];
if ($toplevel_item['id'] != $toplevel_item['parent']) {
if ($toplevel_item['gravity'] != GRAVITY_PARENT) {
$toplevel_item = Item::selectFirst([], ['id' => $toplevel_item['parent']]);
}
}

View file

@ -709,7 +709,7 @@ function networkThreadedView(App $a, $update, $parent)
}
if ($order === 'post') {
// Only show toplevel posts when updating posts in this order mode
$sql_extra4 .= " AND `item`.`id` = `item`.`parent`";
$sql_extra4 .= " AND `item`.`gravity` = " . GRAVITY_PARENT;
}
}

View file

@ -1456,7 +1456,7 @@ function photos_content(App $a)
if (($activity->match($item['verb'], Activity::LIKE) ||
$activity->match($item['verb'], Activity::DISLIKE)) &&
($item['id'] != $item['parent'])) {
($item['gravity'] != GRAVITY_PARENT)) {
continue;
}

View file

@ -467,13 +467,13 @@ function ping_get_notifications($uid)
if ($notification["visible"]
&& !$notification["deleted"]
&& empty($result[$notification["parent"]])
&& empty($result[$notification['parent']])
) {
// Should we condense the notifications or show them all?
if (DI::pConfig()->get(local_user(), 'system', 'detailed_notif')) {
$result[$notification["id"]] = $notification;
} else {
$result[$notification["parent"]] = $notification;
$result[$notification['parent']] = $notification;
}
}
}