mirror of
https://github.com/friendica/friendica
synced 2025-04-30 16:24:24 +02:00
Improved asynchronous message procession
This commit is contained in:
parent
c88b1c0197
commit
a1947d2bb1
8 changed files with 46 additions and 38 deletions
|
@ -3905,11 +3905,12 @@ class Item
|
|||
* Fetches item for given URI or plink
|
||||
*
|
||||
* @param string $uri
|
||||
* @param integer $uid
|
||||
* @param int $uid
|
||||
* @param int $completion
|
||||
*
|
||||
* @return integer item id
|
||||
*/
|
||||
public static function fetchByLink(string $uri, int $uid = 0): int
|
||||
public static function fetchByLink(string $uri, int $uid = 0, int $completion = ActivityPub\Receiver::COMPLETION_MANUAL): int
|
||||
{
|
||||
Logger::info('Trying to fetch link', ['uid' => $uid, 'uri' => $uri]);
|
||||
$item_id = self::searchByLink($uri, $uid);
|
||||
|
@ -3930,7 +3931,7 @@ class Item
|
|||
return is_numeric($hookData['item_id']) ? $hookData['item_id'] : 0;
|
||||
}
|
||||
|
||||
$fetched_uri = ActivityPub\Processor::fetchMissingActivity($uri, [], '', ActivityPub\Receiver::COMPLETION_MANUAL, $uid);
|
||||
$fetched_uri = ActivityPub\Processor::fetchMissingActivity($uri, [], '', $completion, $uid);
|
||||
|
||||
if ($fetched_uri) {
|
||||
$item_id = self::searchByLink($fetched_uri, $uid);
|
||||
|
@ -3990,7 +3991,7 @@ class Item
|
|||
}
|
||||
|
||||
$url = $shared['message_id'] ?: $shared['link'];
|
||||
$id = self::fetchByLink($url);
|
||||
$id = self::fetchByLink($url, 0, ActivityPub\Receiver::COMPLETION_ASYNC);
|
||||
if (!$id) {
|
||||
Logger::notice('Post could not be fetched.', ['url' => $url, 'uid' => $uid]);
|
||||
return 0;
|
||||
|
|
|
@ -35,6 +35,7 @@ use Friendica\Model\Photo;
|
|||
use Friendica\Model\Post;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientOptions;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
use Friendica\Util\Images;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\ParseUrl;
|
||||
|
@ -253,7 +254,7 @@ class Media
|
|||
*/
|
||||
private static function addActivity(array $media): array
|
||||
{
|
||||
$id = Item::fetchByLink($media['url']);
|
||||
$id = Item::fetchByLink($media['url'], 0, ActivityPub\Receiver::COMPLETION_ASYNC);
|
||||
if (empty($id)) {
|
||||
return $media;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue