aboutsummaryrefslogtreecommitdiffhomepage
path: root/Digitigrade
diff options
context:
space:
mode:
authorwinter2025-01-14 20:44:49 +0000
committerwinter2025-01-14 20:44:49 +0000
commit4d7f8450d9a842e2f69754ccaa4202710328dcb7 (patch)
tree60e90ff7ebbf069e04faf665d68861970eaee000 /Digitigrade
parent0f427b4b6f75134b2c25b7e5f8a515be2cec97f5 (diff)
add (un)follow button to profile
also other stuff i forgot what exactly
Diffstat (limited to 'Digitigrade')
-rw-r--r--Digitigrade/Model/Actor.php18
-rw-r--r--Digitigrade/Model/Note.php4
2 files changed, 22 insertions, 0 deletions
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
@@ -162,6 +162,24 @@ class Actor extends PushableModel implements RpcReceiver {
}
/**
+ * @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)
*/
public function findFollowers(): array {
diff --git a/Digitigrade/Model/Note.php b/Digitigrade/Model/Note.php
index cf23e80..0aa29bd 100644
--- a/Digitigrade/Model/Note.php
+++ b/Digitigrade/Model/Note.php
@@ -111,6 +111,10 @@ class Note extends PushableModel implements TimelineIncludeable {
return self::findAllWhere($where, [$author->id], $limit, $offset, 'created DESC');
}
+ public static function countWithAuthor(Actor $author): int {
+ return self::countWhere('author = ? AND deleted = false', [$author->id]);
+ }
+
public static function findAllInThread(Note $threadApex, ?int $limit = null, int $offset = 0): array {
if (isset($limit))
$limit--; // to account for adding the note afterwards