Bläddra i källkod

Update AccountService

Daniel Supernault 3 år sedan
förälder
incheckning
a578035bbc
1 ändrade filer med 41 tillägg och 0 borttagningar
  1. 41 0
      app/Services/AccountService.php

+ 41 - 0
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;
+		});
+	}
 }