Use "received" instead of "created" when displaying posts in creation order

This commit is contained in:
Michael 2019-07-07 21:30:33 +00:00
parent 9b8b2b36cd
commit 6bb418c5a7
12 changed files with 51 additions and 59 deletions

View file

@ -1616,7 +1616,7 @@ class Contact extends BaseObject
$pager = new Pager($a->query_string);
$params = ['order' => ['created' => true],
$params = ['order' => ['received' => true],
'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
if ($thread_mode) {

View file

@ -1650,7 +1650,7 @@ class Item extends BaseObject
Logger::log('duplicated item with the same guid found. '.print_r($item,true));
return 0;
}
} else {
} elseif ($item['network'] == Protocol::OSTATUS) {
// Check for an existing post with the same content. There seems to be a problem with OStatus.
$condition = ["`body` = ? AND `network` = ? AND `created` = ? AND `contact-id` = ? AND `uid` = ?",
$item['body'], $item['network'], $item['created'], $item['contact-id'], $item['uid']];
@ -2905,19 +2905,11 @@ class Item extends BaseObject
if ($network != "") {
$condition[0] .= " AND `network` = ?";
$condition[] = $network;
/*
* There is an index "uid_network_received" but not "uid_network_created"
* This avoids the creation of another index just for one purpose.
* And it doesn't really matter wether to look at "received" or "created"
*/
$condition[0] .= " AND `received` < UTC_TIMESTAMP() - INTERVAL ? DAY";
$condition[] = $days;
} else {
$condition[0] .= " AND `created` < UTC_TIMESTAMP() - INTERVAL ? DAY";
$condition[] = $days;
}
$condition[0] .= " AND `received` < UTC_TIMESTAMP() - INTERVAL ? DAY";
$condition[] = $days;
$items = self::select(['file', 'resource-id', 'starred', 'type', 'id', 'post-type'], $condition);
if (!DBA::isResult($items)) {
@ -2967,10 +2959,10 @@ class Item extends BaseObject
public static function firstPostDate($uid, $wall = false)
{
$condition = ['uid' => $uid, 'wall' => $wall, 'deleted' => false, 'visible' => true, 'moderated' => false];
$params = ['order' => ['created' => false]];
$thread = DBA::selectFirst('thread', ['created'], $condition, $params);
$params = ['order' => ['received' => false]];
$thread = DBA::selectFirst('thread', ['received'], $condition, $params);
if (DBA::isResult($thread)) {
return substr(DateTimeFormat::local($thread['created']), 0, 10);
return substr(DateTimeFormat::local($thread['received']), 0, 10);
}
return false;
}