mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-26 23:13:17 +00:00
Merge pull request #1458 from pixelfed/frontend-ui-refactor
Fixes #1453
This commit is contained in:
commit
a47fd755e6
6 changed files with 34 additions and 9 deletions
|
@ -56,7 +56,7 @@ ACTIVITYPUB_SHAREDINBOX=false
|
|||
# php artisan optimize:clear
|
||||
# php artisan optimize
|
||||
|
||||
PF_COSTAR_ENABLED=false
|
||||
PF_COSTAR_ENABLED=true
|
||||
CS_BLOCKED_DOMAINS='gab.com,gab.ai,develop.gab.com'
|
||||
CS_CW_DOMAINS='switter.at'
|
||||
CS_UNLISTED_DOMAINS='example.org,example.net,example.com'
|
||||
|
|
|
@ -10,6 +10,7 @@ use App\Profile;
|
|||
use App\User;
|
||||
use App\UserFilter;
|
||||
use App\Util\Lexer\PrettyNumber;
|
||||
use App\Util\ActivityPub\Helpers;
|
||||
use Auth, Cache, DB;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
|
@ -134,9 +135,13 @@ trait PrivacySettings
|
|||
public function blockedInstanceStore(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
'domain' => 'required|active_url'
|
||||
'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;
|
||||
|
|
|
@ -146,9 +146,13 @@ class Helpers {
|
|||
|
||||
$host = parse_url($valid, PHP_URL_HOST);
|
||||
|
||||
if(count(dns_get_record($host, DNS_A | DNS_AAAA)) == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(config('costar.enabled') == true) {
|
||||
if(
|
||||
(config('costar.domain.block') != null && in_array($host, config('costar.domain.block')) == true) ||
|
||||
(config('costar.domain.block') != null && Str::contains($host, config('costar.domain.block')) == true) ||
|
||||
(config('costar.actor.block') != null && in_array($url, config('costar.actor.block')) == true)
|
||||
) {
|
||||
return false;
|
||||
|
|
|
@ -48,4 +48,9 @@ trait User {
|
|||
{
|
||||
return 500;
|
||||
}
|
||||
|
||||
public function getMaxInstanceBansPerDayAttribute()
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
}
|
|
@ -64,23 +64,34 @@
|
|||
},
|
||||
})
|
||||
.then(val => {
|
||||
if (!val) throw null;
|
||||
if (!val) {
|
||||
swal.stopLoading();
|
||||
swal.close();
|
||||
return;
|
||||
};
|
||||
let msg = 'The URL you have entered is not valid, please try again.'
|
||||
try {
|
||||
let validator = new URL(val);
|
||||
if(!validator.hostname) throw null;
|
||||
if(!validator.hostname || validator.protocol != 'https:') {
|
||||
swal.stopLoading();
|
||||
swal.close();
|
||||
swal('Invalid URL', msg, 'error');
|
||||
return;
|
||||
};
|
||||
axios.post(window.location.href, {
|
||||
domain: validator.hostname
|
||||
domain: validator.href
|
||||
}).then(res => {
|
||||
window.location.href = window.location.href;
|
||||
}).catch(err => {
|
||||
swal.stopLoading();
|
||||
swal.close();
|
||||
swal('An Error Occured', 'An error occured, please try again later.', 'error');
|
||||
swal('Invalid URL', msg, 'error');
|
||||
return;
|
||||
});
|
||||
} catch(e) {
|
||||
swal.stopLoading();
|
||||
swal.close();
|
||||
swal('An Error Occured', 'An error occured, please try again later.', 'error');
|
||||
swal('Invalid URL', msg, 'error');
|
||||
}
|
||||
})
|
||||
});
|
||||
|
|
|
@ -192,7 +192,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
|
|||
Route::get('privacy/blocked-users', 'SettingsController@blockedUsers')->name('settings.privacy.blocked-users');
|
||||
Route::post('privacy/blocked-users', 'SettingsController@blockedUsersUpdate');
|
||||
Route::get('privacy/blocked-instances', 'SettingsController@blockedInstances')->name('settings.privacy.blocked-instances');
|
||||
Route::post('privacy/blocked-instances', 'SettingsController@blockedInstanceStore');
|
||||
Route::post('privacy/blocked-instances', 'SettingsController@blockedInstanceStore')->middleware('throttle:maxInstanceBansPerDay,1440');
|
||||
Route::post('privacy/blocked-instances/unblock', 'SettingsController@blockedInstanceUnblock')->name('settings.privacy.blocked-instances.unblock');
|
||||
Route::get('privacy/blocked-keywords', 'SettingsController@blockedKeywords')->name('settings.privacy.blocked-keywords');
|
||||
|
||||
|
|
Loading…
Reference in a new issue