Merge pull request #7060 from annando/ap-connect
Preparation for switching the connect mechanism from DFRN to AP
This commit is contained in:
commit
33689a8d4e
|
@ -24,6 +24,7 @@ use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
|
use Friendica\Model\APContact;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\Group;
|
use Friendica\Model\Group;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
|
@ -143,6 +144,14 @@ function dfrn_confirm_post(App $a, $handsfree = null)
|
||||||
$network = $contact['network'];
|
$network = $contact['network'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// an empty DFRN-ID tells us that it had been a request via AP from a Friendica contact
|
||||||
|
if (($network === Protocol::DFRN) && empty($dfrn_id) && !empty($contact['hub-verify'])) {
|
||||||
|
$apcontact = APContact::getByURL($contact['url']);
|
||||||
|
if (!empty($apcontact)) {
|
||||||
|
$network = Protocol::ACTIVITYPUB;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($network === Protocol::DFRN) {
|
if ($network === Protocol::DFRN) {
|
||||||
/*
|
/*
|
||||||
* Generate a key pair for all further communications with this person.
|
* Generate a key pair for all further communications with this person.
|
||||||
|
|
|
@ -187,6 +187,18 @@ class Transmitter
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the service array containing information the used software and it's url
|
||||||
|
*
|
||||||
|
* @return array with service data
|
||||||
|
*/
|
||||||
|
private static function getService()
|
||||||
|
{
|
||||||
|
return ['type' => 'Service',
|
||||||
|
'name' => FRIENDICA_PLATFORM . " '" . FRIENDICA_CODENAME . "' " . FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION,
|
||||||
|
'url' => BaseObject::getApp()->getBaseURL()];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the ActivityPub profile of the given user
|
* Return the ActivityPub profile of the given user
|
||||||
*
|
*
|
||||||
|
@ -243,6 +255,8 @@ class Transmitter
|
||||||
$data['icon'] = ['type' => 'Image',
|
$data['icon'] = ['type' => 'Image',
|
||||||
'url' => $contact['avatar']];
|
'url' => $contact['avatar']];
|
||||||
|
|
||||||
|
$data['generator'] = self::getService();
|
||||||
|
|
||||||
// tags: https://kitty.town/@inmysocks/100656097926961126.json
|
// tags: https://kitty.town/@inmysocks/100656097926961126.json
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
@ -741,7 +755,7 @@ class Transmitter
|
||||||
|
|
||||||
$data['published'] = DateTimeFormat::utc($item['created'] . '+00:00', DateTimeFormat::ATOM);
|
$data['published'] = DateTimeFormat::utc($item['created'] . '+00:00', DateTimeFormat::ATOM);
|
||||||
|
|
||||||
$data['instrument'] = ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()];
|
$data['instrument'] = self::getService();
|
||||||
|
|
||||||
$data = array_merge($data, self::createPermissionBlockForItem($item, false));
|
$data = array_merge($data, self::createPermissionBlockForItem($item, false));
|
||||||
|
|
||||||
|
@ -1199,7 +1213,7 @@ class Transmitter
|
||||||
'actor' => $owner['url'],
|
'actor' => $owner['url'],
|
||||||
'object' => $suggestion['url'],
|
'object' => $suggestion['url'],
|
||||||
'content' => $suggestion['note'],
|
'content' => $suggestion['note'],
|
||||||
'instrument' => ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()],
|
'instrument' => self::getService(),
|
||||||
'to' => [ActivityPub::PUBLIC_COLLECTION],
|
'to' => [ActivityPub::PUBLIC_COLLECTION],
|
||||||
'cc' => []];
|
'cc' => []];
|
||||||
|
|
||||||
|
@ -1228,7 +1242,7 @@ class Transmitter
|
||||||
'actor' => $owner['url'],
|
'actor' => $owner['url'],
|
||||||
'object' => $owner['url'],
|
'object' => $owner['url'],
|
||||||
'published' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
|
'published' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
|
||||||
'instrument' => ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()],
|
'instrument' => self::getService(),
|
||||||
'to' => [ActivityPub::PUBLIC_COLLECTION],
|
'to' => [ActivityPub::PUBLIC_COLLECTION],
|
||||||
'cc' => []];
|
'cc' => []];
|
||||||
|
|
||||||
|
@ -1267,7 +1281,7 @@ class Transmitter
|
||||||
'actor' => $owner['url'],
|
'actor' => $owner['url'],
|
||||||
'object' => $owner['url'],
|
'object' => $owner['url'],
|
||||||
'published' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
|
'published' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
|
||||||
'instrument' => ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()],
|
'instrument' => self::getService(),
|
||||||
'to' => [ActivityPub::PUBLIC_COLLECTION],
|
'to' => [ActivityPub::PUBLIC_COLLECTION],
|
||||||
'cc' => []];
|
'cc' => []];
|
||||||
|
|
||||||
|
@ -1298,7 +1312,7 @@ class Transmitter
|
||||||
'actor' => $owner['url'],
|
'actor' => $owner['url'],
|
||||||
'object' => self::getProfile($uid),
|
'object' => self::getProfile($uid),
|
||||||
'published' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
|
'published' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
|
||||||
'instrument' => ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()],
|
'instrument' => self::getService(),
|
||||||
'to' => [$profile['followers']],
|
'to' => [$profile['followers']],
|
||||||
'cc' => []];
|
'cc' => []];
|
||||||
|
|
||||||
|
@ -1334,7 +1348,7 @@ class Transmitter
|
||||||
'type' => $activity,
|
'type' => $activity,
|
||||||
'actor' => $owner['url'],
|
'actor' => $owner['url'],
|
||||||
'object' => $profile['url'],
|
'object' => $profile['url'],
|
||||||
'instrument' => ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()],
|
'instrument' => self::getService(),
|
||||||
'to' => [$profile['url']]];
|
'to' => [$profile['url']]];
|
||||||
|
|
||||||
Logger::log('Sending activity ' . $activity . ' to ' . $target . ' for user ' . $uid, Logger::DEBUG);
|
Logger::log('Sending activity ' . $activity . ' to ' . $target . ' for user ' . $uid, Logger::DEBUG);
|
||||||
|
@ -1383,7 +1397,7 @@ class Transmitter
|
||||||
'type' => 'Follow',
|
'type' => 'Follow',
|
||||||
'actor' => $owner['url'],
|
'actor' => $owner['url'],
|
||||||
'object' => $object,
|
'object' => $object,
|
||||||
'instrument' => ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()],
|
'instrument' => self::getService(),
|
||||||
'to' => [$profile['url']]];
|
'to' => [$profile['url']]];
|
||||||
|
|
||||||
Logger::log('Sending follow ' . $object . ' to ' . $target . ' for user ' . $uid, Logger::DEBUG);
|
Logger::log('Sending follow ' . $object . ' to ' . $target . ' for user ' . $uid, Logger::DEBUG);
|
||||||
|
@ -1413,7 +1427,7 @@ class Transmitter
|
||||||
'object' => ['id' => $id, 'type' => 'Follow',
|
'object' => ['id' => $id, 'type' => 'Follow',
|
||||||
'actor' => $profile['url'],
|
'actor' => $profile['url'],
|
||||||
'object' => $owner['url']],
|
'object' => $owner['url']],
|
||||||
'instrument' => ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()],
|
'instrument' => self::getService(),
|
||||||
'to' => [$profile['url']]];
|
'to' => [$profile['url']]];
|
||||||
|
|
||||||
Logger::log('Sending accept to ' . $target . ' for user ' . $uid . ' with id ' . $id, Logger::DEBUG);
|
Logger::log('Sending accept to ' . $target . ' for user ' . $uid . ' with id ' . $id, Logger::DEBUG);
|
||||||
|
@ -1443,7 +1457,7 @@ class Transmitter
|
||||||
'object' => ['id' => $id, 'type' => 'Follow',
|
'object' => ['id' => $id, 'type' => 'Follow',
|
||||||
'actor' => $profile['url'],
|
'actor' => $profile['url'],
|
||||||
'object' => $owner['url']],
|
'object' => $owner['url']],
|
||||||
'instrument' => ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()],
|
'instrument' => self::getService(),
|
||||||
'to' => [$profile['url']]];
|
'to' => [$profile['url']]];
|
||||||
|
|
||||||
Logger::log('Sending reject to ' . $target . ' for user ' . $uid . ' with id ' . $id, Logger::DEBUG);
|
Logger::log('Sending reject to ' . $target . ' for user ' . $uid . ' with id ' . $id, Logger::DEBUG);
|
||||||
|
@ -1480,7 +1494,7 @@ class Transmitter
|
||||||
'object' => ['id' => $object_id, 'type' => 'Follow',
|
'object' => ['id' => $object_id, 'type' => 'Follow',
|
||||||
'actor' => $owner['url'],
|
'actor' => $owner['url'],
|
||||||
'object' => $profile['url']],
|
'object' => $profile['url']],
|
||||||
'instrument' => ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()],
|
'instrument' => self::getService(),
|
||||||
'to' => [$profile['url']]];
|
'to' => [$profile['url']]];
|
||||||
|
|
||||||
Logger::log('Sending undo to ' . $target . ' for user ' . $uid . ' with id ' . $id, Logger::DEBUG);
|
Logger::log('Sending undo to ' . $target . ' for user ' . $uid . ' with id ' . $id, Logger::DEBUG);
|
||||||
|
|
Loading…
Reference in a new issue