From 4d7f8450d9a842e2f69754ccaa4202710328dcb7 Mon Sep 17 00:00:00 2001 From: winter Date: Tue, 14 Jan 2025 20:44:49 +0000 Subject: add (un)follow button to profile also other stuff i forgot what exactly --- Digitigrade/Model/Actor.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'Digitigrade/Model/Actor.php') diff --git a/Digitigrade/Model/Actor.php b/Digitigrade/Model/Actor.php index 46c6f9a..c8cc25e 100644 --- a/Digitigrade/Model/Actor.php +++ b/Digitigrade/Model/Actor.php @@ -161,6 +161,24 @@ class Actor extends PushableModel implements RpcReceiver { $initiator->rpcCall('rejectedFollow', [$this]); } + /** + * @param Actor $target the other actor + * @return boolean whether this actor is following the target actor + */ + public function follows(Actor $target): bool { + $relation = FollowRelation::findByActors($this, $target); + return $relation != null && $relation->status == FollowRelationStatus::ACTIVE; + } + + /** + * @param Actor $target the other actor + * @return boolean whether this actor has a pending follow request to the target actor + */ + public function followsPending(Actor $target): bool { + $relation = FollowRelation::findByActors($this, $target); + return $relation != null && $relation->status == FollowRelationStatus::PENDING; + } + /** * @return Actor[] a list of actors that follow this actor (does not include pending follows) */ -- cgit v1.3