mirror of
https://github.com/friendica/friendica
synced 2025-05-05 15:04:09 +02:00
Clarify usage of ActivityPub\Transmitter::fetchTargetInboxes in Worker\APDelivery queuing
- $inbox is now always a string - $receivers should be correctly populated now - $target_id is renamed to $item_id and correctly initialized to 0 for non-item deliveries
This commit is contained in:
parent
e4228c6218
commit
d59fcd5093
3 changed files with 19 additions and 41 deletions
|
@ -34,58 +34,36 @@ class APDelivery
|
|||
/**
|
||||
* Delivers ActivityPub messages
|
||||
*
|
||||
* @param string $cmd
|
||||
* @param integer $target_id
|
||||
* @param string|array $inboxes
|
||||
* @param integer $uid
|
||||
* @param array $receivers
|
||||
* @param string $cmd One of the Worker\Delivery constant values
|
||||
* @param integer $item_id 0 if no item is involved (like Delivery::REMOVAL and Delivery::PROFILEUPDATE)
|
||||
* @param string $inbox The URL of the recipient profile
|
||||
* @param integer $uid The ID of the user who triggered this delivery
|
||||
* @param array $receivers The contact IDs related to the inbox URL for contact archival housekeeping
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public static function execute(string $cmd, int $target_id, $inboxes, int $uid, array $receivers = [])
|
||||
{
|
||||
if (is_string($inboxes)) {
|
||||
$inboxes = [$inboxes];
|
||||
}
|
||||
|
||||
foreach ($inboxes as $inbox) {
|
||||
self::perform($cmd, $target_id, $inbox, $uid, $receivers);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delivers ActivityPub messages
|
||||
*
|
||||
* @param string $cmd
|
||||
* @param integer $target_id
|
||||
* @param string $inbox
|
||||
* @param integer $uid
|
||||
* @param array $receivers
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
private static function perform(string $cmd, int $target_id, string $inbox, int $uid, array $receivers = [])
|
||||
public static function execute(string $cmd, int $item_id, string $inbox, int $uid, array $receivers = [])
|
||||
{
|
||||
if (ActivityPub\Transmitter::archivedInbox($inbox)) {
|
||||
Logger::info('Inbox is archived', ['cmd' => $cmd, 'inbox' => $inbox, 'id' => $target_id, 'uid' => $uid]);
|
||||
Logger::info('Inbox is archived', ['cmd' => $cmd, 'inbox' => $inbox, 'id' => $item_id, 'uid' => $uid]);
|
||||
if (in_array($cmd, [Delivery::POST])) {
|
||||
$item = Item::selectFirst(['uri-id'], ['id' => $target_id]);
|
||||
$item = Item::selectFirst(['uri-id'], ['id' => $item_id]);
|
||||
Post\DeliveryData::incrementQueueFailed($item['uri-id'] ?? 0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Logger::info('Invoked', ['cmd' => $cmd, 'inbox' => $inbox, 'id' => $target_id, 'uid' => $uid]);
|
||||
Logger::info('Invoked', ['cmd' => $cmd, 'inbox' => $inbox, 'id' => $item_id, 'uid' => $uid]);
|
||||
|
||||
$success = true;
|
||||
|
||||
if ($cmd == Delivery::MAIL) {
|
||||
$data = ActivityPub\Transmitter::createActivityFromMail($target_id);
|
||||
$data = ActivityPub\Transmitter::createActivityFromMail($item_id);
|
||||
if (!empty($data)) {
|
||||
$success = HTTPSignature::transmit($data, $inbox, $uid);
|
||||
}
|
||||
} elseif ($cmd == Delivery::SUGGESTION) {
|
||||
$success = ActivityPub\Transmitter::sendContactSuggestion($uid, $inbox, $target_id);
|
||||
$success = ActivityPub\Transmitter::sendContactSuggestion($uid, $inbox, $item_id);
|
||||
} elseif ($cmd == Delivery::RELOCATION) {
|
||||
// @todo Implementation pending
|
||||
} elseif ($cmd == Delivery::POKE) {
|
||||
|
@ -95,14 +73,14 @@ class APDelivery
|
|||
} elseif ($cmd == Delivery::PROFILEUPDATE) {
|
||||
$success = ActivityPub\Transmitter::sendProfileUpdate($uid, $inbox);
|
||||
} else {
|
||||
$data = ActivityPub\Transmitter::createCachedActivityFromItem($target_id);
|
||||
$data = ActivityPub\Transmitter::createCachedActivityFromItem($item_id);
|
||||
if (!empty($data)) {
|
||||
$success = HTTPSignature::transmit($data, $inbox, $uid);
|
||||
}
|
||||
}
|
||||
|
||||
// This should never fail and is temporariy (until the move to the "post" structure)
|
||||
$item = Item::selectFirst(['uri-id'], ['id' => $target_id]);
|
||||
$item = Item::selectFirst(['uri-id'], ['id' => $item_id]);
|
||||
$uriid = $item['uri-id'] ?? 0;
|
||||
|
||||
foreach ($receivers as $receiver) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue