Wrong notice id on creation which is making AP Notice grabber fail

This commit is contained in:
Diogo Cordeiro 2018-08-01 03:58:47 +01:00
parent 30affa954f
commit ec49aee44b
2 changed files with 12 additions and 14 deletions

View File

@ -87,7 +87,7 @@ class apSharedInboxAction extends ManagedAction
'as:Public' 'as:Public'
]; ];
$to_profiles = 'https://www.w3.org/ns/activitystreams#Public'; $to_profiles = ['https://www.w3.org/ns/activitystreams#Public'];
// Process request // Process request
switch ($data->type) { switch ($data->type) {

View File

@ -29,27 +29,27 @@ if (!defined('GNUSOCIAL')) {
exit(1); exit(1);
} }
$valid_object_types = array("Note"); $valid_object_types = ['Note'];
// Validate data // Validate data
if (!isset($data->object->id)) { if (!isset($data->object->id)) {
ActivityPubReturn::error("Object ID not specified."); ActivityPubReturn::error('Object ID not specified.');
} elseif (!filter_var($data->object->id, FILTER_VALIDATE_URL)) { } elseif (!filter_var($data->object->id, FILTER_VALIDATE_URL)) {
ActivityPubReturn::error("Invalid Object ID."); ActivityPubReturn::error('Invalid Object ID.');
} }
if (!(isset($data->object->type) && in_array($data->object->type, $valid_object_types))) { if (!(isset($data->object->type) && in_array($data->object->type, $valid_object_types))) {
ActivityPubReturn::error("Invalid Object type."); ActivityPubReturn::error('Invalid Object type.');
} }
if (!isset($data->object->content)) { if (!isset($data->object->content)) {
ActivityPubReturn::error("Object content was not specified."); ActivityPubReturn::error('Object content was not specified.');
} }
if (!isset($data->object->url)) { if (!isset($data->object->url)) {
ActivityPubReturn::error("Object url was not specified."); ActivityPubReturn::error('Object url was not specified.');
} elseif (!filter_var($data->object->url, FILTER_VALIDATE_URL)) { } elseif (!filter_var($data->object->url, FILTER_VALIDATE_URL)) {
ActivityPubReturn::error("Invalid Object URL."); ActivityPubReturn::error('Invalid Object URL.');
} }
if (!isset($data->object->to)) { if (!isset($data->object->to)) {
ActivityPubReturn::error("Object To was not specified."); ActivityPubReturn::error('Object To was not specified.');
} }
$content = $data->object->content; $content = $data->object->content;
@ -74,10 +74,9 @@ if (isset($data->object->inReplyTo)) {
$inReplyTo = null; $inReplyTo = null;
} }
$act->context->attention = common_get_attentions($content, $actor_profile, $inReplyTo);
$discovery = new Activitypub_explorer; $discovery = new Activitypub_explorer;
if ($to_profiles == "https://www.w3.org/ns/activitystreams#Public") {
if ($to_profiles == ['https://www.w3.org/ns/activitystreams#Public']) {
$to_profiles = []; $to_profiles = [];
} }
@ -114,12 +113,11 @@ if (isset($data->object->latitude, $data->object->longitude)) {
} }
// Reject notice if it is too long (without the HTML) // Reject notice if it is too long (without the HTML)
// This is done after MediaFile::fromUpload etc. just to act the same as the ApiStatusesUpdateAction
if (Notice::contentTooLong($content)) { if (Notice::contentTooLong($content)) {
ActivityPubReturn::error("That's too long. Maximum notice size is %d character."); ActivityPubReturn::error("That's too long. Maximum notice size is %d character.");
} }
$options = array('source' => 'ActivityPub', 'uri' => isset($data->id) ? $data->id : $data->object->url, 'url' => $data->object->url); $options = array('source' => 'ActivityPub', 'uri' => isset($data->id) ? $data->id : $data->object->id, 'url' => $data->object->url);
// $options gets filled with possible scoping settings // $options gets filled with possible scoping settings
ToSelector::fillActivity($this, $act, $options); ToSelector::fillActivity($this, $act, $options);