public static function sendContactSuggestion($uid, $inbox, $suggestion_id)
{
$owner = User::getOwnerDataById($uid);
- $profile = APContact::getByURL($owner['url']);
$suggestion = DBA::selectFirst('fsuggest', ['url', 'note', 'created'], ['id' => $suggestion_id]);
- $data = ['@context' => 'https://www.w3.org/ns/activitystreams',
+ $data = ['@context' => ActivityPub::CONTEXT,
'id' => System::baseUrl() . '/activity/' . System::createGUID(),
'type' => 'Announce',
'actor' => $owner['url'],
return HTTPSignature::transmit($signed, $inbox, $uid);
}
+ /**
+ * Transmits a profile relocation to a given inbox
+ *
+ * @param integer $uid User ID
+ * @param string $inbox Target inbox
+ *
+ * @return boolean was the transmission successful?
+ */
+ public static function sendProfileRelocation($uid, $inbox)
+ {
+ $owner = User::getOwnerDataById($uid);
+
+ $data = ['@context' => ActivityPub::CONTEXT,
+ 'id' => System::baseUrl() . '/activity/' . System::createGUID(),
+ 'type' => 'dfrn:relocate',
+ 'actor' => $owner['url'],
+ 'object' => $owner['url'],
+ 'published' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
+ 'instrument' => ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()],
+ 'to' => [ActivityPub::PUBLIC_COLLECTION],
+ 'cc' => []];
+
+ $signed = LDSignature::sign($data, $owner);
+
+ Logger::log('Deliver profile relocation for user ' . $uid . ' to ' . $inbox . ' via ActivityPub', Logger::DEBUG);
+ return HTTPSignature::transmit($signed, $inbox, $uid);
+ }
+
/**
* Transmits a profile deletion to a given inbox
*
public static function sendProfileDeletion($uid, $inbox)
{
$owner = User::getOwnerDataById($uid);
- $profile = APContact::getByURL($owner['url']);
- $data = ['@context' => 'https://www.w3.org/ns/activitystreams',
+ $data = ['@context' => ActivityPub::CONTEXT,
'id' => System::baseUrl() . '/activity/' . System::createGUID(),
'type' => 'Delete',
'actor' => $owner['url'],
$owner = User::getOwnerDataById($uid);
$profile = APContact::getByURL($owner['url']);
- $data = ['@context' => 'https://www.w3.org/ns/activitystreams',
+ $data = ['@context' => ActivityPub::CONTEXT,
'id' => System::baseUrl() . '/activity/' . System::createGUID(),
'type' => 'Update',
'actor' => $owner['url'],
$owner = User::getOwnerDataById($uid);
- $data = ['@context' => 'https://www.w3.org/ns/activitystreams',
+ $data = ['@context' => ActivityPub::CONTEXT,
'id' => System::baseUrl() . '/activity/' . System::createGUID(),
'type' => $activity,
'actor' => $owner['url'],
$profile = APContact::getByURL($target);
$owner = User::getOwnerDataById($uid);
- $data = ['@context' => 'https://www.w3.org/ns/activitystreams',
+ $data = ['@context' => ActivityPub::CONTEXT,
'id' => System::baseUrl() . '/activity/' . System::createGUID(),
'type' => 'Accept',
'actor' => $owner['url'],
$profile = APContact::getByURL($target);
$owner = User::getOwnerDataById($uid);
- $data = ['@context' => 'https://www.w3.org/ns/activitystreams',
+ $data = ['@context' => ActivityPub::CONTEXT,
'id' => System::baseUrl() . '/activity/' . System::createGUID(),
'type' => 'Reject',
'actor' => $owner['url'],
$id = System::baseUrl() . '/activity/' . System::createGUID();
$owner = User::getOwnerDataById($uid);
- $data = ['@context' => 'https://www.w3.org/ns/activitystreams',
+ $data = ['@context' => ActivityPub::CONTEXT,
'id' => $id,
'type' => 'Undo',
'actor' => $owner['url'],
$context = (object)['as' => 'https://www.w3.org/ns/activitystreams#',
'w3id' => 'https://w3id.org/security#',
+ 'ldp' => (object)['@id' => 'http://www.w3.org/ns/ldp#', '@type' => '@id'],
'vcard' => (object)['@id' => 'http://www.w3.org/2006/vcard/ns#', '@type' => '@id'],
- 'ostatus' => (object)['@id' => 'http://ostatus.org#', '@type' => '@id'],
+ 'dfrn' => (object)['@id' => 'http://purl.org/macgirvin/dfrn/1.0/', '@type' => '@id'],
'diaspora' => (object)['@id' => 'https://diasporafoundation.org/ns/', '@type' => '@id'],
- 'dc' => (object)['@id' => 'http://purl.org/dc/terms/', '@type' => '@id'],
- 'ldp' => (object)['@id' => 'http://www.w3.org/ns/ldp#', '@type' => '@id']];
+ 'ostatus' => (object)['@id' => 'http://ostatus.org#', '@type' => '@id'],
+ 'dc' => (object)['@id' => 'http://purl.org/dc/terms/', '@type' => '@id']];
$jsonobj = json_decode(json_encode($json, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));