diff --git a/api/v1/database/mastodon/accounts/search/mod.php b/api/v1/database/mastodon/accounts/search/mod.php index eff36ed..0392576 100644 --- a/api/v1/database/mastodon/accounts/search/mod.php +++ b/api/v1/database/mastodon/accounts/search/mod.php @@ -32,7 +32,7 @@ $filtered_accounts_index = []; $sql_all = ' SELECT - a.id, a.display_name, a.username, a.domain, a.fields, + a.id, a.display_name, a.username, a.domain, a.fields, a.silenced_at, a.note, a.avatar_file_name, a.avatar_storage_schema_version, (SELECT count(1) FROM statuses WHERE account_id = a.id) AS statuses FROM accounts AS a @@ -198,6 +198,14 @@ if (isset($_GET['profile']) && trim($_GET['profile']) != '') $config = instance_config('mastodon'); $filtered_accounts = array_unique($filtered_accounts); $trusted_users = mod_php('api/v1/config/trusted_users/get'); +$suspended_users = []; +$susp_file = 'suspended_accounts,'.$GLOBALS['ap_software'].','.$GLOBALS['ap_instance']; +if (filedb_exists('cache', $susp_file)) + $suspended_users = unserialize(filedb_get('cache', $susp_file)); +$silenced_users = []; +$sile_file = 'silenced_accounts,'.$GLOBALS['ap_software'].','.$GLOBALS['ap_instance']; +if (filedb_exists('cache', $sile_file)) + $silenced_users = unserialize(filedb_get('cache', $sile_file)); $result_accounts = []; foreach ($filtered_accounts as $id) { @@ -206,7 +214,8 @@ foreach ($filtered_accounts as $id) { $acct_for_trusted = $account['username'].'@'.($account['domain'] === null ? $GLOBALS['ap_instance'] : $account['domain']); - if (in_array($acct_for_trusted, $trusted_users)) + if (in_array($acct_for_trusted, $trusted_users) || + in_array($id, $suspended_users)) continue; $following = $pg->fetch('SELECT count(1) FROM follows WHERE account_id = \''.$id.'\''); @@ -226,6 +235,10 @@ foreach ($filtered_accounts as $id) { $newacc['statuses'] = intval($account['statuses']); $newacc['following'] = intval($following['count']); $newacc['followers'] = intval($followers['count']); + $newacc['silenced'] = $account['silenced_at'] !== null; + if (in_array($id, $silenced_users)) + $newacc['silenced'] = true; + if ($account['avatar_storage_schema_version'] === 1) { $c = 0; $parts = []; diff --git a/api/v1/http/mastodon/accounts/silence/mod.php b/api/v1/http/mastodon/accounts/silence/mod.php index 8ce06ab..f94e592 100644 --- a/api/v1/http/mastodon/accounts/silence/mod.php +++ b/api/v1/http/mastodon/accounts/silence/mod.php @@ -5,11 +5,22 @@ $_ = function() { if (!valid_mastodon_account_id($id)) return apiresult(['error' => 'id parameter has incorrect format'], 400); + instance_config(); + $output = instance_http_post('/api/v1/admin/accounts/'.$id.'/action', ['type' => 'silence' ]); + $silenced = []; + $sile_file = 'silenced_accounts,'.$GLOBALS['ap_software'].','.$GLOBALS['ap_instance']; + if (filedb_exists('cache', $sile_file)) + $silenced = unserialize(filedb_get('cache', $sile_file)); + $silenced []= $id; + $silenced = array_unique($silenced); + filedb_put('cache', $sile_file, serialize($silenced)); + if (!isset($_SERVER['REQUEST_URI'])) sleep(2); + return apiresult($output); }; $_(); diff --git a/api/v1/http/mastodon/accounts/suspend/mod.php b/api/v1/http/mastodon/accounts/suspend/mod.php index 39ecf3a..7cadda8 100644 --- a/api/v1/http/mastodon/accounts/suspend/mod.php +++ b/api/v1/http/mastodon/accounts/suspend/mod.php @@ -5,6 +5,8 @@ $_ = function() { if (!valid_mastodon_account_id($id)) return apiresult(['error' => 'id parameter has incorrect format'], 400); + instance_config(); + $explain = 'Your account has been suspended'; if (isset($_POST['explain'])) $explain = trim($_POST['explain']); @@ -21,8 +23,17 @@ $_ = function() { if ($is_remote_account) instance_http_delete('/api/v1/admin/accounts/'.$id); + $suspended = []; + $susp_file = 'suspended_accounts,'.$GLOBALS['ap_software'].','.$GLOBALS['ap_instance']; + if (filedb_exists('cache', $susp_file)) + $suspended = unserialize(filedb_get('cache', $susp_file)); + $suspended []= $id; + $suspended = array_unique($suspended); + filedb_put('cache', $susp_file, serialize($suspended)); + if (!isset($_SERVER['REQUEST_URI'])) sleep(3); + return apiresult($output); }; $_(); diff --git a/css/base.php b/css/base.php index ba486ed..8f20f4d 100644 --- a/css/base.php +++ b/css/base.php @@ -75,6 +75,11 @@ body > .toast-container { border: none !important; box-shadow: none !important; } +.disabled, +.silenced .disable-able { + filter: saturate(0); + opacity: 0.7; +} .gray { color: gray } .btn { padding: 1em 3em; @@ -198,6 +203,11 @@ table.fields tr.verified td .fa.fa-check::before { border: 1px solid #0000001a; border-radius: .5em; margin-top: .5em; + word-break: break-word; +} +.item.suspended .card { + background: #fff3f3 !important; + border: 2px solid red; } diff --git a/js/templates/instance/filter-users.html b/js/templates/instance/filter-users.html index b0f7039..a7c0543 100644 --- a/js/templates/instance/filter-users.html +++ b/js/templates/instance/filter-users.html @@ -154,8 +154,8 @@