friendica/src/Worker/APDelivery.php
Adam Magness 14fde5dc9b Log function
implement log() function.
2018-10-30 09:57:14 -04:00

50 lines
1.3 KiB
PHP

<?php
/**
* @file src/Worker/APDelivery.php
*/
namespace Friendica\Worker;
use Friendica\BaseObject;
use Friendica\Core\Logger;
use Friendica\Core\Worker;
use Friendica\Protocol\ActivityPub;
use Friendica\Model\Item;
use Friendica\Util\HTTPSignature;
class APDelivery extends BaseObject
{
/**
* @brief Delivers ActivityPub messages
*
* @param string $cmd
* @param integer $item_id
* @param string $inbox
* @param integer $uid
*/
public static function execute($cmd, $item_id, $inbox, $uid)
{
Logger::log('Invoked: ' . $cmd . ': ' . $item_id . ' to ' . $inbox, LOGGER_DEBUG);
$success = true;
if ($cmd == Delivery::MAIL) {
} elseif ($cmd == Delivery::SUGGESTION) {
$success = ActivityPub\Transmitter::sendContactSuggestion($uid, $inbox, $item_id);
} elseif ($cmd == Delivery::RELOCATION) {
} elseif ($cmd == Delivery::REMOVAL) {
$success = ActivityPub\Transmitter::sendProfileDeletion($uid, $inbox);
} elseif ($cmd == Delivery::PROFILEUPDATE) {
$success = ActivityPub\Transmitter::sendProfileUpdate($uid, $inbox);
} else {
$data = ActivityPub\Transmitter::createCachedActivityFromItem($item_id);
if (!empty($data)) {
$success = HTTPSignature::transmit($data, $inbox, $uid);
}
}
if (!$success) {
Worker::defer();
}
}
}