From dc973571d4288ba387f5dcf6c278bcc8ec24a082 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 2 Jan 2019 22:00:31 -0700 Subject: [PATCH] Add InstanceApiController --- .../Controllers/Api/InstanceApiController.php | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 app/Http/Controllers/Api/InstanceApiController.php diff --git a/app/Http/Controllers/Api/InstanceApiController.php b/app/Http/Controllers/Api/InstanceApiController.php new file mode 100644 index 00000000..1608dc4e --- /dev/null +++ b/app/Http/Controllers/Api/InstanceApiController.php @@ -0,0 +1,66 @@ +first()->profile; + return [ + 'id' => $admin->id, + 'username' => $admin->username, + 'acct' => $admin->username, + 'display_name' => e($admin->name), + 'locked' => (bool) $admin->is_private, + 'bot' => false, + 'created_at' => $admin->created_at->format('c'), + 'note' => e($admin->bio), + 'url' => $admin->url(), + 'avatar' => $admin->avatarUrl(), + 'avatar_static' => $admin->avatarUrl(), + 'header' => null, + 'header_static' => null, + 'moved' => null, + 'fields' => null, + 'bot' => null, + ]; + }); + + $res = [ + 'uri' => config('pixelfed.domain.app'), + 'title' => config('app.name'), + 'description' => '', + 'version' => config('pixelfed.version'), + 'urls' => [], + 'stats' => [ + 'user_count' => User::count(), + 'status_count' => Status::whereNull('uri')->count(), + 'domain_count' => Profile::whereNotNull('domain') + ->groupBy('domain') + ->pluck('domain') + ->count() + ], + 'thumbnail' => '', + 'languages' => [], + 'contact_account' => $contact + ]; + return $res; + } + + public function instance() + { + $res = Cache::remember('api:v1:instance', 60, function() { + return json_encode($this->getData()); + }); + + return response($res)->header('Content-Type', 'application/json'); + } + +} \ No newline at end of file