mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 22:41:27 +00:00
Merge pull request #1467 from pixelfed/frontend-ui-refactor
Update Privacy Settings
This commit is contained in:
commit
773a8c1831
4 changed files with 185 additions and 4 deletions
|
@ -5,6 +5,7 @@ namespace App\Http\Controllers\Settings;
|
|||
use App\AccountLog;
|
||||
use App\EmailVerification;
|
||||
use App\Instance;
|
||||
use App\Follower;
|
||||
use App\Media;
|
||||
use App\Profile;
|
||||
use App\User;
|
||||
|
@ -170,4 +171,47 @@ trait PrivacySettings
|
|||
{
|
||||
return view('settings.privacy.blocked-keywords');
|
||||
}
|
||||
|
||||
public function privateAccountOptions(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
'mode' => 'required|string|in:keep-all,mutual-only,only-followers,remove-all',
|
||||
'duration' => 'required|integer|min:60|max:525600',
|
||||
]);
|
||||
$mode = $request->input('mode');
|
||||
$duration = $request->input('duration');
|
||||
// $newRequests = $request->input('newrequests');
|
||||
|
||||
$profile = Auth::user()->profile;
|
||||
$settings = Auth::user()->settings;
|
||||
|
||||
if($mode !== 'keep-all') {
|
||||
switch ($mode) {
|
||||
case 'mutual-only':
|
||||
$following = $profile->following()->pluck('profiles.id');
|
||||
Follower::whereFollowingId($profile->id)->whereNotIn('profile_id', $following)->delete();
|
||||
break;
|
||||
|
||||
case 'only-followers':
|
||||
$ts = now()->subMinutes($duration);
|
||||
Follower::whereFollowingId($profile->id)->where('created_at', '>', $ts)->delete();
|
||||
break;
|
||||
|
||||
case 'remove-all':
|
||||
Follower::whereFollowingId($profile->id)->delete();
|
||||
break;
|
||||
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
}
|
||||
}
|
||||
$profile->is_private = true;
|
||||
$settings->show_guests = false;
|
||||
$settings->show_discover = false;
|
||||
$settings->save();
|
||||
$profile->save();
|
||||
Cache::forget('profiles:private');
|
||||
return [200];
|
||||
}
|
||||
}
|
|
@ -50,7 +50,7 @@ class MentionPipeline implements ShouldQueue
|
|||
|
||||
$exists = Notification::whereProfileId($target)
|
||||
->whereActorId($actor->id)
|
||||
->whereAction('mention')
|
||||
->whereIn('action', ['mention', 'comment'])
|
||||
->whereItemId($status->id)
|
||||
->whereItemType('App\Status')
|
||||
->count();
|
||||
|
|
|
@ -10,10 +10,15 @@
|
|||
<p>
|
||||
<a class="btn btn-outline-secondary py-0 font-weight-bold" href="{{route('settings.privacy.muted-users')}}">Muted Users</a>
|
||||
<a class="btn btn-outline-secondary py-0 font-weight-bold" href="{{route('settings.privacy.blocked-users')}}">Blocked Users</a>
|
||||
<a class="btn btn-outline-secondary py-0 font-weight-bold" href="{{route('settings.privacy.blocked-keywords')}}">Blocked keywords</a>
|
||||
<a class="btn btn-outline-secondary py-0 font-weight-bold" href="{{route('settings.privacy.blocked-instances')}}">Blocked instances</a>
|
||||
</p>
|
||||
</div>
|
||||
<form method="post">
|
||||
@csrf
|
||||
<input type="hidden" name="pa_mode" value="">
|
||||
<input type="hidden" name="pa_duration" value="">
|
||||
<input type="hidden" name="pa_newrequests" value="">
|
||||
<div class="form-check pb-3">
|
||||
<input class="form-check-input" type="checkbox" name="is_private" id="is_private" {{$settings->is_private ? 'checked=""':''}}>
|
||||
<label class="form-check-label font-weight-bold" for="is_private">
|
||||
|
@ -29,6 +34,43 @@
|
|||
<p class="text-muted small help-text">When your account is visible to search engines, your information can be crawled and stored by search engines.</p>
|
||||
</div>
|
||||
|
||||
|
||||
{{-- <div class="form-check pb-3">
|
||||
<input class="form-check-input" type="checkbox" name="show_discover" id="show_discover" {{$settings->is_private ? 'disabled=""':''}} {{$settings->show_discover ? 'checked=""':''}}>
|
||||
<label class="form-check-label font-weight-bold" for="show_discover">
|
||||
{{__('Visible on discover')}}
|
||||
</label>
|
||||
<p class="text-muted small help-text">When this option is enabled, your profile and posts are used for discover recommendations. Only public profiles and posts are used.</p>
|
||||
</div> --}}
|
||||
{{--<div class="form-check pb-3">
|
||||
<input class="form-check-input" type="checkbox" value="" id="dm">
|
||||
<label class="form-check-label font-weight-bold" for="dm">
|
||||
{{__('Receive Direct Messages from anyone')}}
|
||||
</label>
|
||||
<p class="text-muted small help-text">If selected, you will be able to receive messages from any user even if you do not follow them.</p>
|
||||
</div>--}}
|
||||
{{-- <div class="form-check pb-3">
|
||||
<input class="form-check-input" type="checkbox" value="" id="srs" checked="">
|
||||
<label class="form-check-label font-weight-bold" for="srs">
|
||||
{{__('Hide sensitive content from search results')}}
|
||||
</label>
|
||||
<p class="text-muted small help-text">This prevents posts with potentially sensitive content from displaying in your search results.</p>
|
||||
</div> --}}
|
||||
{{-- <div class="form-check pb-3">
|
||||
<input class="form-check-input" type="checkbox" value="" id="rbma" checked="">
|
||||
<label class="form-check-label font-weight-bold" for="rbma">
|
||||
{{__('Remove blocked and muted accounts')}}
|
||||
</label>
|
||||
<p class="text-muted small help-text">Use this to eliminate search results from accounts you've blocked or muted.</p>
|
||||
</div>
|
||||
<div class="form-check pb-3">
|
||||
<input class="form-check-input" type="checkbox" value="" id="ssp">
|
||||
<label class="form-check-label font-weight-bold" for="ssp">
|
||||
{{__('Display media that may contain sensitive content')}}
|
||||
</label>
|
||||
<p class="text-muted small help-text">Show all media, including potentially sensitive content.</p>
|
||||
</div> --}}
|
||||
|
||||
<div class="form-check pb-3">
|
||||
<input class="form-check-input" type="checkbox" name="show_profile_follower_count" id="show_profile_follower_count" {{$settings->show_profile_follower_count ? 'checked=""':''}}>
|
||||
<label class="form-check-label font-weight-bold" for="show_profile_follower_count">
|
||||
|
@ -49,9 +91,104 @@
|
|||
<div class="form-group row mt-5 pt-5">
|
||||
<div class="col-12 text-right">
|
||||
<hr>
|
||||
<button type="submit" class="btn btn-primary font-weight-bold">Submit</button>
|
||||
<button type="submit" class="btn btn-primary font-weight-bold py-0 px-5">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="modal" tabindex="-1" role="dialog" id="pac_modal">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Confirm this action</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body p-3">
|
||||
<p class="font-weight-bold">Please select the type of private account you would like:</p>
|
||||
<div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" id="fm-1" name="pfType" value="keep-all" checked>
|
||||
<label class="form-check-label pb-2 font-weight-bold" for="fm-1">
|
||||
Keep existing followers
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" id="fm-2" name="pfType" value="mutual-only">
|
||||
<label class="form-check-label pb-2 font-weight-bold" for="fm-2">
|
||||
Only keep mutual followers
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" id="fm-3" name="pfType" value="only-followers">
|
||||
<label class="form-check-label pb-2 font-weight-bold" for="fm-3">
|
||||
Only followers that have followed you for atleast <select name="pfDuration">
|
||||
<option value="60">1 hour</option>
|
||||
<option value="1440">1 day</option>
|
||||
<option value="20160">2 weeks</option>
|
||||
<option value="43200">1 month</option>
|
||||
<option value="259200">6 months</option>
|
||||
<option value="525600">1 year</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" id="fm-4" name="pfType" value="remove-all">
|
||||
<label class="form-check-label font-weight-bold text-danger" for="fm-4">
|
||||
Remove existing followers
|
||||
</label>
|
||||
</div>
|
||||
{{-- <hr>
|
||||
<div class="form-check pt-3">
|
||||
<input class="form-check-input" type="checkbox" id="allowFollowRequest">
|
||||
<label class="form-check-label" for="allowFollowRequest">
|
||||
Allow new follow requests
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" name="blockNotifications" id="chk4">
|
||||
<label class="form-check-label" for="chk4">
|
||||
Block notifications from accounts I don't follow
|
||||
</label>
|
||||
</div> --}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-outline-secondary font-weight-bold py-0" data-dismiss="modal">Cancel</button>
|
||||
<button type="button" class="btn btn-primary font-weight-bold py-0" id="modal_confirm">Save</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@endsection
|
||||
@push('scripts')
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#is_private').on('click', function(e) {
|
||||
let el = $(this);
|
||||
if(el[0].checked) {
|
||||
$('#pac_modal').modal('show');
|
||||
}
|
||||
});
|
||||
|
||||
$('#modal_confirm').on('click', function(e) {
|
||||
$('#pac_modal').modal('hide')
|
||||
let mode = $('input[name="pfType"]:checked').val();
|
||||
let duration = $('select[name="pfDuration"]').val();
|
||||
// let newrequests = $('#allowFollowRequest')[0].checked;
|
||||
axios.post("{{route('settings.privacy.account')}}", {
|
||||
'mode': mode,
|
||||
'duration': duration,
|
||||
// 'newrequests': newrequests
|
||||
}).then(res => {
|
||||
window.location.href = window.location.href;
|
||||
}).catch(err => {
|
||||
swal('Error', 'An error occured. Please try again.', 'error');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
@endpush
|
|
@ -195,7 +195,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
|
|||
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');
|
||||
|
||||
Route::post('privacy/account', 'SettingsController@privateAccountOptions')->name('settings.privacy.account');
|
||||
Route::get('reports', 'SettingsController@reportsHome')->name('settings.reports');
|
||||
// Todo: Release in 0.7.2
|
||||
Route::group(['prefix' => 'remove', 'middleware' => 'dangerzone'], function() {
|
||||
|
|
Loading…
Reference in a new issue