diff --git a/api/v1/http/mastodon/accounts/suspend/mod.php b/api/v1/http/mastodon/accounts/suspend/mod.php index 07b8f5d..39ecf3a 100644 --- a/api/v1/http/mastodon/accounts/suspend/mod.php +++ b/api/v1/http/mastodon/accounts/suspend/mod.php @@ -9,10 +9,20 @@ $_ = function() { if (isset($_POST['explain'])) $explain = trim($_POST['explain']); + $is_remote_account = false; + $pg = new PgDatabase(); + if ($pg->is_ok()) { + $result = $pg->fetch('SELECT domain FROM accounts WHERE id = '.$id); + $is_remote_account = isset($result['domain']) && $result['domain'] !== null; + } + $output = instance_http_post('/api/v1/admin/accounts/'.$id.'/action', ['type' => 'suspend', 'text' => $explain ]); - #$output = instance_http_delete('/api/v1/admin/accounts/'.$id); - sleep(3); + if ($is_remote_account) + instance_http_delete('/api/v1/admin/accounts/'.$id); + + if (!isset($_SERVER['REQUEST_URI'])) + sleep(3); return apiresult($output); }; $_(); diff --git a/classes/PgDatabase.php b/classes/PgDatabase.php index d311f5a..7524f2a 100644 --- a/classes/PgDatabase.php +++ b/classes/PgDatabase.php @@ -8,7 +8,6 @@ class PgDatabase { $url = trim($_SERVER['REQUEST_URI'], '/'); $url = substr($url, 7); // api/vX/ $ps = explode('/', $url); - if ($ps[0] !== 'database') return; $software = $ps[1]; } if ($software === null && isset($GLOBALS['ap_software']))