X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FAPContact.php;h=6a8e5b3ae1c78e39433c1d25543fab4a02718616;hb=deb6b7a7c3d62a42e2f71a3adf7ba3689e741f5a;hp=d31aa5d3727f4eecebdbb6d7e9f0841b37d310b8;hpb=a852455d0ed9824fb71c9374c9fffda28f95096f;p=friendica.git diff --git a/src/Model/APContact.php b/src/Model/APContact.php index d31aa5d372..6a8e5b3ae1 100644 --- a/src/Model/APContact.php +++ b/src/Model/APContact.php @@ -22,8 +22,11 @@ namespace Friendica\Model; use Friendica\Content\Text\HTML; +use Friendica\Core\Cache\Duration; use Friendica\Core\Logger; +use Friendica\Core\System; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Network\Probe; use Friendica\Protocol\ActivityNamespace; use Friendica\Protocol\ActivityPub; @@ -40,7 +43,7 @@ class APContact * @param string $addr Address * @return array webfinger data */ - public static function fetchWebfingerData(string $addr) + private static function fetchWebfingerData(string $addr) { $addr_parts = explode('@', $addr); if (count($addr_parts) != 2) { @@ -154,6 +157,16 @@ class APContact return $fetched_contact; } + // Detect multiple fast repeating request to the same address + // See https://github.com/friendica/friendica/issues/9303 + $cachekey = 'apcontact:getByURL:' . $url; + $result = DI::cache()->get($cachekey); + if (!is_null($result)) { + Logger::notice('Multiple requests for the address', ['url' => $url, 'update' => $update, 'callstack' => System::callstack(20), 'result' => $result]); + } else { + DI::cache()->set($cachekey, System::callstack(20), Duration::FIVE_MINUTES); + } + $apcontact['url'] = $compacted['@id']; $apcontact['uuid'] = JsonLD::fetchElement($compacted, 'diaspora:guid', '@value'); $apcontact['type'] = str_replace('as:', '', JsonLD::fetchElement($compacted, '@type'));