diff --git a/CHANGELOG.md b/CHANGELOG.md index f6115fca3..2a1328b78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ - 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 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/)) ## [v0.11.6 (2023-05-03)](https://github.com/pixelfed/pixelfed/compare/v0.11.5...v0.11.6) diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index 408c5be32..df25b2d7b 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -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) diff --git a/app/Http/Controllers/Settings/PrivacySettings.php b/app/Http/Controllers/Settings/PrivacySettings.php index 3cee63322..3d1cd4515 100644 --- a/app/Http/Controllers/Settings/PrivacySettings.php +++ b/app/Http/Controllers/Settings/PrivacySettings.php @@ -20,11 +20,13 @@ trait PrivacySettings public function privacy() { - $settings = Auth::user()->settings; - $is_private = Auth::user()->profile->is_private; - $settings['is_private'] = (bool) $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); diff --git a/database/migrations/2023_05_19_102013_add_enable_atom_feed_to_user_settings_table.php b/database/migrations/2023_05_19_102013_add_enable_atom_feed_to_user_settings_table.php new file mode 100644 index 000000000..5aee6d8b8 --- /dev/null +++ b/database/migrations/2023_05_19_102013_add_enable_atom_feed_to_user_settings_table.php @@ -0,0 +1,28 @@ +boolean('show_atom')->default(true); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('user_settings', function (Blueprint $table) { + $table->dropColumn('show_atom'); + }); + } +}; diff --git a/resources/views/settings/privacy.blade.php b/resources/views/settings/privacy.blade.php index 8c4142908..78ead55ee 100644 --- a/resources/views/settings/privacy.blade.php +++ b/resources/views/settings/privacy.blade.php @@ -88,6 +88,24 @@
Display following count on profile
+ @if(!$settings->is_private) +Enable your profile atom feed. Only public profiles are eligible.
+ @if($settings->show_atom) + + @endif +