Fix Likes
This commit is contained in:
parent
8f6c120620
commit
e4a65130f8
@ -29,18 +29,14 @@ if (!defined('GNUSOCIAL')) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($data->object->id)) {
|
|
||||||
ActivityPubReturn::error("Id not specified.");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
$object_notice = ActivityPubPlugin::get_local_notice_from_url($data->object->id);
|
$object_notice = ActivityPubPlugin::get_local_notice_from_url($data->object);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
ActivityPubReturn::error("Invalid Object ID value.");
|
ActivityPubReturn::error("Invalid Object ID value.");
|
||||||
}
|
}
|
||||||
Fave::addNew($actor_profile, $object_notice);
|
Fave::addNew($actor_profile, $object_notice);
|
||||||
ActivityPubReturn::answer(Activitypub_like::like_to_array($data->actor, Activitypub_notice::notice_to_array($object_notice)));
|
ActivityPubReturn::answer(Activitypub_like::like_to_array($data->actor, $object_notice));
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
ActivityPubReturn::error($e->getMessage(), 403);
|
ActivityPubReturn::error($e->getMessage(), 403);
|
||||||
}
|
}
|
||||||
|
@ -50,11 +50,15 @@ class Activitypub_like extends Managed_DataObject
|
|||||||
*/
|
*/
|
||||||
public static function like_to_array($actor, $object)
|
public static function like_to_array($actor, $object)
|
||||||
{
|
{
|
||||||
$res = array("@context" => "https://www.w3.org/ns/activitystreams",
|
$res = [
|
||||||
|
'@context' => [
|
||||||
|
'https://www.w3.org/ns/activitystreams',
|
||||||
|
'https://w3id.org/security/v1'
|
||||||
|
],
|
||||||
"type" => "Like",
|
"type" => "Like",
|
||||||
"actor" => $actor,
|
"actor" => $actor,
|
||||||
"object" => $object
|
"object" => $object
|
||||||
);
|
];
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user