diff --git a/api/v1/config/filters/actions/put/index.php b/api/v1/config/filters/actions/put/index.php index f2fbbab..1358b9d 100644 --- a/api/v1/config/filters/actions/put/index.php +++ b/api/v1/config/filters/actions/put/index.php @@ -26,8 +26,12 @@ if ($id === null || $action === null) apiresult(['error' => ' or parameter is not valid']); $interval = 0; -if (isset($_GET['interval'])) - $interval = intval(trim($_GET['interval'])); +if (isset($_POST['interval'])) + $interval = intval(trim($_POST['interval'])); + +$explain = null; +if (isset($_POST['explain'])) + $explain = trim($_POST['explain']); $afile_name = $type.','.$GLOBALS['ap_instance'].','; $action_file = $actions_dir.'/'.$type.','.$GLOBALS['ap_instance'].','.$id; @@ -35,6 +39,10 @@ $action_file = $actions_dir.'/'.$type.','.$GLOBALS['ap_instance'].','.$id; if ($action === 'none' && file_exists($action_file)) unlink($action_file); else if ($action !== 'none') - file_put_contents($action_file, serialize( - ['name' => $action, 'interval' => $interval])); + file_put_contents($action_file, + serialize([ + 'name' => $action, + 'interval' => $interval, + 'explain' => $explain, + ])); apiresult(['ok' => 'filter action has been succesfully saved']); diff --git a/api/v1/http/mastodon/accounts/suspend/mod.php b/api/v1/http/mastodon/accounts/suspend/mod.php index 428c1b3..1fe6b67 100644 --- a/api/v1/http/mastodon/accounts/suspend/mod.php +++ b/api/v1/http/mastodon/accounts/suspend/mod.php @@ -5,7 +5,12 @@ $_ = function() { if (!valid_mastodon_account_id($id)) return apiresult(['error' => 'id parameter has incorrect format'], 400); - instance_http_post('/api/v1/admin/accounts/'.$id.'/action',['type' => 'suspend']); + $explain = 'Your account has been suspended'; + if (isset($_POST['explain'])) + $explain = trim($_POST['explain']); + + instance_http_post('/api/v1/admin/accounts/'.$id.'/action', + ['type' => 'suspend', 'text' => $explain ]); $output = instance_http_delete('/api/v1/admin/accounts/'.$id); return apiresult($output); }; diff --git a/js/templates/instance/filter-users.html b/js/templates/instance/filter-users.html index c026f92..b725a90 100644 --- a/js/templates/instance/filter-users.html +++ b/js/templates/instance/filter-users.html @@ -120,6 +120,12 @@ +
+ +
+ +
diff --git a/views/instance.php b/views/instance.php index 0e518a6..941fa62 100644 --- a/views/instance.php +++ b/views/instance.php @@ -134,11 +134,13 @@ window.view.instance = { return tpl; }); if (js.action === null) - js.action = { name: 'none', interval: NaN }; + js.action = { name: 'none', interval: NaN, explain: '' }; E.element('#filter-instance-action select[name=instance_action_name]') .value = js.action.name; E.element('#filter-instance-action input[name=instance_action_interval]') .value = js.action.interval; + E.element('#filter-instance-action textarea[name=instance_action_explain]') + .value = js.action.explain; }); break; } @@ -151,8 +153,10 @@ window.view.instance = { const v = E.element('#filter-instance-action select[name=instance_action_name]').value.trim(); var v2 = E.element('#filter-instance-action input[name=instance_action_interval]').value.trim(); v2 = Number.parseInt(v2) === NaN ? 0 : Number.parseInt(v2); - http.get(`api/v1/config/filters/actions/put?instance=${hargs.instance}&type=users&id=${_id}&action=${v}&interval=${v2}`, - {},function(js){ if (js.ok) toast.info(js.ok) }); + const v3 = E.element('#filter-instance-action textarea[name=instance_action_explain]').value.trim(); + const payload = { interval: v2, explain: v3 }; + http.post(`api/v1/config/filters/actions/put?instance=${hargs.instance}&type=users&id=${_id}&action=${v}`, + payload, function(js){ if (js.ok) toast.info(js.ok) }); }, delete_filter: function(_id) { if (!confirm('Are you sure you want to delete this filter?'))