mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 14:31:26 +00:00
Update user domain block commands
This commit is contained in:
parent
d8f46f47a1
commit
73a0f528ab
2 changed files with 16 additions and 9 deletions
|
@ -34,6 +34,10 @@ class AddUserDomainBlock extends Command
|
||||||
$domain = text('Enter domain you want to block');
|
$domain = text('Enter domain you want to block');
|
||||||
$domain = strtolower($domain);
|
$domain = strtolower($domain);
|
||||||
$domain = $this->validateDomain($domain);
|
$domain = $this->validateDomain($domain);
|
||||||
|
if(!$domain || empty($domain)) {
|
||||||
|
$this->error('Invalid domain');
|
||||||
|
return;
|
||||||
|
}
|
||||||
$this->processBlocks($domain);
|
$this->processBlocks($domain);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -41,7 +45,6 @@ class AddUserDomainBlock extends Command
|
||||||
protected function validateDomain($domain)
|
protected function validateDomain($domain)
|
||||||
{
|
{
|
||||||
if(!strpos($domain, '.')) {
|
if(!strpos($domain, '.')) {
|
||||||
$this->error('Invalid domain');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,14 +56,13 @@ class AddUserDomainBlock extends Command
|
||||||
$domain = str_replace('http://', '', $domain);
|
$domain = str_replace('http://', '', $domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$domain = strtolower(parse_url('https://' . $domain, PHP_URL_HOST));
|
||||||
|
|
||||||
$valid = filter_var($domain, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME|FILTER_NULL_ON_FAILURE);
|
$valid = filter_var($domain, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME|FILTER_NULL_ON_FAILURE);
|
||||||
if(!$valid) {
|
if(!$valid) {
|
||||||
$this->error('Invalid domain');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$domain = strtolower(parse_url('https://' . $domain, PHP_URL_HOST));
|
|
||||||
|
|
||||||
if($domain === config('pixelfed.domain.app')) {
|
if($domain === config('pixelfed.domain.app')) {
|
||||||
$this->error('Invalid domain');
|
$this->error('Invalid domain');
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -34,6 +34,10 @@ class DeleteUserDomainBlock extends Command
|
||||||
$domain = text('Enter domain you want to unblock');
|
$domain = text('Enter domain you want to unblock');
|
||||||
$domain = strtolower($domain);
|
$domain = strtolower($domain);
|
||||||
$domain = $this->validateDomain($domain);
|
$domain = $this->validateDomain($domain);
|
||||||
|
if(!$domain || empty($domain)) {
|
||||||
|
$this->error('Invalid domain');
|
||||||
|
return;
|
||||||
|
}
|
||||||
$this->processUnblocks($domain);
|
$this->processUnblocks($domain);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -41,7 +45,6 @@ class DeleteUserDomainBlock extends Command
|
||||||
protected function validateDomain($domain)
|
protected function validateDomain($domain)
|
||||||
{
|
{
|
||||||
if(!strpos($domain, '.')) {
|
if(!strpos($domain, '.')) {
|
||||||
$this->error('Invalid domain');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,16 +56,14 @@ class DeleteUserDomainBlock extends Command
|
||||||
$domain = str_replace('http://', '', $domain);
|
$domain = str_replace('http://', '', $domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$domain = strtolower(parse_url('https://' . $domain, PHP_URL_HOST));
|
||||||
|
|
||||||
$valid = filter_var($domain, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME|FILTER_NULL_ON_FAILURE);
|
$valid = filter_var($domain, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME|FILTER_NULL_ON_FAILURE);
|
||||||
if(!$valid) {
|
if(!$valid) {
|
||||||
$this->error('Invalid domain');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$domain = strtolower(parse_url('https://' . $domain, PHP_URL_HOST));
|
|
||||||
|
|
||||||
if($domain === config('pixelfed.domain.app')) {
|
if($domain === config('pixelfed.domain.app')) {
|
||||||
$this->error('Invalid domain');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,6 +78,10 @@ class DeleteUserDomainBlock extends Command
|
||||||
protected function processUnblocks($domain)
|
protected function processUnblocks($domain)
|
||||||
{
|
{
|
||||||
DefaultDomainBlock::whereDomain($domain)->delete();
|
DefaultDomainBlock::whereDomain($domain)->delete();
|
||||||
|
if(!UserDomainBlock::whereDomain($domain)->count()) {
|
||||||
|
$this->info('No results found!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
progress(
|
progress(
|
||||||
label: 'Updating user domain blocks...',
|
label: 'Updating user domain blocks...',
|
||||||
steps: UserDomainBlock::whereDomain($domain)->lazyById(500),
|
steps: UserDomainBlock::whereDomain($domain)->lazyById(500),
|
||||||
|
|
Loading…
Reference in a new issue