From 402a4607c93b1f4fd7998db520f848633ece8f26 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 29 Feb 2024 04:51:56 -0700 Subject: [PATCH 1/3] Update Inbox, fix flag validation condition, allow profile reports --- app/Util/ActivityPub/Inbox.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Util/ActivityPub/Inbox.php b/app/Util/ActivityPub/Inbox.php index ed6b964e8..4ab87f40b 100644 --- a/app/Util/ActivityPub/Inbox.php +++ b/app/Util/ActivityPub/Inbox.php @@ -1283,7 +1283,7 @@ class Inbox } } - if(!$accountId || !$objects->count()) { + if(!$accountId && !$objects->count()) { return; } From 542d110673fb2e5fe0506de931f1ff16c86c24ac Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 29 Feb 2024 04:59:13 -0700 Subject: [PATCH 2/3] Update AccountTransformer, fix follower/following count visibility bug --- app/Http/Controllers/Api/ApiV1Controller.php | 2 ++ .../Controllers/Settings/PrivacySettings.php | 17 ++++++----- app/Transformer/Api/AccountTransformer.php | 30 +++++++++++++++---- 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/app/Http/Controllers/Api/ApiV1Controller.php b/app/Http/Controllers/Api/ApiV1Controller.php index 0205648e8..c8728bcf4 100644 --- a/app/Http/Controllers/Api/ApiV1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Controller.php @@ -409,6 +409,7 @@ class ApiV1Controller extends Controller if($settings->show_profile_follower_count != $show_profile_follower_count) { $settings->show_profile_follower_count = $show_profile_follower_count; $changes = true; + Cache::forget('pf:acct-trans:hideFollowers:' . $profile->id); } } @@ -417,6 +418,7 @@ class ApiV1Controller extends Controller if($settings->show_profile_following_count != $show_profile_following_count) { $settings->show_profile_following_count = $show_profile_following_count; $changes = true; + Cache::forget('pf:acct-trans:hideFollowing:' . $profile->id); } } diff --git a/app/Http/Controllers/Settings/PrivacySettings.php b/app/Http/Controllers/Settings/PrivacySettings.php index bd2222d48..6697bf3c8 100644 --- a/app/Http/Controllers/Settings/PrivacySettings.php +++ b/app/Http/Controllers/Settings/PrivacySettings.php @@ -84,14 +84,17 @@ trait PrivacySettings } $settings->save(); } - Cache::forget('profile:settings:' . $profile->id); + $pid = $profile->id; + Cache::forget('profile:settings:' . $pid); 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); + Cache::forget('profile:follower_count:' . $pid); + Cache::forget('profile:following_count:' . $pid); + Cache::forget('profile:atom:enabled:' . $pid); + Cache::forget('profile:embed:' . $pid); + Cache::forget('pf:acct:settings:hidden-followers:' . $pid); + Cache::forget('pf:acct:settings:hidden-following:' . $pid); + Cache::forget('pf:acct-trans:hideFollowing:' . $pid); + Cache::forget('pf:acct-trans:hideFollowers:' . $pid); return redirect(route('settings.privacy'))->with('status', 'Settings successfully updated!'); } diff --git a/app/Transformer/Api/AccountTransformer.php b/app/Transformer/Api/AccountTransformer.php index 6c6fa17e4..52026eb8e 100644 --- a/app/Transformer/Api/AccountTransformer.php +++ b/app/Transformer/Api/AccountTransformer.php @@ -6,14 +6,15 @@ use Auth; use Cache; use App\Profile; use App\User; +use App\UserSetting; use League\Fractal; use App\Services\PronounService; class AccountTransformer extends Fractal\TransformerAbstract { - protected $defaultIncludes = [ - // 'relationship', - ]; + protected $defaultIncludes = [ + // 'relationship', + ]; public function transform(Profile $profile) { @@ -26,6 +27,25 @@ class AccountTransformer extends Fractal\TransformerAbstract }); $local = $profile->private_key != null; + $local = $profile->user_id && $profile->private_key != null; + $hideFollowing = false; + $hideFollowers = false; + if($local) { + $hideFollowing = Cache::remember('pf:acct-trans:hideFollowing:' . $profile->id, 2592000, function() use($profile) { + $settings = UserSetting::whereUserId($profile->user_id)->first(); + if(!$settings) { + return false; + } + return $settings->show_profile_following_count == false; + }); + $hideFollowers = Cache::remember('pf:acct-trans:hideFollowers:' . $profile->id, 2592000, function() use($profile) { + $settings = UserSetting::whereUserId($profile->user_id)->first(); + if(!$settings) { + return false; + } + return $settings->show_profile_follower_count == false; + }); + } $is_admin = !$local ? false : in_array($profile->id, $adminIds); $acct = $local ? $profile->username : substr($profile->username, 1); $username = $local ? $profile->username : explode('@', $acct)[0]; @@ -36,8 +56,8 @@ class AccountTransformer extends Fractal\TransformerAbstract 'display_name' => $profile->name, 'discoverable' => true, 'locked' => (bool) $profile->is_private, - 'followers_count' => (int) $profile->followers_count, - 'following_count' => (int) $profile->following_count, + 'followers_count' => $hideFollowers ? 0 : (int) $profile->followers_count, + 'following_count' => $hideFollowing ? 0 : (int) $profile->following_count, 'statuses_count' => (int) $profile->status_count, 'note' => $profile->bio ?? '', 'note_text' => $profile->bio ? strip_tags($profile->bio) : null, From d5a6d9cc8d25af908eb17364f57e7ab734131588 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 29 Feb 2024 05:00:44 -0700 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b0b7fc21..f8b4fde43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,8 @@ - Update AdminReportController, add story report support ([a16309ac](https://github.com/pixelfed/pixelfed/commit/a16309ac)) - Update kb, add email confirmation issues page ([2f48df8c](https://github.com/pixelfed/pixelfed/commit/2f48df8c)) - Update AdminCuratedRegisterController, filter confirmation activities from activitylog ([ab9ecb6e](https://github.com/pixelfed/pixelfed/commit/ab9ecb6e)) +- Update Inbox, fix flag validation condition, allow profile reports ([402a4607](https://github.com/pixelfed/pixelfed/commit/402a4607)) +- Update AccountTransformer, fix follower/following count visibility bug ([542d1106](https://github.com/pixelfed/pixelfed/commit/542d1106)) - ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.11.12 (2024-02-16)](https://github.com/pixelfed/pixelfed/compare/v0.11.11...v0.11.12)