Improved feedback on silence/suspend actions
This commit is contained in:
parent
739f23cc63
commit
dcc159ea91
|
@ -32,7 +32,7 @@ $filtered_accounts_index = [];
|
||||||
|
|
||||||
$sql_all = '
|
$sql_all = '
|
||||||
SELECT
|
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,
|
a.note, a.avatar_file_name, a.avatar_storage_schema_version,
|
||||||
(SELECT count(1) FROM statuses WHERE account_id = a.id) AS statuses
|
(SELECT count(1) FROM statuses WHERE account_id = a.id) AS statuses
|
||||||
FROM accounts AS a
|
FROM accounts AS a
|
||||||
|
@ -198,6 +198,14 @@ if (isset($_GET['profile']) && trim($_GET['profile']) != '')
|
||||||
$config = instance_config('mastodon');
|
$config = instance_config('mastodon');
|
||||||
$filtered_accounts = array_unique($filtered_accounts);
|
$filtered_accounts = array_unique($filtered_accounts);
|
||||||
$trusted_users = mod_php('api/v1/config/trusted_users/get');
|
$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 = [];
|
$result_accounts = [];
|
||||||
foreach ($filtered_accounts as $id) {
|
foreach ($filtered_accounts as $id) {
|
||||||
|
@ -206,7 +214,8 @@ foreach ($filtered_accounts as $id) {
|
||||||
|
|
||||||
$acct_for_trusted = $account['username'].'@'.($account['domain'] === null ?
|
$acct_for_trusted = $account['username'].'@'.($account['domain'] === null ?
|
||||||
$GLOBALS['ap_instance'] : $account['domain']);
|
$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;
|
continue;
|
||||||
|
|
||||||
$following = $pg->fetch('SELECT count(1) FROM follows WHERE account_id = \''.$id.'\'');
|
$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['statuses'] = intval($account['statuses']);
|
||||||
$newacc['following'] = intval($following['count']);
|
$newacc['following'] = intval($following['count']);
|
||||||
$newacc['followers'] = intval($followers['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) {
|
if ($account['avatar_storage_schema_version'] === 1) {
|
||||||
$c = 0;
|
$c = 0;
|
||||||
$parts = [];
|
$parts = [];
|
||||||
|
|
|
@ -5,11 +5,22 @@ $_ = function() {
|
||||||
if (!valid_mastodon_account_id($id))
|
if (!valid_mastodon_account_id($id))
|
||||||
return apiresult(['error' => 'id parameter has incorrect format'], 400);
|
return apiresult(['error' => 'id parameter has incorrect format'], 400);
|
||||||
|
|
||||||
|
instance_config();
|
||||||
|
|
||||||
$output = instance_http_post('/api/v1/admin/accounts/'.$id.'/action',
|
$output = instance_http_post('/api/v1/admin/accounts/'.$id.'/action',
|
||||||
['type' => 'silence' ]);
|
['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']))
|
if (!isset($_SERVER['REQUEST_URI']))
|
||||||
sleep(2);
|
sleep(2);
|
||||||
|
|
||||||
return apiresult($output);
|
return apiresult($output);
|
||||||
};
|
};
|
||||||
$_();
|
$_();
|
||||||
|
|
|
@ -5,6 +5,8 @@ $_ = function() {
|
||||||
if (!valid_mastodon_account_id($id))
|
if (!valid_mastodon_account_id($id))
|
||||||
return apiresult(['error' => 'id parameter has incorrect format'], 400);
|
return apiresult(['error' => 'id parameter has incorrect format'], 400);
|
||||||
|
|
||||||
|
instance_config();
|
||||||
|
|
||||||
$explain = 'Your account has been suspended';
|
$explain = 'Your account has been suspended';
|
||||||
if (isset($_POST['explain']))
|
if (isset($_POST['explain']))
|
||||||
$explain = trim($_POST['explain']);
|
$explain = trim($_POST['explain']);
|
||||||
|
@ -21,8 +23,17 @@ $_ = function() {
|
||||||
if ($is_remote_account)
|
if ($is_remote_account)
|
||||||
instance_http_delete('/api/v1/admin/accounts/'.$id);
|
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']))
|
if (!isset($_SERVER['REQUEST_URI']))
|
||||||
sleep(3);
|
sleep(3);
|
||||||
|
|
||||||
return apiresult($output);
|
return apiresult($output);
|
||||||
};
|
};
|
||||||
$_();
|
$_();
|
||||||
|
|
10
css/base.php
10
css/base.php
|
@ -75,6 +75,11 @@ body > .toast-container {
|
||||||
border: none !important;
|
border: none !important;
|
||||||
box-shadow: none !important;
|
box-shadow: none !important;
|
||||||
}
|
}
|
||||||
|
.disabled,
|
||||||
|
.silenced .disable-able {
|
||||||
|
filter: saturate(0);
|
||||||
|
opacity: 0.7;
|
||||||
|
}
|
||||||
.gray { color: gray }
|
.gray { color: gray }
|
||||||
.btn {
|
.btn {
|
||||||
padding: 1em 3em;
|
padding: 1em 3em;
|
||||||
|
@ -198,6 +203,11 @@ table.fields tr.verified td .fa.fa-check::before {
|
||||||
border: 1px solid #0000001a;
|
border: 1px solid #0000001a;
|
||||||
border-radius: .5em;
|
border-radius: .5em;
|
||||||
margin-top: .5em;
|
margin-top: .5em;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
.item.suspended .card {
|
||||||
|
background: #fff3f3 !important;
|
||||||
|
border: 2px solid red;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -154,8 +154,8 @@
|
||||||
</div>
|
</div>
|
||||||
<div id="users-all"></div>
|
<div id="users-all"></div>
|
||||||
<div id="users-all-item" data-id="{id}">
|
<div id="users-all-item" data-id="{id}">
|
||||||
<div class="card software {software}">
|
<div class="card software {software} {silencedClass}">
|
||||||
<div class="flex">
|
<div class="flex disable-able">
|
||||||
<img data-src="{avatar}"/>
|
<img data-src="{avatar}"/>
|
||||||
<div class="w100" style="padding:0 1em">
|
<div class="w100" style="padding:0 1em">
|
||||||
<b style="font-size: 1.1em">{name}</b>
|
<b style="font-size: 1.1em">{name}</b>
|
||||||
|
@ -168,16 +168,26 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="only mastodon">{mastodon:fields}</div>
|
<div class="only mastodon disable-able">{mastodon:fields}</div>
|
||||||
<div class="note">{note}</div>
|
<div class="note">{note}</div>
|
||||||
<div style="margin-top: 1em; text-align: right;">
|
<div style="margin-top: 1em; text-align: right;">
|
||||||
<button onclick="if (window.view.instance.do.users.trust_user('{acct}'))
|
<button onclick="if (window.view.instance.do.users.trust_user('{acct}'))
|
||||||
E.element('.item[data-id="{id}"]').remove()"
|
E.element('.item[data-id="{id}"]').remove()"
|
||||||
class="btn mid green"><i class="fa fa-thumbs-up fa-fw"></i>Trust</button>
|
class="btn mid green"><i class="fa fa-thumbs-up fa-fw"></i>Trust</button>
|
||||||
<button onclick="window.view.instance.do.users.silence('{id}')"
|
<button onclick="
|
||||||
class="btn mid"><i class="fa fa-volume-mute fa-fw"></i>Silence</button>
|
if ('' === '{disabledClass}') {
|
||||||
<button onclick="window.view.instance.do.users.suspend('{id}')"
|
if (window.view.instance.do.users.silence('{id}')) {
|
||||||
class="btn mid red"><i class="fa fa-ban fa-fw"></i>Suspend</button>
|
E.element('.item[data-id="{id}"]').classList.add('silenced');
|
||||||
|
this.querySelector('span').innerText = 'Silenced';
|
||||||
|
this.setAttribute('disabled', 'true');
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
class="btn mid disable-able" {disabledHTML}>
|
||||||
|
<i class="fa fa-volume-mute fa-fw"></i><span>{silencedText}</span></button>
|
||||||
|
<button onclick="if (window.view.instance.do.users.suspend('{id}')) {
|
||||||
|
E.element('.item[data-id="{id}"]').classList.add('suspended');
|
||||||
|
this.querySelector('span'),innerText = 'Suspended'}"
|
||||||
|
class="btn mid red"><i class="fa fa-ban fa-fw"></i><span>Suspend</span></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -34,12 +34,13 @@ window.view.instance = {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
suspend: function(_id) {
|
suspend: function(_id) {
|
||||||
if (!confirm('Are you sure you want to suspend this user?')) return;
|
if (!confirm('Are you sure you want to suspend this user?')) return false;
|
||||||
const hargs = get_hash_arguments();
|
const hargs = get_hash_arguments();
|
||||||
http.get(`api/v1/http/mastodon/accounts/suspend?instance=${hargs.instance}&id=${_id}`,
|
http.get(`api/v1/http/mastodon/accounts/suspend?instance=${hargs.instance}&id=${_id}`,
|
||||||
{}, function(js) {
|
{}, function(js) {
|
||||||
toast.info('User has been successfully suspended');
|
toast.info('User has been successfully suspended');
|
||||||
});
|
});
|
||||||
|
return true;
|
||||||
},
|
},
|
||||||
silence: function(_id) {
|
silence: function(_id) {
|
||||||
const hargs = get_hash_arguments();
|
const hargs = get_hash_arguments();
|
||||||
|
@ -47,6 +48,7 @@ window.view.instance = {
|
||||||
{}, function(js) {
|
{}, function(js) {
|
||||||
toast.info('User has been successfully silenced');
|
toast.info('User has been successfully silenced');
|
||||||
});
|
});
|
||||||
|
return true;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
new_accounts: {
|
new_accounts: {
|
||||||
|
@ -201,6 +203,7 @@ window.view.instance = {
|
||||||
execute: function(page, items_per_page) {
|
execute: function(page, items_per_page) {
|
||||||
const btn = E.elemid('btncollapse-filters-current');
|
const btn = E.elemid('btncollapse-filters-current');
|
||||||
if (btn.innerText.trim() === 'hide') btn.click();
|
if (btn.innerText.trim() === 'hide') btn.click();
|
||||||
|
window.scrollTo(0,0);
|
||||||
|
|
||||||
const data = window.view.instance.do.filter_users.get_current_filter();
|
const data = window.view.instance.do.filter_users.get_current_filter();
|
||||||
delete data.id;
|
delete data.id;
|
||||||
|
@ -234,6 +237,10 @@ window.view.instance = {
|
||||||
tpl = tpl.replaceAll('{statuses}', it.statuses);
|
tpl = tpl.replaceAll('{statuses}', it.statuses);
|
||||||
tpl = tpl.replaceAll('{following}', it.following);
|
tpl = tpl.replaceAll('{following}', it.following);
|
||||||
tpl = tpl.replaceAll('{followers}', it.followers);
|
tpl = tpl.replaceAll('{followers}', it.followers);
|
||||||
|
tpl = tpl.replaceAll('{disabledClass}', it.silenced === true ? 'disabled' : '');
|
||||||
|
tpl = tpl.replaceAll('{silencedClass}', it.silenced === true ? 'silenced' : '');
|
||||||
|
tpl = tpl.replaceAll('{disabledHTML}', it.silenced === true ? 'disabled="true"' : '');
|
||||||
|
tpl = tpl.replaceAll('{silencedText}', it.silenced === true ? 'Silenced' : 'Silence');
|
||||||
if (hargs.software === 'mastodon') {
|
if (hargs.software === 'mastodon') {
|
||||||
if (![null, undefined].includes(it.fields)) {
|
if (![null, undefined].includes(it.fields)) {
|
||||||
var _fields = '<table class="fields"><tbody>';
|
var _fields = '<table class="fields"><tbody>';
|
||||||
|
|
Loading…
Reference in New Issue