Merge pull request #11790 from annando/fetchactivity

Negative caching / config for receiver / fix fatals
This commit is contained in:
Hypolite Petovan
2022-07-28 17:29:34 -04:00
committed by GitHub
5 changed files with 21 additions and 7 deletions
+3 -3
View File
@@ -352,11 +352,11 @@ class Photo extends BaseModule
}
if (empty($mimetext)) {
if ($customsize <= Proxy::PIXEL_MICRO) {
$url = Contact::getDefaultAvatar($contact, Proxy::SIZE_MICRO);
$url = Contact::getDefaultAvatar($contact ?: [], Proxy::SIZE_MICRO);
} elseif ($customsize <= Proxy::PIXEL_THUMB) {
$url = Contact::getDefaultAvatar($contact, Proxy::SIZE_THUMB);
$url = Contact::getDefaultAvatar($contact ?: [], Proxy::SIZE_THUMB);
} else {
$url = Contact::getDefaultAvatar($contact, Proxy::SIZE_SMALL);
$url = Contact::getDefaultAvatar($contact ?: [], Proxy::SIZE_SMALL);
}
}
return MPhoto::createPhotoForExternalResource($url, 0, $mimetext);
+8 -2
View File
@@ -303,7 +303,7 @@ class Processor
if (empty($activity['directmessage']) && ($activity['id'] != $activity['reply-to-id']) && !Post::exists(['uri' => $activity['reply-to-id']])) {
$recursion_depth = $activity['recursion-depth'] ?? 0;
Logger::notice('Parent not found. Try to refetch it.', ['parent' => $activity['reply-to-id'], 'recursion-depth' => $recursion_depth]);
if ($recursion_depth < 10) {
if ($recursion_depth < DI::config()->get('system', 'max_recursion_depth')) {
$result = self::fetchMissingActivity($activity['reply-to-id'], $activity, '', Receiver::COMPLETION_AUTO);
if (empty($result) && self::isActivityGone($activity['reply-to-id'])) {
// Recursively delete this and all depending entries
@@ -1207,13 +1207,19 @@ class Processor
$object = DI::cache()->get($cachekey);
if (!is_null($object)) {
Logger::debug('Fetch from cache', ['url' => $url, 'uid' => $uid]);
if (!empty($object)) {
Logger::debug('Fetch from cache', ['url' => $url, 'uid' => $uid]);
} else {
Logger::debug('Fetch from negative cache', ['url' => $url, 'uid' => $uid]);
}
return $object;
}
$object = ActivityPub::fetchContent($url, $uid);
if (empty($object)) {
Logger::notice('Activity was not fetchable, aborting.', ['url' => $url, 'uid' => $uid]);
// We perform negative caching.
DI::cache()->set($cachekey, [], Duration::FIVE_MINUTES);
return [];
}
+1 -1
View File
@@ -592,7 +592,7 @@ class Receiver
return;
}
if (!empty($object_data['entry-id']) && ($push || ($activity['completion-mode'] == self::COMPLETION_RELAY))) {
if (!empty($object_data['entry-id']) && DI::config()->get('system', 'decoupled_receiver') && ($push || ($activity['completion-mode'] == self::COMPLETION_RELAY))) {
// We delay by 5 seconds to allow to accumulate all receivers
$delayed = date(DateTimeFormat::MYSQL, time() + 5);
Logger::debug('Initiate processing', ['id' => $object_data['entry-id'], 'uri' => $object_data['object_id']]);
+1 -1
View File
@@ -3114,7 +3114,7 @@ class Diaspora
Logger::notice('Empty addr', ['contact' => $contact ?? [], 'callstack' => System::callstack(20)]);
}
$envelope = self::buildMessage($msg, $owner, $contact, $owner['uprvkey'], $pubkey, $public_batch);
$envelope = self::buildMessage($msg, $owner, $contact, $owner['uprvkey'], $pubkey ?? '', $public_batch);
$return_code = self::transmit($owner, $contact, $envelope, $public_batch, $guid);