diff options
Diffstat (limited to 'routes/actor_profile_fragment.php')
| -rw-r--r-- | routes/actor_profile_fragment.php | 23 |
1 files changed, 23 insertions, 0 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 |
