[AP] Properly target public notices

ActivityPubPlugin:
- Use TO as principal audience, CC as secondary
- Update note validation
This commit is contained in:
tenma 2019-08-11 22:54:23 +01:00 committed by Diogo Peralta Cordeiro
parent 4a56a61094
commit 0d9606ffbf

View File

@ -61,14 +61,13 @@ 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',
@ -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;
} }