Prevent loop also when fetching the outbox
This commit is contained in:
parent
596bb9fa7c
commit
d8bf9c4601
|
@ -148,6 +148,19 @@ class APContact
|
|||
$url = $apcontact['url'];
|
||||
}
|
||||
|
||||
// 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]);
|
||||
if (!empty($fetched_contact)) {
|
||||
return $fetched_contact;
|
||||
}
|
||||
} else {
|
||||
DI::cache()->set($cachekey, System::callstack(20), Duration::FIVE_MINUTES);
|
||||
}
|
||||
|
||||
$curlResult = HTTPSignature::fetchRaw($url);
|
||||
$failed = empty($curlResult) || empty($curlResult->getBody()) ||
|
||||
(!$curlResult->isSuccess() && ($curlResult->getReturnCode() != 410));
|
||||
|
@ -171,16 +184,6 @@ 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'));
|
||||
|
|
|
@ -235,7 +235,7 @@ class Transmitter
|
|||
*/
|
||||
public static function getOutbox($owner, $page = null, $requester = '')
|
||||
{
|
||||
$public_contact = Contact::getIdForURL($owner['url']);
|
||||
$public_contact = Contact::getIdForURL($owner['url'], 0, false);
|
||||
$condition = ['uid' => 0, 'contact-id' => $public_contact,
|
||||
'private' => [Item::PUBLIC, Item::UNLISTED]];
|
||||
|
||||
|
|
Loading…
Reference in a new issue