Skip to content
Snippets Groups Projects
BlockController.php 3.17 KiB
Newer Older
  • Learn to ignore specific revisions
  • /**
     * @copyright  2021 Podlibre
     * @license    https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
     * @link       https://castopod.org/
     */
    
    
    use CodeIgniter\HTTP\RedirectResponse;
    
        public function attemptBlockActor(): RedirectResponse
    
                return redirect()
                    ->back()
                    ->withInput()
                    ->with('errors', $this->validator->getErrors());
            }
    
            $handle = $this->request->getPost('handle');
    
            if ($parts = split_handle($handle)) {
    
                    ($actor = get_or_create_actor($parts['username'], $parts['domain'])) === null
    
                        ->with('error', lang('Fediverse.messages.actorNotFound'));
    
                model('ActorModel')
                    ->blockActor($actor->id);
    
            return redirect()->back()
                ->with('message', lang('Fediverse.messages.blockActorSuccess', [
                    'actor' => $handle,
                ]));
    
        public function attemptUnblockActor(): RedirectResponse
    
                'actor_id' => 'required',
    
                return redirect()
                    ->back()
                    ->withInput()
                    ->with('errors', $this->validator->getErrors());
            }
    
    
            model('ActorModel')
                ->unblockActor((int) $this->request->getPost('actor_id'));
    
            return redirect()->back()
                ->with('message', lang('Fediverse.messages.unblockActorSuccess'));
    
        public function attemptBlockDomain(): RedirectResponse
    
                'domain' => 'required',
    
                return redirect()
                    ->back()
                    ->withInput()
                    ->with('errors', $this->validator->getErrors());
            }
    
    
            $domain = $this->request->getPost('domain');
    
            model('BlockedDomainModel')
    
                ->blockDomain($domain);
    
            return redirect()->back()
                ->with('message', lang('Fediverse.messages.blockDomainSuccess', [
                    'domain' => $domain,
                ]));
    
        public function attemptUnblockDomain(): RedirectResponse
    
                return redirect()
                    ->back()
                    ->withInput()
                    ->with('errors', $this->validator->getErrors());
            }
    
    
            $domain = $this->request->getPost('domain');
    
                ->unblockDomain($domain);
    
            return redirect()->back()
                ->with('message', lang('Fediverse.messages.unblockDomainSuccess', [
                    'domain' => $domain,
                ]));