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

This commit is contained in:
Michael 2020-05-27 12:19:06 +00:00
parent 133de9b524
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'];
}
}