mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-09 16:24:51 +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\Profile;
|
||||||
use App\Story;
|
use App\Story;
|
||||||
use App\User;
|
use App\User;
|
||||||
|
use App\UserSetting;
|
||||||
use App\UserFilter;
|
use App\UserFilter;
|
||||||
use League\Fractal;
|
use League\Fractal;
|
||||||
use App\Services\AccountService;
|
use App\Services\AccountService;
|
||||||
|
@ -236,6 +237,21 @@ class ProfileController extends Controller
|
||||||
|
|
||||||
abort_if($aiCheck, 404);
|
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) {
|
$data = Cache::remember('pf:atom:user-feed:by-id:' . $profile['id'], 900, function() use($pid, $profile) {
|
||||||
$items = DB::table('statuses')
|
$items = DB::table('statuses')
|
||||||
->whereProfileId($pid)
|
->whereProfileId($pid)
|
||||||
|
|
|
@ -20,11 +20,13 @@ trait PrivacySettings
|
||||||
|
|
||||||
public function privacy()
|
public function privacy()
|
||||||
{
|
{
|
||||||
$settings = Auth::user()->settings;
|
$user = Auth::user();
|
||||||
$is_private = Auth::user()->profile->is_private;
|
$settings = $user->settings;
|
||||||
$settings['is_private'] = (bool) $is_private;
|
$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)
|
public function privacyStore(Request $request)
|
||||||
|
@ -37,6 +39,7 @@ trait PrivacySettings
|
||||||
'public_dm',
|
'public_dm',
|
||||||
'show_profile_follower_count',
|
'show_profile_follower_count',
|
||||||
'show_profile_following_count',
|
'show_profile_following_count',
|
||||||
|
'show_atom',
|
||||||
];
|
];
|
||||||
|
|
||||||
$profile->is_suggestable = $request->input('is_suggestable') == 'on';
|
$profile->is_suggestable = $request->input('is_suggestable') == 'on';
|
||||||
|
@ -80,6 +83,7 @@ trait PrivacySettings
|
||||||
Cache::forget('user:account:id:' . $profile->user_id);
|
Cache::forget('user:account:id:' . $profile->user_id);
|
||||||
Cache::forget('profile:follower_count:' . $profile->id);
|
Cache::forget('profile:follower_count:' . $profile->id);
|
||||||
Cache::forget('profile:following_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('profile:embed:' . $profile->id);
|
||||||
Cache::forget('pf:acct:settings:hidden-followers:' . $profile->id);
|
Cache::forget('pf:acct:settings:hidden-followers:' . $profile->id);
|
||||||
Cache::forget('pf:acct:settings:hidden-following:' . $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>
|
<p class="text-muted small help-text">Display following count on profile</p>
|
||||||
</div>
|
</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="form-group row mt-5 pt-5">
|
||||||
<div class="col-12 text-right">
|
<div class="col-12 text-right">
|
||||||
<hr>
|
<hr>
|
||||||
|
|
Loading…
Reference in a new issue