3 * @file src/Worker/APDelivery.php
5 namespace Friendica\Worker;
7 use Friendica\Core\Logger;
8 use Friendica\Core\Worker;
9 use Friendica\Model\ItemDeliveryData;
10 use Friendica\Protocol\ActivityPub;
11 use Friendica\Util\HTTPSignature;
16 * @brief Delivers ActivityPub messages
19 * @param integer $target_id
20 * @param string $inbox
22 * @throws \Friendica\Network\HTTPException\InternalServerErrorException
23 * @throws \ImagickException
25 public static function execute($cmd, $target_id, $inbox, $uid)
27 Logger::log('Invoked: ' . $cmd . ': ' . $target_id . ' to ' . $inbox, Logger::DEBUG);
31 if ($cmd == Delivery::MAIL) {
32 $data = ActivityPub\Transmitter::createActivityFromMail($target_id);
34 $success = HTTPSignature::transmit($data, $inbox, $uid);
36 } elseif ($cmd == Delivery::SUGGESTION) {
37 $success = ActivityPub\Transmitter::sendContactSuggestion($uid, $inbox, $target_id);
38 } elseif ($cmd == Delivery::RELOCATION) {
39 // @todo Implementation pending
40 } elseif ($cmd == Delivery::POKE) {
41 // Implementation not planned
42 } elseif ($cmd == Delivery::REMOVAL) {
43 $success = ActivityPub\Transmitter::sendProfileDeletion($uid, $inbox);
44 } elseif ($cmd == Delivery::PROFILEUPDATE) {
45 $success = ActivityPub\Transmitter::sendProfileUpdate($uid, $inbox);
47 $data = ActivityPub\Transmitter::createCachedActivityFromItem($target_id);
49 $success = HTTPSignature::transmit($data, $inbox, $uid);
53 if (!$success && !Worker::defer() && in_array($cmd, [Delivery::POST])) {
54 ItemDeliveryData::incrementQueueFailed($target_id);
55 } elseif ($success && in_array($cmd, [Delivery::POST])) {
56 ItemDeliveryData::incrementQueueDone($target_id, ItemDeliveryData::ACTIVITYPUB);