X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FNoScrape.php;h=c4138ed709db5c2c0191a3bd2b3134993f4ffe3d;hb=3bca4fe2a64671d09e08346456cdfa6c12f996e9;hp=2530038969679eee6136259fd071d460af385002;hpb=7cdd2d1336e768def2f9b2dc1d4026f8d9bb3804;p=friendica.git diff --git a/src/Module/NoScrape.php b/src/Module/NoScrape.php index 2530038969..c4138ed709 100644 --- a/src/Module/NoScrape.php +++ b/src/Module/NoScrape.php @@ -1,6 +1,6 @@ parameters['nick'])) { // Get infos about a specific nick (public) - $which = $parameters['nick']; - } elseif (local_user() && isset($parameters['profile']) && DI::args()->get(2) == 'view') { + $which = $this->parameters['nick']; + } elseif (DI::userSession()->getLocalUserId() && isset($this->parameters['profile']) && DI::args()->get(2) == 'view') { // view infos about a known profile (needs a login) $which = $a->getLoggedInUserNickname(); } else { - System::jsonError(403, 'Authentication required'); + $this->jsonError(403, 'Authentication required'); } $owner = User::getOwnerDataByNick($which); if (empty($owner['uid'])) { - System::jsonError(404, 'Profile not found'); + $this->jsonError(404, 'Profile not found'); } $json_info = [ @@ -72,7 +71,7 @@ class NoScrape extends BaseModule if (!$owner['net-publish']) { $json_info['hide'] = true; - System::jsonExit($json_info); + $this->jsonExit($json_info); } $keywords = $owner['pub_keywords'] ?? ''; @@ -89,32 +88,14 @@ class NoScrape extends BaseModule } if (!($owner['hide-friends'] ?? false)) { - $json_info['contacts'] = DBA::count('contact', - [ - 'uid' => $owner['uid'], - 'self' => 0, - 'blocked' => 0, - 'pending' => 0, - 'hidden' => 0, - 'archive' => 0, - 'network' => [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS] - ]); + $apcontact = APContact::getByURL($owner['url']); + $json_info['contacts'] = max($apcontact['following_count'], $apcontact['followers_count']); } // We display the last activity (post or login), reduced to year and week number - $last_active = 0; - $condition = ['uid' => $owner['uid'], 'self' => true]; - $contact = DBA::selectFirst('contact', ['last-item'], $condition); - if (DBA::isResult($contact)) { - $last_active = strtotime($contact['last-item']); - } - - $condition = ['uid' => $owner['uid']]; - $user = DBA::selectFirst('user', ['login_date'], $condition); - if (DBA::isResult($user)) { - if ($last_active < strtotime($user['login_date'])) { - $last_active = strtotime($user['login_date']); - } + $last_active = strtotime($owner['last-item']); + if ($owner['last-activity'] && $last_active < strtotime($owner['last-activity'])) { + $last_active = strtotime($owner['last-activity']); } $json_info['last-activity'] = date('o-W', $last_active); @@ -122,10 +103,10 @@ class NoScrape extends BaseModule $profile_fields = ['about', 'locality', 'region', 'postal-code', 'country-name', 'xmpp', 'matrix']; foreach ($profile_fields as $field) { if (!empty($owner[$field])) { - $json_info["$field"] = $owner[$field]; + $json_info[$field] = $owner[$field]; } } - System::jsonExit($json_info); + $this->jsonExit($json_info); } }