[ActivityPub] Properly handle Actor URIs by using events correctly

This should fix nulls on explorer lookups inputed by postman after generate_followers/getSubscribers, that I think were caused by calling common_profile_uri that, curiously, only handles local profiles
This commit is contained in:
Diogo Cordeiro
2019-12-10 22:27:32 +00:00
parent b730582336
commit 80ba2b3ccc
13 changed files with 37 additions and 66 deletions

View File

@@ -36,7 +36,7 @@ class HttpSignature
$key = openssl_pkey_get_private($actor_private_key);
openssl_sign($stringToSign, $signature, $key, OPENSSL_ALGO_SHA256);
$signature = base64_encode($signature);
$signatureHeader = 'keyId="' . ActivityPubPlugin::actor_uri($user).'#public-key' . '",headers="' . $signedHeaders . '",algorithm="rsa-sha256",signature="' . $signature . '"';
$signatureHeader = 'keyId="' . $user->getUri() . '#public-key' . '",headers="' . $signedHeaders . '",algorithm="rsa-sha256",signature="' . $signature . '"';
unset($headers['(request-target)']);
$headers['Signature'] = $signatureHeader;

View File

@@ -46,7 +46,7 @@ class Activitypub_announce
*/
public static function announce_to_array(Profile $actor, Notice $notice): array
{
$actor_uri = ActivityPubPlugin::actor_uri($actor);
$actor_uri = $actor->getUri();
$notice_url = Activitypub_notice::getUrl($notice);
$to = [common_local_url('apActorFollowers', ['id' => $actor->getID()])];

View File

@@ -85,13 +85,13 @@ class Activitypub_follow
if (!Subscription::exists($actor_profile, $object_profile)) {
Subscription::start($actor_profile, $object_profile);
Activitypub_profile::subscribeCacheUpdate($actor_profile, $object_profile);
common_debug('ActivityPubPlugin: Accepted Follow request from '.ActivityPubPlugin::actor_uri($actor_profile).' to '.$object);
common_debug('ActivityPubPlugin: Accepted Follow request from '.$actor_profile->getUri().' to '.$object);
} else {
common_debug('ActivityPubPlugin: Received a repeated Follow request from '.ActivityPubPlugin::actor_uri($actor_profile).' to '.$object);
common_debug('ActivityPubPlugin: Received a repeated Follow request from '.$actor_profile->getUri().' to '.$object);
}
// Notify remote instance that we have accepted their request
common_debug('ActivityPubPlugin: Notifying remote instance that we have accepted their Follow request request from '.ActivityPubPlugin::actor_uri($actor_profile).' to '.$object);
common_debug('ActivityPubPlugin: Notifying remote instance that we have accepted their Follow request request from '.$actor_profile->getUri().' to '.$object);
$postman = new Activitypub_postman($object_profile, [$actor_aprofile]);
$postman->accept_follow($id);
}

View File

@@ -63,7 +63,7 @@ class Activitypub_message
'id' => common_local_url('showmessage', ['message' => $message->getID()]),
'type' => 'Note',
'published' => str_replace(' ', 'T', $message->created).'Z',
'attributedTo' => ActivityPubPlugin::actor_uri($from),
'attributedTo' => $from->getUri(),
'to' => $to,
'cc' => [],
'content' => $message->getRendered(),

View File

@@ -85,7 +85,7 @@ class Activitypub_notice
'type' => 'Note',
'published' => str_replace(' ', 'T', $notice->getCreated()) . 'Z',
'url' => self::getUrl($notice),
'attributedTo' => ActivityPubPlugin::actor_uri($profile),
'attributedTo' => $profile->getUri(),
'to' => $to,
'cc' => $cc,
'conversation' => $notice->getConversationUrl(),
@@ -205,7 +205,7 @@ class Activitypub_notice
foreach ($mentions_profiles as $mp) {
if (!$mp->hasBlocked($actor_profile)) {
$act->context->attention[ActivityPubPlugin::actor_uri($mp)] = 'http://activitystrea.ms/schema/1.0/person';
$act->context->attention[$mp->getUri()] = 'http://activitystrea.ms/schema/1.0/person';
}
}

View File

@@ -58,7 +58,7 @@ class Activitypub_postman
$this->actor = $from;
$this->to = $to;
$this->actor_uri = ActivityPubPlugin::actor_uri($this->actor);
$this->actor_uri = $this->actor->getUri();
$this->client = new HTTPClient();
}
@@ -364,7 +364,7 @@ class Activitypub_postman
public function delete_note($notice)
{
$data = Activitypub_delete::delete_to_array(
ActivityPubPlugin::actor_uri($notice->getProfile()),
$notice->getProfile()->getUri(),
Activitypub_notice::getUrl($notice)
);
$errors = [];