Fix default severity for domain blocks

This commit is contained in:
Emelia Smith 2024-03-30 00:54:55 +01:00
parent 96a226d90c
commit 626c87a420
No known key found for this signature in database

View file

@ -58,14 +58,15 @@ class DomainBlocksController extends ApiController {
]); ]);
$domain = $request->input('domain'); $domain = $request->input('domain');
$severity = $request->input('severity'); $severity = $request->input('severity', 'silence');
$private_comment = $request->input('private_comment'); $private_comment = $request->input('private_comment');
abort_if(!strpos($domain, '.'), 400, 'Invalid domain'); abort_if(!strpos($domain, '.'), 400, 'Invalid domain');
abort_if(!filter_var($domain, FILTER_VALIDATE_DOMAIN), 400, 'Invalid domain'); abort_if(!filter_var($domain, FILTER_VALIDATE_DOMAIN), 400, 'Invalid domain');
// This is because Pixelfed can't currently support wildcard domain blocks
// We have to find something that could plausibly be an instance
$parts = explode('.', $domain); $parts = explode('.', $domain);
if ($parts[0] == '*') { if ($parts[0] == '*') {
// If we only have two parts, e.g., "*", "example", then we want to fail: // If we only have two parts, e.g., "*", "example", then we want to fail:
abort_if(count($parts) <= 2, 400, 'Invalid domain: This API does not support wildcard domain blocks yet'); abort_if(count($parts) <= 2, 400, 'Invalid domain: This API does not support wildcard domain blocks yet');
@ -109,7 +110,7 @@ class DomainBlocksController extends ApiController {
'obfuscate' => 'sometimes|required|boolean' 'obfuscate' => 'sometimes|required|boolean'
]); ]);
$severity = $request->input('severity'); $severity = $request->input('severity', 'silence');
$private_comment = $request->input('private_comment'); $private_comment = $request->input('private_comment');
$domain_block = Instance::moderated()->find($id); $domain_block = Instance::moderated()->find($id);