3 * @copyright Copyright (C) 2010-2024, the Friendica project
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 namespace Friendica\Module\Ping;
25 use Friendica\App\Mode;
26 use Friendica\Content\Conversation;
27 use Friendica\Content\Conversation\Factory\Timeline as TimelineFactory;
28 use Friendica\Content\Conversation\Repository\UserDefinedChannel;
29 use Friendica\Content\Conversation\Factory\Channel as ChannelFactory;
30 use Friendica\Content\Conversation\Factory\UserDefinedChannel as UserDefinedChannelFactory;
31 use Friendica\Content\Conversation\Factory\Community as CommunityFactory;
32 use Friendica\Content\Conversation\Factory\Network as NetworkFactory;
33 use Friendica\Core\Cache\Capability\ICanCache;
34 use Friendica\Core\Config\Capability\IManageConfigValues;
35 use Friendica\Core\L10n;
36 use Friendica\Core\Lock\Capability\ICanLock;
37 use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
38 use Friendica\Core\Session\Capability\IHandleUserSessions;
39 use Friendica\Core\System;
40 use Friendica\Database\Database;
41 use Friendica\Module\Conversation\Network as NetworkModule;
42 use Friendica\Module\Response;
43 use Friendica\Navigation\SystemMessages;
44 use Friendica\Util\Profiler;
45 use Psr\Log\LoggerInterface;
47 class Network extends NetworkModule
54 public function __construct(ICanLock $lock, UserDefinedChannelFactory $userDefinedChannel, NetworkFactory $network, CommunityFactory $community, ChannelFactory $channelFactory, UserDefinedChannel $channel, App $app, TimelineFactory $timeline, SystemMessages $systemMessages, Mode $mode, Conversation $conversation, App\Page $page, 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 = [])
56 parent::__construct($userDefinedChannel, $network, $community, $channelFactory, $channel, $app, $timeline, $systemMessages, $mode, $conversation, $page, $session, $database, $pConfig, $config, $cache, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
61 protected function rawContent(array $request = [])
63 if (!$this->session->getLocalUserId()) {
67 if (!empty($request['ping'])) {
68 $request = $this->getTimelineRequestBySession();
71 if (!isset($request['p']) || !isset($request['item'])) {
75 $this->parseRequest($request);
77 if ($this->force || !is_null($this->maxId)) {
81 $lockkey = 'network-ping-' . $this->session->getLocalUserId();
82 if (!$this->lock->acquire($lockkey, 0)) {
83 $this->logger->debug('Ping-1-lock', ['uid' => $this->session->getLocalUserId()]);
88 $this->itemsPerPage = 100;
90 if ($this->channel->isTimeline($this->selectedTab) || $this->userDefinedChannel->isTimeline($this->selectedTab, $this->session->getLocalUserId())) {
91 $items = $this->getChannelItems($request);
92 } elseif ($this->community->isTimeline($this->selectedTab)) {
93 $items = $this->getCommunityItems();
95 $items = $this->getItems();
97 $this->lock->release($lockkey);
98 $count = count($items);
99 System::httpExit(($count < 100) ? $count : '99+');