Merge pull request #4396 from pixelfed/staging

Staging
This commit is contained in:
daniel 2023-05-19 04:57:09 -06:00 committed by GitHub
commit a36d2b1d2b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 71 additions and 4 deletions

View file

@ -43,6 +43,7 @@
- Update atom view, fix atom feed bug ([63b72c42](https://github.com/pixelfed/pixelfed/commit/63b72c42)) - Update atom view, fix atom feed bug ([63b72c42](https://github.com/pixelfed/pixelfed/commit/63b72c42))
- Update StatusController, disable post embeds from spam accounts ([c167af43](https://github.com/pixelfed/pixelfed/commit/c167af43)) - Update StatusController, disable post embeds from spam accounts ([c167af43](https://github.com/pixelfed/pixelfed/commit/c167af43))
- Update ProfileController, require login to view spam accounts, and disable profile embeds and atom feeds for spam accounts ([dd2f5bb9](https://github.com/pixelfed/pixelfed/commit/dd2f5bb9)) - Update ProfileController, require login to view spam accounts, and disable profile embeds and atom feeds for spam accounts ([dd2f5bb9](https://github.com/pixelfed/pixelfed/commit/dd2f5bb9))
- Update Settings, allow users to disable atom feeds ([3662d3de](https://github.com/pixelfed/pixelfed/commit/3662d3de))
- ([](https://github.com/pixelfed/pixelfed/commit/)) - ([](https://github.com/pixelfed/pixelfed/commit/))
## [v0.11.6 (2023-05-03)](https://github.com/pixelfed/pixelfed/compare/v0.11.5...v0.11.6) ## [v0.11.6 (2023-05-03)](https://github.com/pixelfed/pixelfed/compare/v0.11.5...v0.11.6)

View file

@ -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)

View file

@ -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);

View file

@ -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');
});
}
};

View file

@ -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>