forked from mirror/pixelfed
Update RelationshipTransformer
This commit is contained in:
parent
f47d2113b1
commit
74a719bdfd
|
@ -3,7 +3,10 @@
|
||||||
namespace App\Transformer\Api;
|
namespace App\Transformer\Api;
|
||||||
|
|
||||||
use Auth;
|
use Auth;
|
||||||
use App\Profile;
|
use App\{
|
||||||
|
FollowRequest,
|
||||||
|
Profile
|
||||||
|
};
|
||||||
use League\Fractal;
|
use League\Fractal;
|
||||||
|
|
||||||
class RelationshipTransformer extends Fractal\TransformerAbstract
|
class RelationshipTransformer extends Fractal\TransformerAbstract
|
||||||
|
@ -12,6 +15,12 @@ class RelationshipTransformer extends Fractal\TransformerAbstract
|
||||||
{
|
{
|
||||||
$auth = Auth::check();
|
$auth = Auth::check();
|
||||||
$user = $auth ? Auth::user()->profile : false;
|
$user = $auth ? Auth::user()->profile : false;
|
||||||
|
$requested = false;
|
||||||
|
if($user) {
|
||||||
|
$requested = FollowRequest::whereFollowerId($user->id)
|
||||||
|
->whereFollowingId($profile->id)
|
||||||
|
->exists();
|
||||||
|
}
|
||||||
return [
|
return [
|
||||||
'id' => (string) $profile->id,
|
'id' => (string) $profile->id,
|
||||||
'following' => $auth ? $user->follows($profile) : false,
|
'following' => $auth ? $user->follows($profile) : false,
|
||||||
|
@ -19,7 +28,7 @@ class RelationshipTransformer extends Fractal\TransformerAbstract
|
||||||
'blocking' => $auth ? $user->blockedIds()->contains($profile->id) : false,
|
'blocking' => $auth ? $user->blockedIds()->contains($profile->id) : false,
|
||||||
'muting' => $auth ? $user->mutedIds()->contains($profile->id) : false,
|
'muting' => $auth ? $user->mutedIds()->contains($profile->id) : false,
|
||||||
'muting_notifications' => null,
|
'muting_notifications' => null,
|
||||||
'requested' => null,
|
'requested' => $requested,
|
||||||
'domain_blocking' => null,
|
'domain_blocking' => null,
|
||||||
'showing_reblogs' => null,
|
'showing_reblogs' => null,
|
||||||
'endorsed' => false
|
'endorsed' => false
|
||||||
|
|
Loading…
Reference in New Issue