From a578035bbc057e25a4af5627fbf3965c3d04a17a Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 8 Jan 2022 04:03:45 -0700 Subject: [PATCH] Update AccountService --- app/Services/AccountService.php | 41 +++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/app/Services/AccountService.php b/app/Services/AccountService.php index 62996a83..3813f70f 100644 --- a/app/Services/AccountService.php +++ b/app/Services/AccountService.php @@ -5,6 +5,7 @@ namespace App\Services; use Cache; use App\Profile; use App\Status; +use App\User; use App\UserSetting; use App\Transformer\Api\AccountTransformer; use League\Fractal; @@ -174,4 +175,44 @@ class AccountService return (string) $profile->id; }); } + + public static function hiddenFollowers($id) + { + $account = self::get($id, true); + if(!$account || !isset($account['local']) || $account['local'] == false) { + return false; + } + + return Cache::remember('pf:acct:settings:hidden-followers:' . $id, 43200, function() use($id) { + $user = User::whereProfileId($id)->first(); + if(!$user) { + return false; + } + $settings = UserSetting::whereUserId($user->id)->first(); + if($settings) { + return $settings->show_profile_follower_count == false; + } + return false; + }); + } + + public static function hiddenFollowing($id) + { + $account = self::get($id, true); + if(!$account || !isset($account['local']) || $account['local'] == false) { + return false; + } + + return Cache::remember('pf:acct:settings:hidden-following:' . $id, 43200, function() use($id) { + $user = User::whereProfileId($id)->first(); + if(!$user) { + return false; + } + $settings = UserSetting::whereUserId($user->id)->first(); + if($settings) { + return $settings->show_profile_following_count == false; + } + return false; + }); + } }