diff options
| author | winter | 2025-01-14 20:44:49 +0000 |
|---|---|---|
| committer | winter | 2025-01-14 20:44:49 +0000 |
| commit | 4d7f8450d9a842e2f69754ccaa4202710328dcb7 (patch) | |
| tree | 60e90ff7ebbf069e04faf665d68861970eaee000 /routes | |
| parent | 0f427b4b6f75134b2c25b7e5f8a515be2cec97f5 (diff) | |
add (un)follow button to profile
also other stuff i forgot what exactly
Diffstat (limited to 'routes')
| -rw-r--r-- | routes/actor_profile_fragment.php | 23 | ||||
| -rw-r--r-- | routes/webfinger.php | 2 |
2 files changed, 24 insertions, 1 deletions
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 @@ +<?php + +use Digitigrade\Model\Actor; +use Digitigrade\Model\UserAccount; +use Digitigrade\Router; + +Router::getInstance()->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' ] ] |
