X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FNoScrape.php;h=f5c5c725e0344928cca6bbd0f745f94025f0faed;hb=8165fb80910560cef86f78ae7a52c7131f5ad3f5;hp=e3a01ceaab6d29467d47ceda5c4a0afc1fad9e55;hpb=8b7cb5d9efeab580c2592e0fbe301f7142b73a3d;p=friendica.git diff --git a/src/Module/NoScrape.php b/src/Module/NoScrape.php index e3a01ceaab..f5c5c725e0 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 = $this->parameters['nick']; - } elseif (local_user() && isset($this->parameters['profile']) && DI::args()->get(2) == 'view') { + } 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 { @@ -58,12 +54,6 @@ class NoScrape extends BaseModule System::jsonError(404, 'Profile not found'); } - $cachekey = self::CACHEKEY . $owner['uid']; - $result = DI::cache()->get($cachekey); - if (!is_null($result)) { - System::jsonExit($result); - } - $json_info = [ 'addr' => $owner['addr'], 'nick' => $which, @@ -98,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); @@ -135,8 +107,6 @@ class NoScrape extends BaseModule } } - DI::cache()->set($cachekey, $json_info, Duration::DAY); - System::jsonExit($json_info); } }