X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fnetwork.php;h=d82072754c9bf140e7d0602e8c68f63ff0dfeb1b;hb=418c2edb50ce948f687400eea01b2dc875c1ab1f;hp=3311a796a89b5cd4f3776abfa9478ce9d8542cbb;hpb=acea18a25549b4f067bc01fb5ff1d88c446edb18;p=friendica.git diff --git a/mod/network.php b/mod/network.php index 3311a796a8..d82072754c 100644 --- a/mod/network.php +++ b/mod/network.php @@ -20,7 +20,6 @@ */ use Friendica\App; -use Friendica\Content\Feature; use Friendica\Content\ForumManager; use Friendica\Content\Nav; use Friendica\Content\Pager; @@ -29,9 +28,7 @@ use Friendica\Content\Text\HTML; use Friendica\Core\ACL; use Friendica\Core\Hook; use Friendica\Core\Logger; -use Friendica\Core\Protocol; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Contact; @@ -41,13 +38,12 @@ use Friendica\Model\Post\Category; use Friendica\Model\Profile; use Friendica\Module\Security\Login; use Friendica\Util\DateTimeFormat; -use Friendica\Util\Proxy as ProxyUtils; use Friendica\Util\Strings; function network_init(App $a) { if (!local_user()) { - notice(DI::l10n()->t('Permission denied.') . EOL); + notice(DI::l10n()->t('Permission denied.')); return; } @@ -271,7 +267,7 @@ function networkConversation(App $a, $items, Pager $pager, $mode, $update, $orde $a->page_contact = $a->contact; if (!is_array($items)) { - Logger::log("Expecting items to be an array. Got " . print_r($items, true)); + Logger::info('Expecting items to be an array.', ['items' => $items]); $items = []; } @@ -305,7 +301,7 @@ function network_content(App $a, $update = 0, $parent = 0) } if ($o === '') { - info("No items found"); + notice(DI::l10n()->t("No items found")); } return $o; @@ -541,7 +537,6 @@ function networkThreadedView(App $a, $update, $parent) } $sql_nets = (($nets) ? sprintf(" AND $sql_table.`network` = '%s' ", DBA::escape($nets)) : ''); - $sql_tag_nets = (($nets) ? sprintf(" AND `item`.`network` = '%s' ", DBA::escape($nets)) : ''); if ($gid) { $group = DBA::selectFirst('group', ['name'], ['id' => $gid, 'uid' => local_user()]); @@ -549,7 +544,7 @@ function networkThreadedView(App $a, $update, $parent) if ($update) { exit(); } - notice(DI::l10n()->t('No such group') . EOL); + notice(DI::l10n()->t('No such group')); DI::baseUrl()->redirect('network/0'); // NOTREACHED } @@ -570,7 +565,7 @@ function networkThreadedView(App $a, $update, $parent) $sql_extra3 .= " OR (`thread`.`contact-id` = '$contact_str_self' AND `temp1`.`allow_gid` LIKE '" . Strings::protectSprintf('%<' . intval($gid) . '>%') . "' AND `temp1`.`private`))"; } else { $sql_extra3 .= " AND false "; - info(DI::l10n()->t('Group is empty')); + notice(DI::l10n()->t('Group is empty')); } $o = Renderer::replaceMacros(Renderer::getMarkupTemplate('section_title.tpl'), [ @@ -588,7 +583,7 @@ function networkThreadedView(App $a, $update, $parent) 'id' => 'network', 'name' => $contact['name'], 'itemurl' => ($contact['addr'] ?? '') ?: $contact['nurl'], - 'thumb' => ProxyUtils::proxifyUrl($contact['thumb'], false, ProxyUtils::SIZE_THUMB), + 'thumb' => Contact::getThumb($contact), 'details' => $contact['location'], ]; @@ -599,7 +594,7 @@ function networkThreadedView(App $a, $update, $parent) 'id' => 'network', ]) . $o; } else { - notice(DI::l10n()->t('Invalid contact.') . EOL); + notice(DI::l10n()->t('Invalid contact.')); DI::baseUrl()->redirect('network'); // NOTREACHED } @@ -739,78 +734,6 @@ function networkThreadedView(App $a, $update, $parent) ); } - // Only show it when unfiltered (no groups, no networks, ...) - if (in_array($nets, ['', Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS]) && (strlen($sql_extra . $sql_extra2 . $sql_extra3) == 0)) { - if (DBA::isResult($r)) { - $top_limit = current($r)['order_date']; - $bottom_limit = end($r)['order_date']; - if (empty($_SESSION['network_last_top_limit']) || ($_SESSION['network_last_top_limit'] < $top_limit)) { - $_SESSION['network_last_top_limit'] = $top_limit; - } - } else { - $top_limit = $bottom_limit = DateTimeFormat::utcNow(); - } - - // When checking for updates we need to fetch from the newest date to the newest date before - // Only do this, when the last stored date isn't too long ago (10 times the update interval) - $browser_update = DI::pConfig()->get(local_user(), 'system', 'update_interval', 40000) / 1000; - - if (($browser_update > 0) && $update && !empty($_SESSION['network_last_date']) && - (($bottom_limit < $_SESSION['network_last_date']) || ($top_limit == $bottom_limit)) && - ((time() - $_SESSION['network_last_date_timestamp']) < ($browser_update * 10))) { - $bottom_limit = $_SESSION['network_last_date']; - } - $_SESSION['network_last_date'] = Session::get('network_last_top_limit', $top_limit); - $_SESSION['network_last_date_timestamp'] = time(); - - if ($last_date > $top_limit) { - $top_limit = $last_date; - } elseif ($pager->getPage() == 1) { - // Highest possible top limit when we are on the first page - $top_limit = DateTimeFormat::utcNow(); - } - - // Handle bad performance situations when the distance between top and bottom is too high - // See issue https://github.com/friendica/friendica/issues/8619 - if (strtotime($top_limit) - strtotime($bottom_limit) > 86400) { - // Set the bottom limit to one day in the past at maximum - $bottom_limit = DateTimeFormat::utc(date('c', strtotime($top_limit) - 86400)); - } - - $items = DBA::p("SELECT `item`.`parent-uri` AS `uri`, 0 AS `item_id`, `item`.$ordering AS `order_date`, `author`.`url` AS `author-link` FROM `item` - STRAIGHT_JOIN (SELECT `uri-id` FROM `tag-search-view` WHERE `name` IN - (SELECT SUBSTR(`term`, 2) FROM `search` WHERE `uid` = ? AND `term` LIKE '#%') AND `uid` = 0) AS `tag-search` - ON `item`.`uri-id` = `tag-search`.`uri-id` - STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `item`.`author-id` - WHERE `item`.`uid` = 0 AND `item`.$ordering < ? AND `item`.$ordering > ? AND `item`.`gravity` = ? - AND NOT `author`.`hidden` AND NOT `author`.`blocked`" . $sql_tag_nets, - local_user(), $top_limit, $bottom_limit, GRAVITY_PARENT); - - $data = DBA::toArray($items); - - if (count($data) > 0) { - $tag_top_limit = current($data)['order_date']; - if ($_SESSION['network_last_date'] < $tag_top_limit) { - $_SESSION['network_last_date'] = $tag_top_limit; - } - - Logger::log('Tagged items: ' . count($data) . ' - ' . $bottom_limit . ' - ' . $top_limit . ' - ' . local_user().' - '.(int)$update); - $s = []; - foreach ($r as $item) { - $s[$item['uri']] = $item; - } - foreach ($data as $item) { - // Don't show hash tag posts from blocked or ignored contacts - $condition = ["`nurl` = ? AND `uid` = ? AND (`blocked` OR `readonly`)", - Strings::normaliseLink($item['author-link']), local_user()]; - if (!DBA::exists('contact', $condition)) { - $s[$item['uri']] = $item; - } - } - $r = $s; - } - } - $parents_str = ''; $date_offset = '';