Newer
Older
<?php
/**
* @copyright 2021 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace ActivityPub\Controllers;
use CodeIgniter\Controller;
class BlockController extends Controller
{

Yassine Doghri
committed
/**
* @var string[]
*/
protected $helpers = ['activitypub'];
public function attemptBlockActor()
{
$rules = [
'handle' => 'required',
];
if (!$this->validate($rules)) {
return redirect()
->back()
->withInput()
->with('errors', $this->validator->getErrors());
}
$handle = $this->request->getPost('handle');
if ($parts = split_handle($handle)) {
extract($parts);

Yassine Doghri
committed
if (($actor = get_or_create_actor($username, $domain)) === null) {
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
return redirect()
->back()
->withInput()
->with('error', 'Actor not found.');
}
model('ActorModel')->blockActor($actor->id);
}
return redirect()->back();
}
function attemptBlockDomain()
{
$rules = [
'domain' => 'required',
];
if (!$this->validate($rules)) {
return redirect()
->back()
->withInput()
->with('errors', $this->validator->getErrors());
}
model('BlockedDomainModel')->blockDomain(
$this->request->getPost('domain'),
);
return redirect()->back();
}
function attemptUnblockActor()
{
$rules = [
'actor_id' => 'required',
];
if (!$this->validate($rules)) {
return redirect()
->back()
->withInput()
->with('errors', $this->validator->getErrors());
}
model('ActorModel')->unblockActor($this->request->getPost('actor_id'));
return redirect()->back();
}
function attemptUnblockDomain()
{
$rules = [
'domain' => 'required',
];
if (!$this->validate($rules)) {
return redirect()
->back()
->withInput()
->with('errors', $this->validator->getErrors());
}
model('BlockedDomainModel')->unblockDomain(
$this->request->getPost('domain'),
);
return redirect()->back();
}
}