Fix some issues
This commit is contained in:
parent
442e66d112
commit
de432cda88
@ -88,36 +88,43 @@ class apActorInboxAction extends ManagedAction
|
|||||||
ActivityPubReturn::error($e->getMessage(), 404);
|
ActivityPubReturn::error($e->getMessage(), 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$to_profiles = [$profile];
|
$cc = [$profile];
|
||||||
|
|
||||||
// Process request
|
// Process request
|
||||||
|
define('INBOX_HANDLERS', __DIR__ . DIRECTORY_SEPARATOR . 'inbox' . DIRECTORY_SEPARATOR);
|
||||||
switch ($data['type']) {
|
switch ($data['type']) {
|
||||||
case "Create":
|
// Data available:
|
||||||
require_once __DIR__ . DIRECTORY_SEPARATOR . "inbox" . DIRECTORY_SEPARATOR . "Create.php";
|
// Profile $actor_profile Actor performing the action
|
||||||
break;
|
// string|object $data->object Object to be handled
|
||||||
case "Delete":
|
// Array|String $cc Destinataries
|
||||||
require_once __DIR__ . DIRECTORY_SEPARATOR . "inbox" . DIRECTORY_SEPARATOR . "Delete.php";
|
// Profile $profile Local user to whom this action is directed
|
||||||
break;
|
case 'Create':
|
||||||
case "Follow":
|
$cc = array_merge ([$profile], $data['object']['cc']);
|
||||||
require_once __DIR__ . DIRECTORY_SEPARATOR . "inbox" . DIRECTORY_SEPARATOR . "Follow.php";
|
require_once INBOX_HANDLERS . 'Create.php';
|
||||||
break;
|
break;
|
||||||
case "Like":
|
case 'Follow':
|
||||||
require_once __DIR__ . DIRECTORY_SEPARATOR . "inbox" . DIRECTORY_SEPARATOR . "Like.php";
|
require_once INBOX_HANDLERS . 'Follow.php';
|
||||||
break;
|
break;
|
||||||
case "Undo":
|
case 'Like':
|
||||||
require_once __DIR__ . DIRECTORY_SEPARATOR . "inbox" . DIRECTORY_SEPARATOR . "Undo.php";
|
require_once INBOX_HANDLERS . 'Like.php';
|
||||||
break;
|
break;
|
||||||
case "Announce":
|
case 'Announce':
|
||||||
require_once __DIR__ . DIRECTORY_SEPARATOR . "inbox" . DIRECTORY_SEPARATOR . "Announce.php";
|
require_once INBOX_HANDLERS . 'Announce.php';
|
||||||
break;
|
break;
|
||||||
case "Accept":
|
case 'Undo':
|
||||||
require_once __DIR__ . DIRECTORY_SEPARATOR . "inbox" . DIRECTORY_SEPARATOR . "Accept.php";
|
require_once INBOX_HANDLERS . 'Undo.php';
|
||||||
break;
|
break;
|
||||||
case "Reject":
|
case 'Delete':
|
||||||
require_once __DIR__ . DIRECTORY_SEPARATOR . "inbox" . DIRECTORY_SEPARATOR . "Reject.php";
|
require_once INBOX_HANDLERS . 'Delete.php';
|
||||||
break;
|
break;
|
||||||
|
case 'Accept':
|
||||||
|
require_once INBOX_HANDLERS . 'Accept.php';
|
||||||
|
break;
|
||||||
|
case 'Reject':
|
||||||
|
require_once INBOX_HANDLERS . 'Reject.php';
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
ActivityPubReturn::error("Invalid type value.");
|
ActivityPubReturn::error('Invalid type value.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,39 +78,44 @@ class apSharedInboxAction extends ManagedAction
|
|||||||
ActivityPubReturn::error($e->getMessage(), 404);
|
ActivityPubReturn::error($e->getMessage(), 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$to_profiles = [];
|
$cc = [];
|
||||||
|
|
||||||
// Process request
|
// Process request
|
||||||
|
define('INBOX_HANDLERS', __DIR__ . DIRECTORY_SEPARATOR . 'inbox' . DIRECTORY_SEPARATOR);
|
||||||
switch ($data['type']) {
|
switch ($data['type']) {
|
||||||
// Data available:
|
// Data available:
|
||||||
// Profile $actor_profile
|
// Profile $actor_profile Actor performing the action
|
||||||
|
// string|object $data->object Object to be handled
|
||||||
|
// Array|String $cc Destinataries
|
||||||
// string|object $data->object
|
// string|object $data->object
|
||||||
case 'Create':
|
case 'Create':
|
||||||
require_once __DIR__ . DIRECTORY_SEPARATOR . 'inbox' . DIRECTORY_SEPARATOR . 'Create.php';
|
$cc = $data['object']['cc'];
|
||||||
break;
|
$res = $data['object'];
|
||||||
|
require_once INBOX_HANDLERS . 'Create.php';
|
||||||
|
break;
|
||||||
case 'Follow':
|
case 'Follow':
|
||||||
require_once __DIR__ . DIRECTORY_SEPARATOR . 'inbox' . DIRECTORY_SEPARATOR . 'Follow.php';
|
require_once INBOX_HANDLERS . 'Follow.php';
|
||||||
break;
|
break;
|
||||||
case 'Like':
|
case 'Like':
|
||||||
require_once __DIR__ . DIRECTORY_SEPARATOR . 'inbox' . DIRECTORY_SEPARATOR . 'Like.php';
|
require_once INBOX_HANDLERS . 'Like.php';
|
||||||
break;
|
break;
|
||||||
case 'Announce':
|
case 'Announce':
|
||||||
require_once __DIR__ . DIRECTORY_SEPARATOR . 'inbox' . DIRECTORY_SEPARATOR . 'Announce.php';
|
require_once INBOX_HANDLERS . 'Announce.php';
|
||||||
break;
|
break;
|
||||||
case 'Undo':
|
case 'Undo':
|
||||||
require_once __DIR__ . DIRECTORY_SEPARATOR . 'inbox' . DIRECTORY_SEPARATOR . 'Undo.php';
|
require_once INBOX_HANDLERS . 'Undo.php';
|
||||||
break;
|
break;
|
||||||
case 'Delete':
|
case 'Delete':
|
||||||
require_once __DIR__ . DIRECTORY_SEPARATOR . 'inbox' . DIRECTORY_SEPARATOR . 'Delete.php';
|
require_once INBOX_HANDLERS . 'Delete.php';
|
||||||
break;
|
break;
|
||||||
case 'Accept':
|
case 'Accept':
|
||||||
require_once __DIR__ . DIRECTORY_SEPARATOR . 'inbox' . DIRECTORY_SEPARATOR . 'Accept.php';
|
require_once INBOX_HANDLERS . 'Accept.php';
|
||||||
break;
|
break;
|
||||||
case 'Reject':
|
case 'Reject':
|
||||||
require_once __DIR__ . DIRECTORY_SEPARATOR . 'inbox' . DIRECTORY_SEPARATOR . 'Reject.php';
|
require_once INBOX_HANDLERS . 'Reject.php';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ActivityPubReturn::error('Invalid type value.');
|
ActivityPubReturn::error('Invalid type value.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,8 +31,6 @@ if (!defined('GNUSOCIAL')) {
|
|||||||
|
|
||||||
$valid_object_types = ['Note'];
|
$valid_object_types = ['Note'];
|
||||||
|
|
||||||
$res = $data['object'];
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Activitypub_notice::validate_remote_notice($res);
|
Activitypub_notice::validate_remote_notice($res);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
@ -61,7 +59,7 @@ try {
|
|||||||
$res['id'],
|
$res['id'],
|
||||||
$res['url'],
|
$res['url'],
|
||||||
$res['content'],
|
$res['content'],
|
||||||
$res['cc'],
|
$cc,
|
||||||
$settings
|
$settings
|
||||||
);
|
);
|
||||||
ActivityPubReturn::answer();
|
ActivityPubReturn::answer();
|
||||||
|
@ -144,13 +144,13 @@ class Activitypub_notice extends Managed_DataObject
|
|||||||
throw new UnsupportedMediaException('Downloaded image was not an image.');
|
throw new UnsupportedMediaException('Downloaded image was not an image.');
|
||||||
}
|
}
|
||||||
file_put_contents($temp_filename, $imgData);
|
file_put_contents($temp_filename, $imgData);
|
||||||
unset($imgData); // No need to carry this in memory.
|
|
||||||
common_debug('ActivityPub Create Notice: Stored dowloaded image in: '.$temp_filename);
|
common_debug('ActivityPub Create Notice: Stored dowloaded image in: '.$temp_filename);
|
||||||
|
|
||||||
$id = $actor_profile->getID();
|
$id = $actor_profile->getID();
|
||||||
|
|
||||||
$imagefile = new ImageFile(null, $temp_filename);
|
$imagefile = new ImageFile(null, $temp_filename);
|
||||||
$filename = hash(File::FILEHASH_ALG, $imgData).image_type_to_extension($imagefile->type);
|
$filename = hash(File::FILEHASH_ALG, $imgData).image_type_to_extension($imagefile->type);
|
||||||
|
unset($imgData); // No need to carry this in memory.
|
||||||
rename($temp_filename, File::path($filename));
|
rename($temp_filename, File::path($filename));
|
||||||
common_debug('ActivityPub Create Notice: Moved image from: '.$temp_filename.' to '.$filename);
|
common_debug('ActivityPub Create Notice: Moved image from: '.$temp_filename.' to '.$filename);
|
||||||
$mediaFile = new MediaFile($filename, $attach['mediaType']);
|
$mediaFile = new MediaFile($filename, $attach['mediaType']);
|
||||||
@ -186,7 +186,7 @@ class Activitypub_notice extends Managed_DataObject
|
|||||||
array_unique($cc);
|
array_unique($cc);
|
||||||
foreach ($cc as $cc_url) {
|
foreach ($cc as $cc_url) {
|
||||||
try {
|
try {
|
||||||
$cc_profiles = array_merge($cc_profiles, $discovery->lookup($cc_url));
|
$cc = array_merge($cc, $discovery->lookup($cc_url));
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
// Invalid actor found, just let it go. // TODO: Fallback to OStatus
|
// Invalid actor found, just let it go. // TODO: Fallback to OStatus
|
||||||
}
|
}
|
||||||
@ -195,7 +195,7 @@ class Activitypub_notice extends Managed_DataObject
|
|||||||
// No need to do anything else at this point, let's just break out the if
|
// No need to do anything else at this point, let's just break out the if
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
$cc_profiles = array_merge($cc_profiles, $discovery->lookup($cc));
|
$cc = array_merge($cc, $discovery->lookup($cc));
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
// Invalid actor found, just let it go. // TODO: Fallback to OStatus
|
// Invalid actor found, just let it go. // TODO: Fallback to OStatus
|
||||||
}
|
}
|
||||||
@ -203,7 +203,7 @@ class Activitypub_notice extends Managed_DataObject
|
|||||||
|
|
||||||
unset($discovery);
|
unset($discovery);
|
||||||
|
|
||||||
foreach ($cc_profiles as $tp) {
|
foreach ($cc as $tp) {
|
||||||
$act->context->attention[ActivityPubPlugin::actor_uri($tp)] = 'http://activitystrea.ms/schema/1.0/person';
|
$act->context->attention[ActivityPubPlugin::actor_uri($tp)] = 'http://activitystrea.ms/schema/1.0/person';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user