From 3646579d15cc345b2207079054ce6cdf01ad55f2 Mon Sep 17 00:00:00 2001 From: Bofh Date: Mon, 28 Nov 2022 15:45:55 +0100 Subject: [PATCH] Make new accounts accepted 1 by 1 instead of fetching all --- .../mastodon/get-pending-users/index.php | 12 +++++++-- css/base.php | 16 +++++++++--- js/templates/instance/new-account.html | 1 + views/instance.php | 26 +++++++++---------- 4 files changed, 36 insertions(+), 19 deletions(-) diff --git a/api/v1/database/mastodon/get-pending-users/index.php b/api/v1/database/mastodon/get-pending-users/index.php index 6761a88..5a957da 100644 --- a/api/v1/database/mastodon/get-pending-users/index.php +++ b/api/v1/database/mastodon/get-pending-users/index.php @@ -4,9 +4,17 @@ $pg = new PgDatabase(); if ($pg->is_ok()) { - $result = $pg->fetch_all('SELECT a.id, a.username, u.sign_up_ip, u.email, ui.text FROM users AS u INNER JOIN user_invite_requests AS ui ON ui.user_id = u.id INNER JOIN accounts AS a ON a.id = u.account_id WHERE NOT confirmed_at IS NULL AND approved = false ORDER BY ui.id ASC'); + $result = $pg->query('SELECT COUNT(1) FROM users AS u INNER JOIN user_invite_requests AS ui ON ui.user_id = u.id INNER JOIN accounts AS a ON a.id = u.account_id WHERE NOT confirmed_at IS NULL AND approved = false'); + $count = (pg_fetch_object($result))->count; + $result = $pg->query('SELECT a.id, a.username, u.sign_up_ip, u.email, ui.text FROM users AS u INNER JOIN user_invite_requests AS ui ON ui.user_id = u.id INNER JOIN accounts AS a ON a.id = u.account_id WHERE NOT confirmed_at IS NULL AND approved = false ORDER BY ui.id ASC LIMIT 1'); + $account = pg_fetch_object($result); + if ($account === false) + $account = null; $pg->close(); - apiresult($result); + apiresult([ + 'count' => intval($count), + 'account' => $account, + ]); } apiresult(['error' => 'Server has failed connecting to database'], 503); diff --git a/css/base.php b/css/base.php index 5bd8ac0..5cd558b 100644 --- a/css/base.php +++ b/css/base.php @@ -1,3 +1,8 @@ + '#e3e3e3' +]; +?>