aboutsummaryrefslogtreecommitdiffhomepage
path: root/routes/actor_profile_fragment.php
diff options
context:
space:
mode:
authorwinter2025-01-14 20:44:49 +0000
committerwinter2025-01-14 20:44:49 +0000
commit4d7f8450d9a842e2f69754ccaa4202710328dcb7 (patch)
tree60e90ff7ebbf069e04faf665d68861970eaee000 /routes/actor_profile_fragment.php
parent0f427b4b6f75134b2c25b7e5f8a515be2cec97f5 (diff)
add (un)follow button to profile
also other stuff i forgot what exactly
Diffstat (limited to 'routes/actor_profile_fragment.php')
-rw-r--r--routes/actor_profile_fragment.php23
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