mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 06:21:27 +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 App\Util\ActivityPub\Helpers;
|
||||||
use Auth, Cache, DB;
|
use Auth, Cache, DB;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use App\Models\UserDomainBlock;
|
||||||
|
|
||||||
trait PrivacySettings
|
trait PrivacySettings
|
||||||
{
|
{
|
||||||
|
@ -149,47 +150,25 @@ trait PrivacySettings
|
||||||
|
|
||||||
public function blockedInstances()
|
public function blockedInstances()
|
||||||
{
|
{
|
||||||
$pid = Auth::user()->profile->id;
|
// deprecated
|
||||||
$filters = UserFilter::whereUserId($pid)
|
abort(404);
|
||||||
->whereFilterableType('App\Instance')
|
}
|
||||||
->whereFilterType('block')
|
|
||||||
->orderByDesc('id')
|
public function domainBlocks()
|
||||||
->paginate(10);
|
{
|
||||||
return view('settings.privacy.blocked-instances', compact('filters'));
|
return view('settings.privacy.domain-blocks');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function blockedInstanceStore(Request $request)
|
public function blockedInstanceStore(Request $request)
|
||||||
{
|
{
|
||||||
$this->validate($request, [
|
// deprecated
|
||||||
'domain' => 'required|url|min:1|max:120'
|
abort(404);
|
||||||
]);
|
|
||||||
$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]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function blockedInstanceUnblock(Request $request)
|
public function blockedInstanceUnblock(Request $request)
|
||||||
{
|
{
|
||||||
$this->validate($request, [
|
// deprecated
|
||||||
'id' => 'required|integer|min:1'
|
abort(404);
|
||||||
]);
|
|
||||||
$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'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function blockedKeywords()
|
public function blockedKeywords()
|
||||||
|
|
Loading…
Reference in a new issue