1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-29 11:15:09 +00:00
pixelfed/app/Http/Controllers/Api/InstanceApiController.php

66 lines
1.7 KiB
PHP
Raw Normal View History

2019-01-03 05:00:31 +00:00
<?php
namespace App\Http\Controllers\Api;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\{Profile, Status, User};
use Cache;
class InstanceApiController extends Controller {
protected function getData()
{
2019-02-25 18:56:24 +00:00
$contact = Cache::remember('api:v1:instance:contact', now()->addMinutes(1440), function() {
2019-01-03 05:00:31 +00:00
$admin = User::whereIsAdmin(true)->first()->profile;
return [
'id' => $admin->id,
'username' => $admin->username,
'acct' => $admin->username,
'display_name' => e($admin->name),
'locked' => (bool) $admin->is_private,
2022-05-20 19:22:59 +00:00
'created_at' => str_replace('+00:00', 'Z', $admin->created_at->format(DATE_RFC3339_EXTENDED)),
2019-01-03 05:00:31 +00:00
'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'),
2021-05-08 03:47:51 +00:00
'title' => config_cache('app.name'),
2019-01-03 05:00:31 +00:00
'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()
{
2019-02-25 18:56:24 +00:00
$res = Cache::remember('api:v1:instance', now()->addMinutes(60), function() {
2019-01-03 05:00:31 +00:00
return json_encode($this->getData());
});
return response($res)->header('Content-Type', 'application/json');
}
2020-02-22 13:47:49 +00:00
}