mirror of
https://github.com/friendica/friendica
synced 2025-04-22 11:10:11 +00:00
AP: Support for "move" and "accept" from gup.pe
This commit is contained in:
parent
02bca72de3
commit
9fe70af85a
2 changed files with 77 additions and 11 deletions
|
@ -1733,6 +1733,38 @@ class Processor
|
|||
Queue::remove($activity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add moved contacts as followers for all subscribers of the old contact
|
||||
*
|
||||
* @param array $activity
|
||||
* @return void
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public static function movePerson(array $activity)
|
||||
{
|
||||
if (empty($activity['target_id']) || empty($activity['object_id'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($activity['object_id'] != $activity['actor']) {
|
||||
Logger::notice('Object is not the actor', ['activity' => $activity]);
|
||||
return;
|
||||
}
|
||||
|
||||
$from = Contact::getByURL($activity['object_id'], false, ['uri-id']);
|
||||
if (empty($from['uri-id'])) {
|
||||
Logger::info('Object not found', ['activity' => $activity]);
|
||||
return;
|
||||
}
|
||||
|
||||
$contacts = DBA::select('contact', ['uid', 'url'], ["`uri-id` = ? AND `uid` != ? AND `rel` IN (?, ?)", $from['uri-id'], 0, Contact::FRIEND, Contact::SHARING]);
|
||||
while ($from_contact = DBA::fetch($contacts)) {
|
||||
$result = Contact::createFromProbeForUser($from_contact['uid'], $activity['target_id']);
|
||||
Logger::debug('Follower added', ['from' => $from_contact, 'result' => $result]);
|
||||
}
|
||||
DBA::close($contacts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Blocks the user by the contact
|
||||
*
|
||||
|
@ -1792,17 +1824,38 @@ class Processor
|
|||
*/
|
||||
public static function acceptFollowUser(array $activity)
|
||||
{
|
||||
$uid = User::getIdForURL($activity['object_actor']);
|
||||
if (!empty($activity['object_actor'])) {
|
||||
$uid = User::getIdForURL($activity['object_actor']);
|
||||
$check_id = false;
|
||||
} elseif (!empty($activity['receiver']) && (count($activity['receiver']) == 1)) {
|
||||
$uid = array_shift($activity['receiver']);
|
||||
$check_id = true;
|
||||
}
|
||||
|
||||
if (empty($uid)) {
|
||||
Logger::notice('User could not be detected', ['activity' => $activity]);
|
||||
Queue::remove($activity);
|
||||
return;
|
||||
}
|
||||
|
||||
$cid = Contact::getIdForURL($activity['actor'], $uid);
|
||||
if (empty($cid)) {
|
||||
Logger::info('No contact found', ['actor' => $activity['actor']]);
|
||||
Logger::notice('No contact found', ['actor' => $activity['actor']]);
|
||||
Queue::remove($activity);
|
||||
return;
|
||||
}
|
||||
|
||||
$id = Transmitter::activityIDFromContact($cid);
|
||||
if ($id == $activity['object_id']) {
|
||||
Logger::info('Successful id check', ['uid' => $uid, 'cid' => $cid]);
|
||||
} else {
|
||||
Logger::info('Unsuccessful id check', ['uid' => $uid, 'cid' => $cid, 'id' => $id, 'object_id' => $activity['object_id']]);
|
||||
if ($check_id) {
|
||||
Queue::remove($activity);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
self::switchContact($cid);
|
||||
|
||||
$fields = ['pending' => false];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue