diff --git a/appinfo/routes.php b/appinfo/routes.php index fad134fd..2b64e712 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -55,6 +55,7 @@ return [ ['name' => 'ActivityPub#following', 'url' => '/@{username}/following', 'verb' => 'GET'], ['name' => 'OStatus#subscribe', 'url' => '/ostatus/follow/{uri}', 'verb' => 'GET'], + ['name' => 'OStatus#followRemote', 'url' => '/api/v1/ostatus/followRemote/{local}', 'verb' => 'GET'], ['name' => 'OStatus#getLink', 'url' => '/api/v1/ostatus/link/{local}/{account}', 'verb' => 'GET'], ['name' => 'SocialPub#displayPost', 'url' => '/@{username}/{postId}', 'verb' => 'GET'], diff --git a/lib/Controller/OStatusController.php b/lib/Controller/OStatusController.php index 31eda483..182c4a3d 100644 --- a/lib/Controller/OStatusController.php +++ b/lib/Controller/OStatusController.php @@ -107,7 +107,20 @@ class OStatusController extends Controller { try { $actor = $this->cacheActorService->getFromAccount($uri); - return $this->success([$actor]); + $user = $this->userSession->getUser(); + if ($user === null) { + return $this->fail('Failed to retrieve current user'); + } + + return new TemplateResponse('social', 'ostatus', [ + 'serverData' => [ + 'account' => $actor->getAccount(), + 'currentUser' => [ + 'uid' => $user->getUID(), + 'displayName' => $user->getDisplayName(), + ] + ] + ], 'guest'); } catch (Exception $e) { return $this->fail($e); } @@ -117,6 +130,30 @@ class OStatusController extends Controller { /** * @NoCSRFRequired * @NoAdminRequired + * @PublicPage + * + * @param string $local + * @return Response + */ + public function followRemote(string $local): Response { + try { + $following = $this->accountService->getActor($local); + + return new TemplateResponse('social', 'ostatus', [ + 'serverData' => [ + 'local' => $local, + 'account' => $following->getAccount() + ] + ], 'guest'); + } catch (\Exception $e) { + return $this->fail($e); + } + } + + /** + * @NoCSRFRequired + * @NoAdminRequired + * @PublicPage * * @param string $local * @param string $account @@ -138,24 +175,10 @@ class OStatusController extends Controller { throw new RetrieveAccountFormatException(); } - $user = $this->userSession->getUser(); - if ($user === null) { - return $this->fail('Failed to retrieve current user'); - } - $template = $this->get('template', $link, ''); $url = str_replace('{uri}', $following->getAccount(), $template); - return new TemplateResponse('social', 'ostatus', [ - 'serverData' => [ - 'url' => $url, - 'account' => $account, - 'currentUser' => [ - 'uid' => $user->getUID(), - 'displayName' => $user->getDisplayName(), - ] - ] - ], 'guest'); + return $this->success(['url' => $url]); } catch (Exception $e) { return $this->fail($e); } diff --git a/src/components/ProfileInfo.vue b/src/components/ProfileInfo.vue index 439da6df..e1352084 100644 --- a/src/components/ProfileInfo.vue +++ b/src/components/ProfileInfo.vue @@ -35,6 +35,9 @@

+