Don't count and fetch "follow" activities

This commit is contained in:
Michael 2020-05-07 18:39:39 +00:00
parent fbf846accb
commit 856cf7f664
3 changed files with 42 additions and 17 deletions

View file

@ -769,9 +769,36 @@ function conversation_add_children(array $parents, $block_authors, $order, $uid)
$items = []; $items = [];
$follow = Item::activityToIndex(Activity::FOLLOW);
foreach ($parents AS $parent) { foreach ($parents AS $parent) {
$condition = ["`item`.`parent-uri` = ? AND `item`.`uid` IN (0, ?) ", $condition = ["`item`.`parent-uri` = ? AND `item`.`uid` IN (0, ?) AND (`activity` != ? OR `activity` IS NULL)",
$parent['uri'], $uid]; $parent['uri'], $uid, $follow];
$items = conversation_fetch_items($parent, $items, $condition, $block_authors, $params);
}
foreach ($items as $index => $item) {
if ($item['uid'] == 0) {
$items[$index]['writable'] = in_array($item['network'], Protocol::FEDERATED);
}
}
$items = conv_sort($items, $order);
return $items;
}
/**
* Fetch conversation items
*
* @param array $parent
* @param array $items
* @param array $condition
* @param boolean $block_authors
* @param array $params
* @return array
*/
function conversation_fetch_items(array $parent, array $items, array $condition, bool $block_authors, array $params) {
if ($block_authors) { if ($block_authors) {
$condition[0] .= "AND NOT `author`.`hidden`"; $condition[0] .= "AND NOT `author`.`hidden`";
} }
@ -783,16 +810,6 @@ function conversation_add_children(array $parents, $block_authors, $order, $uid)
if (count($comments) != 0) { if (count($comments) != 0) {
$items = array_merge($items, $comments); $items = array_merge($items, $comments);
} }
}
foreach ($items as $index => $item) {
if ($item['uid'] == 0) {
$items[$index]['writable'] = in_array($item['network'], Protocol::FEDERATED);
}
}
$items = conv_sort($items, $order);
return $items; return $items;
} }

View file

@ -30,6 +30,7 @@ use Friendica\Model\Contact;
use Friendica\Model\Group; use Friendica\Model\Group;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\Notify\Type; use Friendica\Model\Notify\Type;
use Friendica\Protocol\Activity;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Temporal; use Friendica\Util\Temporal;
use Friendica\Util\Proxy as ProxyUtils; use Friendica\Util\Proxy as ProxyUtils;
@ -134,9 +135,10 @@ function ping_init(App $a)
$notifs = ping_get_notifications(local_user()); $notifs = ping_get_notifications(local_user());
$condition = ["`unseen` AND `uid` = ? AND `contact-id` != ?", local_user(), local_user()]; $condition = ["`unseen` AND `uid` = ? AND `contact-id` != ? AND (`activity` != ? OR `activity` IS NULL)",
local_user(), local_user(), Item::activityToIndex(Activity::FOLLOW)];
$fields = ['id', 'parent', 'verb', 'author-name', 'unseen', 'author-link', 'author-avatar', 'contact-avatar', $fields = ['id', 'parent', 'verb', 'author-name', 'unseen', 'author-link', 'author-avatar', 'contact-avatar',
'network', 'created', 'object', 'parent-author-name', 'parent-author-link', 'parent-guid', 'wall']; 'network', 'created', 'object', 'parent-author-name', 'parent-author-link', 'parent-guid', 'wall', 'activity'];
$params = ['order' => ['received' => true]]; $params = ['order' => ['received' => true]];
$items = Item::selectForUser(local_user(), $fields, $condition, $params); $items = Item::selectForUser(local_user(), $fields, $condition, $params);

View file

@ -74,7 +74,7 @@ class Item
'event-id', 'event-created', 'event-edited', 'event-start', 'event-finish', 'event-id', 'event-created', 'event-edited', 'event-start', 'event-finish',
'event-summary', 'event-desc', 'event-location', 'event-type', 'event-summary', 'event-desc', 'event-location', 'event-type',
'event-nofinish', 'event-adjust', 'event-ignore', 'event-id', 'event-nofinish', 'event-adjust', 'event-ignore', 'event-id',
'delivery_queue_count', 'delivery_queue_done', 'delivery_queue_failed' 'delivery_queue_count', 'delivery_queue_done', 'delivery_queue_failed', 'activity'
]; ];
// Field list that is used to deliver items via the protocols // Field list that is used to deliver items via the protocols
@ -1672,7 +1672,13 @@ class Item
$allow_gid = $parent['allow_gid']; $allow_gid = $parent['allow_gid'];
$deny_cid = $parent['deny_cid']; $deny_cid = $parent['deny_cid'];
$deny_gid = $parent['deny_gid']; $deny_gid = $parent['deny_gid'];
// Don't federate received participation messages
if ($item['verb'] != Activity::FOLLOW) {
$item['wall'] = $parent['wall']; $item['wall'] = $parent['wall'];
} else {
$item['wall'] = false;
}
/* /*
* If the parent is private, force privacy for the entire conversation * If the parent is private, force privacy for the entire conversation