Add Undo Announce entry point
This commit is contained in:
parent
6e55a72179
commit
133066b9ac
@ -871,9 +871,10 @@ class ActivityPubReturn
|
|||||||
*
|
*
|
||||||
* @author Diogo Cordeiro <diogo@fc.up.pt>
|
* @author Diogo Cordeiro <diogo@fc.up.pt>
|
||||||
* @param array $res
|
* @param array $res
|
||||||
|
* @param int 32 $code Status Code
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function answer($res, $code = 200)
|
public static function answer($res = '', $code = 202)
|
||||||
{
|
{
|
||||||
http_response_code($code);
|
http_response_code($code);
|
||||||
header('Content-Type: application/activity+json');
|
header('Content-Type: application/activity+json');
|
||||||
@ -886,7 +887,7 @@ class ActivityPubReturn
|
|||||||
*
|
*
|
||||||
* @author Diogo Cordeiro <diogo@fc.up.pt>
|
* @author Diogo Cordeiro <diogo@fc.up.pt>
|
||||||
* @param string $m
|
* @param string $m
|
||||||
* @param int32 $code
|
* @param int32 $code Status Code
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function error($m, $code = 500)
|
public static function error($m, $code = 500)
|
||||||
|
@ -31,15 +31,15 @@ if (!defined('GNUSOCIAL')) {
|
|||||||
|
|
||||||
// Validate data
|
// Validate data
|
||||||
if (!isset($data->type)) {
|
if (!isset($data->type)) {
|
||||||
ActivityPubReturn::error("Type was not specified.");
|
ActivityPubReturn::error('Type was not specified.');
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($data->object->type) {
|
switch ($data->object->type) {
|
||||||
case "Like":
|
case 'Like':
|
||||||
try {
|
try {
|
||||||
// Validate data
|
// Validate data
|
||||||
if (!isset($data->object->object)) {
|
if (!isset($data->object->object)) {
|
||||||
ActivityPubReturn::error("Notice URI was not specified.");
|
ActivityPubReturn::error('Notice URI was not specified.');
|
||||||
}
|
}
|
||||||
Fave::removeEntry($actor_profile, ActivityPubPlugin::get_local_notice_from_url($data->object->object));
|
Fave::removeEntry($actor_profile, ActivityPubPlugin::get_local_notice_from_url($data->object->object));
|
||||||
// Notice disfavorited successfully.
|
// Notice disfavorited successfully.
|
||||||
@ -55,17 +55,17 @@ case "Like":
|
|||||||
ActivityPubReturn::error($e->getMessage(), 403);
|
ActivityPubReturn::error($e->getMessage(), 403);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "Follow":
|
case 'Follow':
|
||||||
// Validate data
|
// Validate data
|
||||||
if (!isset($data->object->object)) {
|
if (!isset($data->object->object)) {
|
||||||
ActivityPubReturn::error("Object Actor URL was not specified.");
|
ActivityPubReturn::error('Object Actor URL was not specified.');
|
||||||
}
|
}
|
||||||
// Get valid Object profile
|
// Get valid Object profile
|
||||||
try {
|
try {
|
||||||
$object_profile = new Activitypub_explorer;
|
$object_profile = new Activitypub_explorer;
|
||||||
$object_profile = $object_profile->lookup($data->object->object)[0];
|
$object_profile = $object_profile->lookup($data->object->object)[0];
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
ActivityPubReturn::error("Invalid Object Actor URL.", 404);
|
ActivityPubReturn::error('Invalid Object Actor URL.', 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Subscription::exists($actor_profile, $object_profile)) {
|
if (Subscription::exists($actor_profile, $object_profile)) {
|
||||||
@ -82,10 +82,12 @@ case "Follow":
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
ActivityPubReturn::error("You are not following this person already.", 409);
|
ActivityPubReturn::error('You are not following this person already.', 409);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'Announce':
|
||||||
|
ActivityPubReturn::answer(); // TODO: Implement Undo Announce
|
||||||
default:
|
default:
|
||||||
ActivityPubReturn::error("Invalid object type.");
|
ActivityPubReturn::error('Invalid object type.');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user