Add suspend button on #instance/filter-users for manually suspending an account

This commit is contained in:
Bofh 2022-12-12 21:28:15 +01:00
parent f9b9b4be40
commit 725f2ab476
2 changed files with 15 additions and 0 deletions

View File

@ -170,6 +170,10 @@
</div> </div>
<div class="only mastodon">{mastodon:fields}</div> <div class="only mastodon">{mastodon:fields}</div>
<div class="note">{note}</div> <div class="note">{note}</div>
<div style="margin-top: 1em; text-align: right;">
<button onclick="window.view.instance.do.users.suspend('{id}')"
class="btn mid red"><i class="fa fa-ban fa-fw"></i>Suspend</button>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -19,6 +19,16 @@ window.view.instance = {
window.location.hash = window.location.hash.replace('#instance/','#instance_config/'); window.location.hash = window.location.hash.replace('#instance/','#instance_config/');
}, },
do: { do: {
users: {
suspend: function(_id) {
if (!confirm('Are you sure you want to suspend this user?')) return;
const hargs = get_hash_arguments();
http.get(`api/v1/http/mastodon/accounts/suspend?instance=${hargs.instance}&id=${_id}`,
{}, function(js) {
toast.info('User has been successfully suspended');
});
},
},
new_accounts: { new_accounts: {
approve: function(_id) { approve: function(_id) {
window.view.instance.do.new_accounts._perform('approve', _id); window.view.instance.do.new_accounts._perform('approve', _id);
@ -194,6 +204,7 @@ window.view.instance = {
var tpl = TPL; var tpl = TPL;
const it = js['data'][i]; const it = js['data'][i];
tpl = tpl.replaceAll('{software}', hargs.software); tpl = tpl.replaceAll('{software}', hargs.software);
tpl = tpl.replaceAll('{id}', it.id);
tpl = tpl.replaceAll('{name}', html2text(it.name)); tpl = tpl.replaceAll('{name}', html2text(it.name));
tpl = tpl.replaceAll('{acct}', html2text(it.acct)); tpl = tpl.replaceAll('{acct}', html2text(it.acct));
if (it.avatar === null) if (it.avatar === null)