diff options
| author | winter | 2025-01-16 20:21:42 +0000 |
|---|---|---|
| committer | winter | 2025-01-16 20:21:42 +0000 |
| commit | b1d6fbc4d740324d96d7fe2677fb15b9b59d20ea (patch) | |
| tree | ae2c996cc6a42b3a42437a7ec8812cd184644817 /routes | |
| parent | 8de5608976dc8a73a400267601acb4c8e127de5a (diff) | |
follow requests
Diffstat (limited to 'routes')
| -rw-r--r-- | routes/actor_profile_fragment.php | 18 | ||||
| -rw-r--r-- | routes/homepage.php | 7 | ||||
| -rw-r--r-- | routes/pending_follows.php | 10 | ||||
| -rw-r--r-- | routes/user_auth.php | 9 |
4 files changed, 43 insertions, 1 deletions
diff --git a/routes/actor_profile_fragment.php b/routes/actor_profile_fragment.php index 9b864d9..a3be976 100644 --- a/routes/actor_profile_fragment.php +++ b/routes/actor_profile_fragment.php @@ -20,4 +20,22 @@ Router::getInstance()->mount('/fragment/actor/:id/followButton', function (array } render_template('actor_profile_follow_button', ['user' => $user, 'actor' => $actor]); +}); + +Router::getInstance()->mount('/fragment/actor/:id/acceptPending', function (array $args) { + $user = UserAccount::requireByCurrentSession(); + $actor = Actor::find($args['id']); + + $user->actor->acceptPendingFollowFrom($actor); + + render_template('actor_profile_pending_follow', ['response' => 'accepted']); +}); + +Router::getInstance()->mount('/fragment/actor/:id/rejectPending', function (array $args) { + $user = UserAccount::requireByCurrentSession(); + $actor = Actor::find($args['id']); + + $user->actor->rejectPendingFollowFrom($actor); + + render_template('actor_profile_pending_follow', ['response' => 'rejected']); });
\ No newline at end of file diff --git a/routes/homepage.php b/routes/homepage.php index db8ea72..c99dce4 100644 --- a/routes/homepage.php +++ b/routes/homepage.php @@ -2,12 +2,17 @@ use Digitigrade\HttpResponseStatus\NotFound; use Digitigrade\HttpResponseStatus\TemporaryRedirect; +use Digitigrade\Model\UserAccount; use Digitigrade\Router; Router::getInstance()->mount('/', function (array $args) { $accept = $_SERVER['HTTP_ACCEPT'] ?? ''; if (str_contains($accept, 'text/html') || str_contains($accept, '*/*')) { - throw new TemporaryRedirect('/feed/global'); + throw new TemporaryRedirect( + UserAccount::findByCurrentSession() == null + ? '/feed/global' + : '/feed/home' + ); } throw new NotFound(); });
\ No newline at end of file diff --git a/routes/pending_follows.php b/routes/pending_follows.php new file mode 100644 index 0000000..d3bd9da --- /dev/null +++ b/routes/pending_follows.php @@ -0,0 +1,10 @@ +<?php + +use Digitigrade\Model\UserAccount; +use Digitigrade\Router; + +Router::getInstance()->mount('/followrequests', function (array $args) { + $user = UserAccount::requireByCurrentSession(); + $actors = $user->actor->findPendingFollowers(); + render_template('follow_requests_page', ['actors' => $actors]); +});
\ No newline at end of file diff --git a/routes/user_auth.php b/routes/user_auth.php index afdf8d8..49e138b 100644 --- a/routes/user_auth.php +++ b/routes/user_auth.php @@ -29,4 +29,13 @@ Router::getInstance()->mount('/login', function (array $args) { } else { render_template('login_page', ['email' => $_POST['email'] ?? '', 'failed' => $failedVerification]); } +}); + +Router::getInstance()->mount('/logout', function (array $args) { + if (isset($_COOKIE['digitigrade-session'])) { + $session = Session::findByToken($_COOKIE['digitigrade-session']); + $session->clearCookie(); + $session->remove(); + } + throw new TemporaryRedirect('/'); });
\ No newline at end of file |
