*
* @return array of follower inboxes
*/
- private static function fetchTargetInboxesforUser($uid)
+ public static function fetchTargetInboxesforUser($uid)
{
$inboxes = [];
}
/**
- * @brief Transmits a profile change to the followers
+ * @brief Transmits a profile change to a given inbox
*
* @param integer $uid User ID
+ * @param string $inbox Target inbox
*/
- public static function transmitProfileUpdate($uid)
+ public static function transmitProfileUpdate($uid, $inbox)
{
$owner = User::getOwnerDataById($uid);
$profile = APContact::getByURL($owner['url']);
'to' => [$profile['followers']],
'cc' => []];
- logger('Sending profile update to followers for user ' . $uid, LOGGER_DEBUG);
-
$signed = LDSignature::sign($data, $owner);
- $inboxes = self::fetchTargetInboxesforUser($uid);
-
- foreach ($inboxes as $inbox) {
- logger('Deliver profile update for user ' . $uid . ' to ' . $inbox .' via ActivityPub', LOGGER_DEBUG);
- HTTPSignature::transmit($signed, $inbox, $uid);
- }
+ logger('Deliver profile update for user ' . $uid . ' to ' . $inbox .' via ActivityPub', LOGGER_DEBUG);
+ HTTPSignature::transmit($signed, $inbox, $uid);
}
+
/**
* @brief Transmits a given activity to a target
*
*
* @return
*/
- private static function processObject(&$object)
+ private static function processObject($object)
{
if (empty($object['id'])) {
return false;
if ($cmd == Delivery::MAIL) {
} elseif ($cmd == Delivery::SUGGESTION) {
} elseif ($cmd == Delivery::RELOCATION) {
+ } elseif ($cmd == Delivery::PROFILEUPDATE) {
+ ActivityPub::transmitProfileUpdate($uid, $inbox);
} else {
$data = ActivityPub::createActivityFromItem($item_id);
if (!empty($data)) {
class Delivery extends BaseObject
{
- const MAIL = 'mail';
- const SUGGESTION = 'suggest';
- const RELOCATION = 'relocate';
- const DELETION = 'drop';
- const POST = 'wall-new';
- const COMMENT = 'comment-new';
- const REMOVAL = 'removeme';
+ const MAIL = 'mail';
+ const SUGGESTION = 'suggest';
+ const RELOCATION = 'relocate';
+ const DELETION = 'drop';
+ const POST = 'wall-new';
+ const COMMENT = 'comment-new';
+ const REMOVAL = 'removeme';
+ const PROFILEUPDATE = 'profileupdate';
public static function execute($cmd, $item_id, $contact_id)
{
namespace Friendica\Worker;
+use Friendica\BaseObject;
use Friendica\Protocol\Diaspora;
use Friendica\Protocol\ActivityPub;
+use Friendica\Core\Worker;
class ProfileUpdate {
public static function execute($uid = 0) {
return;
}
- ActivityPub::transmitProfileUpdate($uid);
+ $a = BaseObject::getApp();
+
+ $inboxes = ActivityPub::fetchTargetInboxesforUser($uid);
+
+ foreach ($inboxes as $inbox) {
+ logger('Profile update for user ' . $uid . ' to ' . $inbox .' via ActivityPub', LOGGER_DEBUG);
+ Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true],
+ 'APDelivery', Delivery::PROFILEUPDATE, '', $inbox, $uid);
+ }
+
Diaspora::sendProfile($uid);
}
}