[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 Cordeiro
parent 48cacd6d9d
commit 7188d81ad4

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) {
$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));
}
// In a world without walls and fences, we should make everything Public!
$to[]= 'https://www.w3.org/ns/activitystreams#Public';
$cc = [common_local_url('apActorFollowers', ['id' => $profile->getID()])];
$item = [
'@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.');
throw new Exception('Invalid Object URL.');
}
if (!isset($object['cc'])) {
common_debug('ActivityPub Notice Validator: Rejected because Object CC was not specified.');
throw new Exception('Object CC was not specified.');
if (!(isset($object['to']) || isset($object['cc']))) {
common_debug('ActivityPub Notice Validator: Rejected because neither Object CC and TO were specified.');
throw new Exception('Neither Object CC and TO were specified.');
}
return true;
}