mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-22 07:42:41 +00:00
Add update and delete
This commit is contained in:
parent
652654e24f
commit
21466556d4
3 changed files with 43 additions and 2 deletions
|
@ -35,4 +35,4 @@ class ApiController extends Controller {
|
|||
return $v != null;
|
||||
}, ARRAY_FILTER_USE_BOTH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,4 +73,43 @@ class DomainBlocksController extends ApiController {
|
|||
|
||||
return $this->json(new DomainBlockResource($domain_block));
|
||||
}
|
||||
}
|
||||
|
||||
public function update(Request $request, $id) {
|
||||
$this->validate($request, [
|
||||
'severity' => [
|
||||
'sometimes',
|
||||
Rule::in(['noop', 'silence', 'suspend'])
|
||||
],
|
||||
'reject_media' => 'sometimes|required|boolean',
|
||||
'reject_reports' => 'sometimes|required|boolean',
|
||||
'private_comment' => 'sometimes|string|min:1|max:1000',
|
||||
'public_comment' => 'sometimes|string|min:1|max:1000',
|
||||
'obfuscate' => 'sometimes|required|boolean'
|
||||
]);
|
||||
|
||||
$severity = $request->input('severity');
|
||||
$private_comment = $request->input('private_comment');
|
||||
|
||||
$instance = Instance::moderated()->findOrFail($id);
|
||||
|
||||
$instance->banned = $severity === 'suspend';
|
||||
$instance->unlisted = $severity === 'silence';
|
||||
$instance->notes = [$private_comment];
|
||||
$instance->save();
|
||||
|
||||
InstanceService::refresh();
|
||||
|
||||
return $this->json(new DomainBlockResource($instance));
|
||||
}
|
||||
|
||||
public function delete(Request $request, $id) {
|
||||
$instance = Instance::moderated()->findOrFail($id);
|
||||
$instance->banned = false;
|
||||
$instance->unlisted = false;
|
||||
$instance->save();
|
||||
|
||||
InstanceService::refresh();
|
||||
|
||||
return $this->json([], [], 200);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,6 +106,8 @@ Route::group(['prefix' => 'api'], function() use($middleware) {
|
|||
Route::get('domain_blocks', 'Api\V1\Admin\DomainBlocksController@index')->middleware($middleware);
|
||||
Route::post('domain_blocks', 'Api\V1\Admin\DomainBlocksController@create')->middleware($middleware);
|
||||
Route::get('domain_blocks/{id}', 'Api\V1\Admin\DomainBlocksController@show')->middleware($middleware);
|
||||
Route::put('domain_blocks/{id}', 'Api\V1\Admin\DomainBlocksController@update')->middleware($middleware);
|
||||
Route::delete('domain_blocks/{id}', 'Api\V1\Admin\DomainBlocksController@delete')->middleware($middleware);
|
||||
})->middleware($middleware);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue