soselo/api/v1/actions/mastodon/accounts/add/index.php

27 lines
798 B
PHP
Raw Normal View History

<?php chdir('../../../../../../') ?>
<?php require 'base.php' ?>
<?php
instance_config('mastodon');
$id = trim($_GET['id']);
if (!valid_mastodon_account_id($id))
apiresult(['error' => '<id> parameter has incorrect format'], 400);
$action = trim($_GET['action']);
if (!in_array($action, ['silence', 'sensible', 'suspend']))
apiresult(['error' => '<action> parameter has an incorrect value'], 400);
$action_data = [
'software' => 'mastodon',
'instance' => $GLOBALS['ap_instance'],
'action' => 'accounts:'.$action,
'id' => $id,
];
$filename = md5(json_encode($action_data));
$result = filedb_put('cron/actions', $filename, serialize($action_data));
if ($result)
apiresult(['ok' => 'action has been succesfully scheduled']);
apiresult(['error' => 'could not create the action job'], 500);