} elseif ($contact['network'] == Protocol::DIASPORA) {
Diaspora::sendUnshare($user, $contact);
} elseif ($contact['network'] == Protocol::ACTIVITYPUB) {
- ActivityPub::transmitContactActivity('Undo', $contact['url'], '', $user['uid']);
+ ActivityPub::transmitContactUndo($contact['url'], '', $user['uid']);
}
}
return;
}
- $url = $pub_contact['url'];
+ $url = defaults($datarray, 'author-link', $pub_contact['url']);
$name = $pub_contact['name'];
$photo = $pub_contact['photo'];
$nick = $pub_contact['nick'];
}
if ($contact['network'] == Protocol::ACTIVITYPUB) {
- ActivityPub::transmitContactActivity('Accept', $contact['url'], $contact['hub-verify'], $importer['uid']);
+ ActivityPub::transmitContactAccept($contact['url'], $contact['hub-verify'], $importer['uid']);
}
// send email notification to owner?
return self::transmit($data, $profile['notify'], $uid);
}
- public static function transmitContactActivity($activity, $target, $id, $uid)
+ public static function transmitContactAccept($target, $id, $uid)
+ {
+ $profile = Probe::uri($target, Protocol::ACTIVITYPUB);
+
+ $owner = User::getOwnerDataById($uid);
+ $data = ['@context' => 'https://www.w3.org/ns/activitystreams',
+ 'id' => 'https://pirati.ca/activity/' . System::createGUID(),
+ 'type' => 'Accept',
+ 'actor' => $owner['url'],
+ 'object' => ['id' => $id, 'type' => 'Follow',
+ 'actor' => $profile['url'],
+ 'object' => $owner['url']]];
+
+ logger('Sending accept to ' . $target . ' for user ' . $uid . ' with id ' . $id, LOGGER_DEBUG);
+ return self::transmit($data, $profile['notify'], $uid);
+ }
+
+ public static function transmitContactUndo($target, $id, $uid)
{
$profile = Probe::uri($target, Protocol::ACTIVITYPUB);
$owner = User::getOwnerDataById($uid);
$data = ['@context' => 'https://www.w3.org/ns/activitystreams',
'id' => 'https://pirati.ca/activity/' . System::createGUID(),
- 'type' => $activity,
+ 'type' => 'Undo',
'actor' => $owner['url'],
'object' => ['id' => $id, 'type' => 'Follow',
'actor' => $owner['url'],
'object' => $profile['url']]];
- logger('Sending ' . $activity . ' to ' . $target . ' for user ' . $uid . ' with id ' . $id, LOGGER_DEBUG);
+ logger('Sending undo to ' . $target . ' for user ' . $uid . ' with id ' . $id, LOGGER_DEBUG);
return self::transmit($data, $profile['notify'], $uid);
}
$contact = false;
}
- $item = ['author-id' => Contact::getIdForURL($activity['owner'])];
+ $item = ['author-id' => Contact::getIdForURL($activity['owner']),
+ 'author-link' => $activity['owner']];
Contact::addRelationship($owner, $contact, $item);
-
$cid = Contact::getIdForURL($activity['owner'], $uid);
if (empty($cid)) {
return;