minor refactoring
This commit is contained in:
parent
d09db31145
commit
59752e549f
@ -63,7 +63,6 @@ class APInboxController extends Controller
|
|||||||
|
|
||||||
public function handle_undo (User $user, $activity)
|
public function handle_undo (User $user, $activity)
|
||||||
{
|
{
|
||||||
// TODO: This needs to be refactored
|
|
||||||
if (TypeActivity::activity_exists ($activity ["id"]))
|
if (TypeActivity::activity_exists ($activity ["id"]))
|
||||||
return response ()->json (["error" => "Activity already exists",], 409);
|
return response ()->json (["error" => "Activity already exists",], 409);
|
||||||
|
|
||||||
@ -74,27 +73,9 @@ class APInboxController extends Controller
|
|||||||
return response ()->json (["error" => "Child activity not found",], 404);
|
return response ()->json (["error" => "Child activity not found",], 404);
|
||||||
|
|
||||||
$child_activity = Activity::where ("activity_id", $child_activity ["id"])->first ();
|
$child_activity = Activity::where ("activity_id", $child_activity ["id"])->first ();
|
||||||
switch ($child_activity->type)
|
$child_activity->delete ();
|
||||||
{
|
|
||||||
case "Follow":
|
|
||||||
// TODO: Move this to its own function
|
|
||||||
// TODO: Should the accept activity be deleted?
|
|
||||||
$followed_user = TypeActor::actor_get_local ($child_activity ["object"]);
|
|
||||||
if (!$followed_user || !$followed_user->user)
|
|
||||||
return response ()->json (["error" => "Target not found",], 404);
|
|
||||||
|
|
||||||
$followed_user->user->friends -= 1;
|
// TODO: Should Undo create a new activity in database?
|
||||||
$followed_user->user->save ();
|
return response ()->json (["success" => "Activity undone",], 200);
|
||||||
|
|
||||||
$child_activity->delete ();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
Log::info ("Unknown activity type to Undo: " . $child_activity ["type"]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Should Undo create a new activity model?
|
|
||||||
return response ()->json (["error" => "Not implemented",], 501);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user