Use "received" instead of "created" when displaying posts in creation order
This commit is contained in:
parent
9b8b2b36cd
commit
6bb418c5a7
12 changed files with 51 additions and 59 deletions
|
@ -1107,7 +1107,7 @@ function api_statuses_update($type)
|
|||
if ($throttle_day > 0) {
|
||||
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60);
|
||||
|
||||
$condition = ["`uid` = ? AND `wall` AND `created` > ?", api_user(), $datefrom];
|
||||
$condition = ["`uid` = ? AND `wall` AND `received` > ?", api_user(), $datefrom];
|
||||
$posts_day = DBA::count('thread', $condition);
|
||||
|
||||
if ($posts_day > $throttle_day) {
|
||||
|
@ -1121,7 +1121,7 @@ function api_statuses_update($type)
|
|||
if ($throttle_week > 0) {
|
||||
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*7);
|
||||
|
||||
$condition = ["`uid` = ? AND `wall` AND `created` > ?", api_user(), $datefrom];
|
||||
$condition = ["`uid` = ? AND `wall` AND `received` > ?", api_user(), $datefrom];
|
||||
$posts_week = DBA::count('thread', $condition);
|
||||
|
||||
if ($posts_week > $throttle_week) {
|
||||
|
@ -1135,7 +1135,7 @@ function api_statuses_update($type)
|
|||
if ($throttle_month > 0) {
|
||||
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*30);
|
||||
|
||||
$condition = ["`uid` = ? AND `wall` AND `created` > ?", api_user(), $datefrom];
|
||||
$condition = ["`uid` = ? AND `wall` AND `received` > ?", api_user(), $datefrom];
|
||||
$posts_month = DBA::count('thread', $condition);
|
||||
|
||||
if ($posts_month > $throttle_month) {
|
||||
|
@ -5057,7 +5057,7 @@ function api_get_announce($item)
|
|||
$fields = ['author-id', 'author-name', 'author-link', 'author-avatar'];
|
||||
$activity = Item::activityToIndex(ACTIVITY2_ANNOUNCE);
|
||||
$condition = ['parent-uri' => $item['uri'], 'gravity' => GRAVITY_ACTIVITY, 'uid' => [0, $item['uid']], 'activity' => $activity];
|
||||
$announce = Item::selectFirstForUser($item['uid'], $fields, $condition, ['order' => ['created' => true]]);
|
||||
$announce = Item::selectFirstForUser($item['uid'], $fields, $condition, ['order' => ['received' => true]]);
|
||||
if (!DBA::isResult($announce)) {
|
||||
return [];
|
||||
}
|
||||
|
|
|
@ -800,12 +800,12 @@ function conversation_fetch_comments($thread_items) {
|
|||
$parentlines = [];
|
||||
$lineno = 0;
|
||||
$actor = [];
|
||||
$created = '';
|
||||
$received = '';
|
||||
|
||||
while ($row = Item::fetch($thread_items)) {
|
||||
if (($row['verb'] == ACTIVITY2_ANNOUNCE) && !empty($row['contact-uid']) && ($row['created'] > $created) && ($row['thr-parent'] == $row['parent-uri'])) {
|
||||
if (($row['verb'] == ACTIVITY2_ANNOUNCE) && !empty($row['contact-uid']) && ($row['received'] > $received) && ($row['thr-parent'] == $row['parent-uri'])) {
|
||||
$actor = ['link' => $row['author-link'], 'avatar' => $row['author-avatar'], 'name' => $row['author-name']];
|
||||
$created = $row['created'];
|
||||
$received = $row['received'];
|
||||
}
|
||||
|
||||
if ((($row['gravity'] == GRAVITY_PARENT) && !$row['origin'] && !in_array($row['network'], [Protocol::DIASPORA])) &&
|
||||
|
@ -1316,7 +1316,7 @@ function get_item_children(array &$item_list, array $parent, $recursive = true)
|
|||
function sort_item_children(array $items)
|
||||
{
|
||||
$result = $items;
|
||||
usort($result, 'sort_thr_created_rev');
|
||||
usort($result, 'sort_thr_received_rev');
|
||||
foreach ($result as $k => $i) {
|
||||
if (isset($result[$k]['children'])) {
|
||||
$result[$k]['children'] = sort_item_children($result[$k]['children']);
|
||||
|
@ -1401,13 +1401,13 @@ function smart_flatten_conversation(array $parent)
|
|||
|
||||
/**
|
||||
* Expands a flat list of items into corresponding tree-like conversation structures,
|
||||
* sort the top-level posts either on "created" or "commented", and finally
|
||||
* sort the top-level posts either on "received" or "commented", and finally
|
||||
* append all the items at the top level (???)
|
||||
*
|
||||
* @brief Expands a flat item list into a conversation array for display
|
||||
*
|
||||
* @param array $item_list A list of items belonging to one or more conversations
|
||||
* @param string $order Either on "created" or "commented"
|
||||
* @param string $order Either on "received" or "commented"
|
||||
* @return array
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
|
@ -1439,8 +1439,8 @@ function conv_sort(array $item_list, $order)
|
|||
}
|
||||
}
|
||||
|
||||
if (stristr($order, 'created')) {
|
||||
usort($parents, 'sort_thr_created');
|
||||
if (stristr($order, 'received')) {
|
||||
usort($parents, 'sort_thr_received');
|
||||
} elseif (stristr($order, 'commented')) {
|
||||
usort($parents, 'sort_thr_commented');
|
||||
}
|
||||
|
@ -1477,27 +1477,27 @@ function conv_sort(array $item_list, $order)
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief usort() callback to sort item arrays by the created key
|
||||
* @brief usort() callback to sort item arrays by the received key
|
||||
*
|
||||
* @param array $a
|
||||
* @param array $b
|
||||
* @return int
|
||||
*/
|
||||
function sort_thr_created(array $a, array $b)
|
||||
function sort_thr_received(array $a, array $b)
|
||||
{
|
||||
return strcmp($b['created'], $a['created']);
|
||||
return strcmp($b['received'], $a['received']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief usort() callback to reverse sort item arrays by the created key
|
||||
* @brief usort() callback to reverse sort item arrays by the received key
|
||||
*
|
||||
* @param array $a
|
||||
* @param array $b
|
||||
* @return int
|
||||
*/
|
||||
function sort_thr_created_rev(array $a, array $b)
|
||||
function sort_thr_received_rev(array $a, array $b)
|
||||
{
|
||||
return strcmp($a['created'], $b['created']);
|
||||
return strcmp($a['received'], $b['received']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue