mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 06:21:27 +00:00
Update Settings, allow users to disable atom feeds
This commit is contained in:
parent
6622a851bb
commit
3662d3defe
4 changed files with 70 additions and 4 deletions
|
@ -13,6 +13,7 @@ use App\FollowRequest;
|
|||
use App\Profile;
|
||||
use App\Story;
|
||||
use App\User;
|
||||
use App\UserSetting;
|
||||
use App\UserFilter;
|
||||
use League\Fractal;
|
||||
use App\Services\AccountService;
|
||||
|
@ -236,6 +237,21 @@ class ProfileController extends Controller
|
|||
|
||||
abort_if($aiCheck, 404);
|
||||
|
||||
$enabled = Cache::remember('profile:atom:enabled:' . $profile['id'], 84600, function() use ($profile) {
|
||||
$uid = User::whereProfileId($profile['id'])->first();
|
||||
if(!$uid) {
|
||||
return false;
|
||||
}
|
||||
$settings = UserSetting::whereUserId($uid->id)->first();
|
||||
if(!$settings) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $settings->show_atom;
|
||||
});
|
||||
|
||||
abort_if(!$enabled, 404);
|
||||
|
||||
$data = Cache::remember('pf:atom:user-feed:by-id:' . $profile['id'], 900, function() use($pid, $profile) {
|
||||
$items = DB::table('statuses')
|
||||
->whereProfileId($pid)
|
||||
|
|
|
@ -20,11 +20,13 @@ trait PrivacySettings
|
|||
|
||||
public function privacy()
|
||||
{
|
||||
$settings = Auth::user()->settings;
|
||||
$is_private = Auth::user()->profile->is_private;
|
||||
$user = Auth::user();
|
||||
$settings = $user->settings;
|
||||
$profile = $user->profile;
|
||||
$is_private = $profile->is_private;
|
||||
$settings['is_private'] = (bool) $is_private;
|
||||
|
||||
return view('settings.privacy', compact('settings'));
|
||||
return view('settings.privacy', compact('settings', 'profile'));
|
||||
}
|
||||
|
||||
public function privacyStore(Request $request)
|
||||
|
@ -37,6 +39,7 @@ trait PrivacySettings
|
|||
'public_dm',
|
||||
'show_profile_follower_count',
|
||||
'show_profile_following_count',
|
||||
'show_atom',
|
||||
];
|
||||
|
||||
$profile->is_suggestable = $request->input('is_suggestable') == 'on';
|
||||
|
@ -80,6 +83,7 @@ trait PrivacySettings
|
|||
Cache::forget('user:account:id:' . $profile->user_id);
|
||||
Cache::forget('profile:follower_count:' . $profile->id);
|
||||
Cache::forget('profile:following_count:' . $profile->id);
|
||||
Cache::forget('profile:atom:enabled:' . $profile->id);
|
||||
Cache::forget('profile:embed:' . $profile->id);
|
||||
Cache::forget('pf:acct:settings:hidden-followers:' . $profile->id);
|
||||
Cache::forget('pf:acct:settings:hidden-following:' . $profile->id);
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('user_settings', function (Blueprint $table) {
|
||||
$table->boolean('show_atom')->default(true);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('user_settings', function (Blueprint $table) {
|
||||
$table->dropColumn('show_atom');
|
||||
});
|
||||
}
|
||||
};
|
|
@ -88,6 +88,24 @@
|
|||
<p class="text-muted small help-text">Display following count on profile</p>
|
||||
</div>
|
||||
|
||||
@if(!$settings->is_private)
|
||||
<div class="form-check pb-3">
|
||||
<input class="form-check-input" type="checkbox" name="show_atom" id="show_atom" {{$settings->show_atom ? 'checked=""':''}}>
|
||||
<label class="form-check-label font-weight-bold" for="show_atom">
|
||||
{{__('Enable Atom Feed')}}
|
||||
</label>
|
||||
<p class="text-muted small help-text mb-0">Enable your profile atom feed. Only public profiles are eligible.</p>
|
||||
@if($settings->show_atom)
|
||||
<p class="small">
|
||||
<a href="{{$profile->permalink('.atom')}}" class="text-success font-weight-bold small" target="_blank">
|
||||
{{ $profile->permalink('.atom') }}
|
||||
<i class="far fa-external-link ml-1 text-muted" style="opacity: 0.5"></i>
|
||||
</a>
|
||||
</p>
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="form-group row mt-5 pt-5">
|
||||
<div class="col-12 text-right">
|
||||
<hr>
|
||||
|
|
Loading…
Reference in a new issue