<?php
/**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2022, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
namespace Friendica\Module;
use Friendica\BaseModule;
+use Friendica\Core\Cache\Enum\Duration;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Database\DBA;
*/
class NoScrape extends BaseModule
{
- public function rawContent()
+ const CACHEKEY = 'noscrape:';
+
+ protected function rawContent(array $request = [])
{
$a = DI::app();
- if (isset(static::$parameters['nick'])) {
+ if (isset($this->parameters['nick'])) {
// Get infos about a specific nick (public)
- $which = static::$parameters['nick'];
- } elseif (local_user() && isset(static::$parameters['profile']) && DI::args()->get(2) == 'view') {
+ $which = $this->parameters['nick'];
+ } elseif (local_user() && isset($this->parameters['profile']) && DI::args()->get(2) == 'view') {
// view infos about a known profile (needs a login)
$which = $a->getLoggedInUserNickname();
} else {
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,
}
}
+ DI::cache()->set($cachekey, $json_info, Duration::DAY);
+
System::jsonExit($json_info);
}
}