[ActivityPub] attributedTo itself is not required, if not present then it should be inferred from the actor

Reported by kaniini
This commit is contained in:
Diogo Cordeiro 2019-10-11 17:51:17 +01:00
parent b12c2d17d5
commit 6284b155b8

View File

@ -142,7 +142,13 @@ class Activitypub_notice
// Ensure Actor Profile
if (is_null($actor_profile)) {
if (isset($object['attributedTo'])) {
$actor_profile = ActivityPub_explorer::get_profile_from_url($object['attributedTo']);
} elseif (isset($object['actor'])) {
$actor_profile = ActivityPub_explorer::get_profile_from_url($object['actor']);
} else {
throw new Exception("A notice can't be created without an actor.");
}
}
$act = new Activity();
@ -234,10 +240,6 @@ class Activitypub_notice
*/
public static function validate_note($object)
{
if (!isset($object['attributedTo'])) {
common_debug('ActivityPub Notice Validator: Rejected because attributedTo was not specified.');
throw new Exception('No attributedTo specified.');
}
if (!isset($object['id'])) {
common_debug('ActivityPub Notice Validator: Rejected because Object ID was not specified.');
throw new Exception('Object ID not specified.');
@ -250,7 +252,7 @@ class Activitypub_notice
throw new Exception('Invalid Object type.');
}
if (!isset($object['content'])) {
common_debug('ActivityPub Notice Validator: Rejected because Content was not specified.');
common_debug('ActivityPub Notice Validator: Rejected because Content was not specified (GNU social requires content in notes).');
throw new Exception('Object content was not specified.');
}
if (isset($object['url']) && !filter_var($object['url'], FILTER_VALIDATE_URL)) {