mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-25 15:55:22 +00:00
Update PrivacySettings, add domainBlocks
This commit is contained in:
parent
cef451e588
commit
28da44beec
1 changed files with 12 additions and 33 deletions
|
@ -14,6 +14,7 @@ use App\Util\Lexer\PrettyNumber;
|
|||
use App\Util\ActivityPub\Helpers;
|
||||
use Auth, Cache, DB;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\UserDomainBlock;
|
||||
|
||||
trait PrivacySettings
|
||||
{
|
||||
|
@ -149,47 +150,25 @@ trait PrivacySettings
|
|||
|
||||
public function blockedInstances()
|
||||
{
|
||||
$pid = Auth::user()->profile->id;
|
||||
$filters = UserFilter::whereUserId($pid)
|
||||
->whereFilterableType('App\Instance')
|
||||
->whereFilterType('block')
|
||||
->orderByDesc('id')
|
||||
->paginate(10);
|
||||
return view('settings.privacy.blocked-instances', compact('filters'));
|
||||
// deprecated
|
||||
abort(404);
|
||||
}
|
||||
|
||||
public function domainBlocks()
|
||||
{
|
||||
return view('settings.privacy.domain-blocks');
|
||||
}
|
||||
|
||||
public function blockedInstanceStore(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
'domain' => 'required|url|min:1|max:120'
|
||||
]);
|
||||
$domain = $request->input('domain');
|
||||
if(Helpers::validateUrl($domain) == false) {
|
||||
return abort(400, 'Invalid domain');
|
||||
}
|
||||
$domain = parse_url($domain, PHP_URL_HOST);
|
||||
$instance = Instance::firstOrCreate(['domain' => $domain]);
|
||||
$filter = new UserFilter;
|
||||
$filter->user_id = Auth::user()->profile->id;
|
||||
$filter->filterable_id = $instance->id;
|
||||
$filter->filterable_type = 'App\Instance';
|
||||
$filter->filter_type = 'block';
|
||||
$filter->save();
|
||||
return response()->json(['msg' => 200]);
|
||||
// deprecated
|
||||
abort(404);
|
||||
}
|
||||
|
||||
public function blockedInstanceUnblock(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
'id' => 'required|integer|min:1'
|
||||
]);
|
||||
$pid = Auth::user()->profile->id;
|
||||
|
||||
$filter = UserFilter::whereFilterableType('App\Instance')
|
||||
->whereUserId($pid)
|
||||
->findOrFail($request->input('id'));
|
||||
$filter->delete();
|
||||
return redirect(route('settings.privacy.blocked-instances'));
|
||||
// deprecated
|
||||
abort(404);
|
||||
}
|
||||
|
||||
public function blockedKeywords()
|
||||
|
|
Loading…
Reference in a new issue