From 4d7f8450d9a842e2f69754ccaa4202710328dcb7 Mon Sep 17 00:00:00 2001 From: winter Date: Tue, 14 Jan 2025 20:44:49 +0000 Subject: add (un)follow button to profile also other stuff i forgot what exactly --- routes/actor_profile_fragment.php | 23 +++++++++++++++++++++++ routes/webfinger.php | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 routes/actor_profile_fragment.php (limited to 'routes') diff --git a/routes/actor_profile_fragment.php b/routes/actor_profile_fragment.php new file mode 100644 index 0000000..9b864d9 --- /dev/null +++ b/routes/actor_profile_fragment.php @@ -0,0 +1,23 @@ +mount('/fragment/actor/:id/followButton', function (array $args) { + $user = UserAccount::requireByCurrentSession(); + $actor = Actor::find($args['id']); + + if ($user->actor->follows($actor)) { + // already following, therefore unfollow + $user->actor->unfollow($actor); + } elseif ($user->actor->followsPending($actor)) { + // can't actually do anything at this point + // TODO: cancel request? is this possible?? do i need to modify the protocol + } else { + // follow + $user->actor->follow($actor); + } + + render_template('actor_profile_follow_button', ['user' => $user, 'actor' => $actor]); +}); \ No newline at end of file diff --git a/routes/webfinger.php b/routes/webfinger.php index 1b719cd..695f865 100644 --- a/routes/webfinger.php +++ b/routes/webfinger.php @@ -29,7 +29,7 @@ Router::getInstance()->mount('/.well-known/webfinger', function (array $args) { 'links' => [ [ 'rel' => ActorWebfinger::REL_URI, - 'href' => path_to_uri("/actor/$actor->handle"), + 'href' => path_to_uri("/actor/$actor->id"), 'type' => 'application/json' ] ] -- cgit v1.3