Refactor Conversation Timeline

This commit is contained in:
Art4 2024-11-18 22:00:02 +00:00
parent c79f3cde22
commit ec0c3bf96e
2 changed files with 60 additions and 49 deletions

View file

@ -7,7 +7,8 @@
namespace Friendica\Module\Conversation;
use Friendica\App;
use Friendica\App\Arguments;
use Friendica\App\BaseURL;
use Friendica\App\Mode;
use Friendica\BaseModule;
use Friendica\Content\Conversation\Collection\Timelines;
@ -31,6 +32,8 @@ use Friendica\Model\Post;
use Friendica\Model\Post\Engagement;
use Friendica\Model\Post\SearchIndex;
use Friendica\Module\Response;
use Friendica\Network\HTTPException\BadRequestException;
use Friendica\Network\HTTPException\ForbiddenException;
use Friendica\Protocol\Activity;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Profiler;
@ -67,7 +70,7 @@ class Timeline extends BaseModule
/** @var string */
protected $network;
/** @var App\Mode $mode */
/** @var Mode $mode */
protected $mode;
/** @var IHandleUserSessions */
protected $session;
@ -82,7 +85,7 @@ class Timeline extends BaseModule
/** @var UserDefinedChannel */
protected $channelRepository;
public function __construct(UserDefinedChannel $channel, Mode $mode, IHandleUserSessions $session, Database $database, IManagePersonalConfigValues $pConfig, IManageConfigValues $config, ICanCache $cache, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server = [], array $parameters = [])
public function __construct(UserDefinedChannel $channel, Mode $mode, IHandleUserSessions $session, Database $database, IManagePersonalConfigValues $pConfig, IManageConfigValues $config, ICanCache $cache, L10n $l10n, BaseURL $baseUrl, Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server = [], array $parameters = [])
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
@ -98,8 +101,8 @@ class Timeline extends BaseModule
/**
* Computes module parameters from the request and local configuration
*
* @throws HTTPException\BadRequestException
* @throws HTTPException\ForbiddenException
* @throws BadRequestException
* @throws ForbiddenException
*/
protected function parseRequest(array $request)
{
@ -308,6 +311,8 @@ class Timeline extends BaseModule
{
$table = 'post-engagement';
$condition = [];
if ($this->selectedTab == ChannelEntity::WHATSHOT) {
if (!is_null($this->accountType)) {
$condition = ["(`comments` > ? OR `activities` > ?) AND `contact-type` = ?", $this->getMedianComments($uid, 4), $this->getMedianActivities($uid, 4), $this->accountType];
@ -684,6 +689,7 @@ class Timeline extends BaseModule
protected function getCommunityItems()
{
$items = $this->selectItems();
$key = '';
if ($this->selectedTab == Community::LOCAL) {
$maxpostperauthor = (int)$this->config->get('system', 'max_author_posts_community_page');
@ -692,9 +698,15 @@ class Timeline extends BaseModule
$maxpostperauthor = (int)$this->config->get('system', 'max_server_posts_community_page');
$key = 'author-gsid';
} else {
$maxpostperauthor = 0;
$this->setItemsSeenByCondition([
'unseen' => true,
'uid' => $this->session->getLocalUserId(),
'parent-uri-id' => array_column($items, 'uri-id')
]);
return $items;
}
if ($maxpostperauthor != 0) {
$count = 1;
$author_posts = [];
$selected_items = [];
@ -733,9 +745,6 @@ class Timeline extends BaseModule
$items = $this->selectItems();
}
}
} else {
$selected_items = $items;
}
$condition = ['unseen' => true, 'uid' => $this->session->getLocalUserId(), 'parent-uri-id' => array_column($selected_items, 'uri-id')];
$this->setItemsSeenByCondition($condition);

View file

@ -565,6 +565,8 @@ class Probe
$nick = '';
$addr = '';
$path_parts = [];
if (array_key_exists('path', $parts) && trim(strval($parts['path']), '/') !== '') {
$path_parts = explode('/', trim($parts['path'], '/'));
@ -578,7 +580,7 @@ class Probe
}
if (empty($webfinger) && empty($lrdd)) {
while (empty($lrdd) && empty($webfinger) && (sizeof($path_parts) > 1)) {
while (empty($lrdd) && empty($webfinger) && (count($path_parts) > 1)) {
$host .= '/' . array_shift($path_parts);
$baseurl = $parts['scheme'] . '://' . $host;