Profile update is now done via APDelivery
This commit is contained in:
parent
93ccca5807
commit
72c3a62e7f
|
@ -437,7 +437,7 @@ class ActivityPub
|
||||||
*
|
*
|
||||||
* @return array of follower inboxes
|
* @return array of follower inboxes
|
||||||
*/
|
*/
|
||||||
private static function fetchTargetInboxesforUser($uid)
|
public static function fetchTargetInboxesforUser($uid)
|
||||||
{
|
{
|
||||||
$inboxes = [];
|
$inboxes = [];
|
||||||
|
|
||||||
|
@ -732,11 +732,12 @@ class ActivityPub
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Transmits a profile change to the followers
|
* @brief Transmits a profile change to a given inbox
|
||||||
*
|
*
|
||||||
* @param integer $uid User ID
|
* @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);
|
$owner = User::getOwnerDataById($uid);
|
||||||
$profile = APContact::getByURL($owner['url']);
|
$profile = APContact::getByURL($owner['url']);
|
||||||
|
@ -750,17 +751,12 @@ class ActivityPub
|
||||||
'to' => [$profile['followers']],
|
'to' => [$profile['followers']],
|
||||||
'cc' => []];
|
'cc' => []];
|
||||||
|
|
||||||
logger('Sending profile update to followers for user ' . $uid, LOGGER_DEBUG);
|
|
||||||
|
|
||||||
$signed = LDSignature::sign($data, $owner);
|
$signed = LDSignature::sign($data, $owner);
|
||||||
|
|
||||||
$inboxes = self::fetchTargetInboxesforUser($uid);
|
logger('Deliver profile update for user ' . $uid . ' to ' . $inbox .' via ActivityPub', LOGGER_DEBUG);
|
||||||
|
HTTPSignature::transmit($signed, $inbox, $uid);
|
||||||
foreach ($inboxes as $inbox) {
|
|
||||||
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
|
* @brief Transmits a given activity to a target
|
||||||
*
|
*
|
||||||
|
@ -1403,7 +1399,7 @@ class ActivityPub
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static function processObject(&$object)
|
private static function processObject($object)
|
||||||
{
|
{
|
||||||
if (empty($object['id'])) {
|
if (empty($object['id'])) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -18,6 +18,8 @@ class APDelivery extends BaseObject
|
||||||
if ($cmd == Delivery::MAIL) {
|
if ($cmd == Delivery::MAIL) {
|
||||||
} elseif ($cmd == Delivery::SUGGESTION) {
|
} elseif ($cmd == Delivery::SUGGESTION) {
|
||||||
} elseif ($cmd == Delivery::RELOCATION) {
|
} elseif ($cmd == Delivery::RELOCATION) {
|
||||||
|
} elseif ($cmd == Delivery::PROFILEUPDATE) {
|
||||||
|
ActivityPub::transmitProfileUpdate($uid, $inbox);
|
||||||
} else {
|
} else {
|
||||||
$data = ActivityPub::createActivityFromItem($item_id);
|
$data = ActivityPub::createActivityFromItem($item_id);
|
||||||
if (!empty($data)) {
|
if (!empty($data)) {
|
||||||
|
|
|
@ -22,13 +22,14 @@ require_once 'include/items.php';
|
||||||
|
|
||||||
class Delivery extends BaseObject
|
class Delivery extends BaseObject
|
||||||
{
|
{
|
||||||
const MAIL = 'mail';
|
const MAIL = 'mail';
|
||||||
const SUGGESTION = 'suggest';
|
const SUGGESTION = 'suggest';
|
||||||
const RELOCATION = 'relocate';
|
const RELOCATION = 'relocate';
|
||||||
const DELETION = 'drop';
|
const DELETION = 'drop';
|
||||||
const POST = 'wall-new';
|
const POST = 'wall-new';
|
||||||
const COMMENT = 'comment-new';
|
const COMMENT = 'comment-new';
|
||||||
const REMOVAL = 'removeme';
|
const REMOVAL = 'removeme';
|
||||||
|
const PROFILEUPDATE = 'profileupdate';
|
||||||
|
|
||||||
public static function execute($cmd, $item_id, $contact_id)
|
public static function execute($cmd, $item_id, $contact_id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,8 +6,10 @@
|
||||||
|
|
||||||
namespace Friendica\Worker;
|
namespace Friendica\Worker;
|
||||||
|
|
||||||
|
use Friendica\BaseObject;
|
||||||
use Friendica\Protocol\Diaspora;
|
use Friendica\Protocol\Diaspora;
|
||||||
use Friendica\Protocol\ActivityPub;
|
use Friendica\Protocol\ActivityPub;
|
||||||
|
use Friendica\Core\Worker;
|
||||||
|
|
||||||
class ProfileUpdate {
|
class ProfileUpdate {
|
||||||
public static function execute($uid = 0) {
|
public static function execute($uid = 0) {
|
||||||
|
@ -15,7 +17,16 @@ class ProfileUpdate {
|
||||||
return;
|
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);
|
Diaspora::sendProfile($uid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user