[AP] Properly target public notices
ActivityPubPlugin: - Use TO as principal audience, CC as secondary - Update note validation
This commit is contained in:
parent
4a56a61094
commit
0d9606ffbf
|
@ -61,29 +61,28 @@ class Activitypub_notice
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$cc = [common_local_url('apActorFollowers', ['id' => $profile->getID()])];
|
$to = ['https://www.w3.org/ns/activitystreams#Public'];
|
||||||
foreach ($notice->getAttentionProfiles() as $to_profile) {
|
foreach ($notice->getAttentionProfiles() as $to_profile) {
|
||||||
$cc[] = $href = $to_profile->getUri();
|
$to[] = $href = $to_profile->getUri();
|
||||||
$tags[] = Activitypub_mention_tag::mention_tag_to_array_from_values($href, $to_profile->getNickname().'@'.parse_url($href, PHP_URL_HOST));
|
$tags[] = Activitypub_mention_tag::mention_tag_to_array_from_values($href, $to_profile->getNickname().'@'.parse_url($href, PHP_URL_HOST));
|
||||||
}
|
}
|
||||||
|
|
||||||
// In a world without walls and fences, we should make everything Public!
|
$cc = [common_local_url('apActorFollowers', ['id' => $profile->getID()])];
|
||||||
$to[]= 'https://www.w3.org/ns/activitystreams#Public';
|
|
||||||
|
|
||||||
$item = [
|
$item = [
|
||||||
'@context' => 'https://www.w3.org/ns/activitystreams',
|
'@context' => 'https://www.w3.org/ns/activitystreams',
|
||||||
'id' => self::getUrl($notice),
|
'id' => self::getUrl($notice),
|
||||||
'type' => 'Note',
|
'type' => 'Note',
|
||||||
'published' => str_replace(' ', 'T', $notice->getCreated()).'Z',
|
'published' => str_replace(' ', 'T', $notice->getCreated()).'Z',
|
||||||
'url' => self::getUrl($notice),
|
'url' => self::getUrl($notice),
|
||||||
'attributedTo' => ActivityPubPlugin::actor_uri($profile),
|
'attributedTo' => ActivityPubPlugin::actor_uri($profile),
|
||||||
'to' => $to,
|
'to' => $to,
|
||||||
'cc' => $cc,
|
'cc' => $cc,
|
||||||
'conversation' => $notice->getConversationUrl(),
|
'conversation' => $notice->getConversationUrl(),
|
||||||
'content' => $notice->getRendered(),
|
'content' => $notice->getRendered(),
|
||||||
'isLocal' => $notice->isLocal(),
|
'isLocal' => $notice->isLocal(),
|
||||||
'attachment' => $attachments,
|
'attachment' => $attachments,
|
||||||
'tag' => $tags
|
'tag' => $tags
|
||||||
];
|
];
|
||||||
|
|
||||||
// Is this a reply?
|
// Is this a reply?
|
||||||
|
@ -239,9 +238,9 @@ class Activitypub_notice
|
||||||
common_debug('ActivityPub Notice Validator: Rejected because Object URL is invalid.');
|
common_debug('ActivityPub Notice Validator: Rejected because Object URL is invalid.');
|
||||||
throw new Exception('Invalid Object URL.');
|
throw new Exception('Invalid Object URL.');
|
||||||
}
|
}
|
||||||
if (!isset($object['cc'])) {
|
if (!(isset($object['to']) || isset($object['cc']))) {
|
||||||
common_debug('ActivityPub Notice Validator: Rejected because Object CC was not specified.');
|
common_debug('ActivityPub Notice Validator: Rejected because neither Object CC and TO were specified.');
|
||||||
throw new Exception('Object CC was not specified.');
|
throw new Exception('Neither Object CC and TO were specified.');
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user