mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 22:41:27 +00:00
commit
8606040858
5 changed files with 350 additions and 281 deletions
|
@ -11,6 +11,9 @@
|
|||
- Update nginx config ([fbdc6358](https://github.com/pixelfed/pixelfed/commit/fbdc6358))
|
||||
- Update api routes, add DeprecatedEndpoint middleware. For more info, visit [pixelfed.org/kb/10404](https://pixelfed.org/kb/10404) ([a8453e77](https://github.com/pixelfed/pixelfed/commit/a8453e77))
|
||||
- Update admin dashboard, improve users section ([36b6bf48](https://github.com/pixelfed/pixelfed/commit/36b6bf48))
|
||||
- Update AdminApiController, add instance stats endpoint ([89c3710d](https://github.com/pixelfed/pixelfed/commit/89c3710d))
|
||||
- Update config, re-add `PF_MAX_USERS` .env variable to limit max users to 1000 by default ([a6d10f03](https://github.com/pixelfed/pixelfed/commit/a6d10f03))
|
||||
- Update AdminApiController, fix stats ([5c5541fc](https://github.com/pixelfed/pixelfed/commit/5c5541fc))
|
||||
- ([](https://github.com/pixelfed/pixelfed/commit/))
|
||||
|
||||
## [v0.11.8 (2023-05-29)](https://github.com/pixelfed/pixelfed/compare/v0.11.7...v0.11.8)
|
||||
|
|
|
@ -23,6 +23,7 @@ use App\Services\AdminStatsService;
|
|||
use App\Services\ConfigCacheService;
|
||||
use App\Services\InstanceService;
|
||||
use App\Services\ModLogService;
|
||||
use App\Services\SnowflakeService;
|
||||
use App\Services\StatusService;
|
||||
use App\Services\NetworkTimelineService;
|
||||
use App\Services\NotificationService;
|
||||
|
@ -599,4 +600,62 @@ class AdminApiController extends Controller
|
|||
|
||||
return new AdminInstance($instance);
|
||||
}
|
||||
|
||||
public function getAllStats(Request $request)
|
||||
{
|
||||
abort_if(!$request->user(), 404);
|
||||
abort_unless($request->user()->is_admin === 1, 404);
|
||||
|
||||
if($request->has('refresh')) {
|
||||
Cache::forget('admin-api:instance-all-stats-v1');
|
||||
}
|
||||
|
||||
return Cache::remember('admin-api:instance-all-stats-v1', 1209600, function() {
|
||||
$days = range(1, 7);
|
||||
$res = [
|
||||
'cached_at' => now()->format('c'),
|
||||
];
|
||||
$minStatusId = SnowflakeService::byDate(now()->subDays(7));
|
||||
|
||||
foreach($days as $day) {
|
||||
$label = now()->subDays($day)->format('D');
|
||||
$labelShort = substr($label, 0, 1);
|
||||
$res['users']['days'][] = [
|
||||
'date' => now()->subDays($day)->format('M j Y'),
|
||||
'label_full' => $label,
|
||||
'label' => $labelShort,
|
||||
'count' => User::whereDate('created_at', now()->subDays($day))->count()
|
||||
];
|
||||
|
||||
$res['posts']['days'][] = [
|
||||
'date' => now()->subDays($day)->format('M j Y'),
|
||||
'label_full' => $label,
|
||||
'label' => $labelShort,
|
||||
'count' => Status::whereNull('uri')->where('id', '>', $minStatusId)->whereDate('created_at', now()->subDays($day))->count()
|
||||
];
|
||||
|
||||
$res['instances']['days'][] = [
|
||||
'date' => now()->subDays($day)->format('M j Y'),
|
||||
'label_full' => $label,
|
||||
'label' => $labelShort,
|
||||
'count' => Instance::whereDate('created_at', now()->subDays($day))->count()
|
||||
];
|
||||
}
|
||||
|
||||
$res['users']['total'] = DB::table('users')->count();
|
||||
$res['users']['min'] = collect($res['users']['days'])->min('count');
|
||||
$res['users']['max'] = collect($res['users']['days'])->max('count');
|
||||
$res['users']['change'] = collect($res['users']['days'])->sum('count');;
|
||||
$res['posts']['total'] = DB::table('statuses')->whereNull('uri')->count();
|
||||
$res['posts']['min'] = collect($res['posts']['days'])->min('count');
|
||||
$res['posts']['max'] = collect($res['posts']['days'])->max('count');
|
||||
$res['posts']['change'] = collect($res['posts']['days'])->sum('count');
|
||||
$res['instances']['total'] = DB::table('instances')->count();
|
||||
$res['instances']['min'] = collect($res['instances']['days'])->min('count');
|
||||
$res['instances']['max'] = collect($res['instances']['days'])->max('count');
|
||||
$res['instances']['change'] = collect($res['instances']['days'])->sum('count');
|
||||
|
||||
return $res;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -178,8 +178,9 @@ class RegisterController extends Controller
|
|||
if(config('pixelfed.bouncer.cloud_ips.ban_signups')) {
|
||||
abort_if(BouncerService::checkIp(request()->ip()), 404);
|
||||
}
|
||||
$hasLimit = config('pixelfed.enforce_max_users');
|
||||
if($hasLimit) {
|
||||
$limit = config('pixelfed.max_users');
|
||||
if($limit) {
|
||||
$count = User::where(function($q){ return $q->whereNull('status')->orWhereNotIn('status', ['deleted','delete']); })->count();
|
||||
if($limit <= $count) {
|
||||
return redirect(route('help.instance-max-users-limit'));
|
||||
|
@ -208,12 +209,16 @@ class RegisterController extends Controller
|
|||
abort_if(BouncerService::checkIp($request->ip()), 404);
|
||||
}
|
||||
|
||||
$hasLimit = config('pixelfed.enforce_max_users');
|
||||
if($hasLimit) {
|
||||
$count = User::where(function($q){ return $q->whereNull('status')->orWhereNotIn('status', ['deleted','delete']); })->count();
|
||||
$limit = config('pixelfed.max_users');
|
||||
|
||||
if(false == config_cache('pixelfed.open_registration') || $limit && $limit <= $count) {
|
||||
if($limit && $limit <= $count) {
|
||||
return redirect(route('help.instance-max-users-limit'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->validator($request->all())->validate();
|
||||
|
||||
|
|
|
@ -198,7 +198,8 @@ return [
|
|||
| Allow a maximum number of user accounts. Default: off
|
||||
|
|
||||
*/
|
||||
'max_users' => env('PF_MAX_USERS', false),
|
||||
'max_users' => env('PF_MAX_USERS', 1000),
|
||||
'enforce_max_users' => env('PF_ENFORCE_MAX_USERS', true),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
|
@ -200,21 +200,21 @@ Route::group(['prefix' => 'api'], function() use($middleware) {
|
|||
});
|
||||
|
||||
Route::group(['prefix' => 'live'], function() use($middleware) {
|
||||
Route::post('create_stream', 'LiveStreamController@createStream')->middleware($middleware);
|
||||
Route::post('stream/edit', 'LiveStreamController@editStream')->middleware($middleware);
|
||||
Route::get('active/list', 'LiveStreamController@getActiveStreams')->middleware($middleware);
|
||||
Route::get('accounts/stream', 'LiveStreamController@getUserStream')->middleware($middleware);
|
||||
Route::get('accounts/stream/guest', 'LiveStreamController@getUserStreamAsGuest');
|
||||
Route::delete('accounts/stream', 'LiveStreamController@deleteStream')->middleware($middleware);
|
||||
Route::get('chat/latest', 'LiveStreamController@getLatestChat')->middleware($middleware);
|
||||
Route::post('chat/message', 'LiveStreamController@addChatComment')->middleware($middleware);
|
||||
Route::post('chat/delete', 'LiveStreamController@deleteChatComment')->middleware($middleware);
|
||||
Route::post('chat/ban-user', 'LiveStreamController@banChatUser')->middleware($middleware);
|
||||
Route::post('chat/pin', 'LiveStreamController@pinChatComment')->middleware($middleware);
|
||||
Route::post('chat/unpin', 'LiveStreamController@unpinChatComment')->middleware($middleware);
|
||||
Route::get('config', 'LiveStreamController@getConfig');
|
||||
Route::post('broadcast/publish', 'LiveStreamController@clientBroadcastPublish');
|
||||
Route::post('broadcast/finish', 'LiveStreamController@clientBroadcastFinish');
|
||||
// Route::post('create_stream', 'LiveStreamController@createStream')->middleware($middleware);
|
||||
// Route::post('stream/edit', 'LiveStreamController@editStream')->middleware($middleware);
|
||||
// Route::get('active/list', 'LiveStreamController@getActiveStreams')->middleware($middleware);
|
||||
// Route::get('accounts/stream', 'LiveStreamController@getUserStream')->middleware($middleware);
|
||||
// Route::get('accounts/stream/guest', 'LiveStreamController@getUserStreamAsGuest');
|
||||
// Route::delete('accounts/stream', 'LiveStreamController@deleteStream')->middleware($middleware);
|
||||
// Route::get('chat/latest', 'LiveStreamController@getLatestChat')->middleware($middleware);
|
||||
// Route::post('chat/message', 'LiveStreamController@addChatComment')->middleware($middleware);
|
||||
// Route::post('chat/delete', 'LiveStreamController@deleteChatComment')->middleware($middleware);
|
||||
// Route::post('chat/ban-user', 'LiveStreamController@banChatUser')->middleware($middleware);
|
||||
// Route::post('chat/pin', 'LiveStreamController@pinChatComment')->middleware($middleware);
|
||||
// Route::post('chat/unpin', 'LiveStreamController@unpinChatComment')->middleware($middleware);
|
||||
// Route::get('config', 'LiveStreamController@getConfig');
|
||||
// Route::post('broadcast/publish', 'LiveStreamController@clientBroadcastPublish')->middleware($middleware);
|
||||
// Route::post('broadcast/finish', 'LiveStreamController@clientBroadcastFinish')->middleware($middleware);
|
||||
});
|
||||
|
||||
Route::group(['prefix' => 'admin'], function() use($middleware) {
|
||||
|
@ -235,6 +235,7 @@ Route::group(['prefix' => 'api'], function() use($middleware) {
|
|||
Route::get('instances/get', 'Api\AdminApiController@getInstance')->middleware($middleware);
|
||||
Route::post('instances/moderate', 'Api\AdminApiController@moderateInstance')->middleware($middleware);
|
||||
Route::post('instances/refresh-stats', 'Api\AdminApiController@refreshInstanceStats')->middleware($middleware);
|
||||
Route::get('instance/stats', 'Api\AdminApiController@getAllStats')->middleware($middleware);
|
||||
});
|
||||
|
||||
Route::group(['prefix' => 'landing/v1'], function() use($middleware) {
|
||||
|
|
Loading…
Reference in a new issue