diff options
| author | winter | 2025-01-14 18:13:57 +0000 |
|---|---|---|
| committer | winter | 2025-01-14 18:13:57 +0000 |
| commit | 25b748f04911262826d0a0bc9609e03ee47c3232 (patch) | |
| tree | 35dc82bd0cb1798913f726fb6bb74be97e5b83ba /Digitigrade/Model/Note.php | |
| parent | 2082bfe9a378a90b33d4ab5c05dbb19a3457bef6 (diff) | |
add interaction counters
Diffstat (limited to 'Digitigrade/Model/Note.php')
| -rw-r--r-- | Digitigrade/Model/Note.php | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Digitigrade/Model/Note.php b/Digitigrade/Model/Note.php index a4891a3..cf23e80 100644 --- a/Digitigrade/Model/Note.php +++ b/Digitigrade/Model/Note.php @@ -123,10 +123,18 @@ class Note extends PushableModel implements TimelineIncludeable { return Interaction::findAllWithTarget($this); } + public function countInteractionsOfKind(InteractionKind $kind): int { + return Interaction::countWhere('target = ? AND kind = ? AND deleted = false', [$this->id, $kind->value]); + } + public function getInteractionsWithAuthor(Actor $author): array { return Interaction::findAllWhere('author = ? AND target = ? AND deleted = false', [$author->id, $this->id]); } + public function countReplies(): int { + return self::countWhere('in_reply_to = ? AND deleted = false', [$this->id]); + } + protected function getRelevantServers(): array { $recipientActors = match ($this->privacy->scope) { NotePrivacyScope::NONE => [], @@ -134,6 +142,12 @@ class Note extends PushableModel implements TimelineIncludeable { default => $this->author->findFollowers() }; $recipientActors = array_merge($recipientActors, $this->mentions, $this->privacy->alsoVisibleTo); + // reply-to and thread apex author should be covered by mentions but in case they're not: + if (isset($this->inReplyTo)) + $recipientActors[] = $this->inReplyTo->author; + if (isset($this->threadApex)) + $recipientActors[] = $this->threadApex->author; + $recipientActors = array_unique($recipientActors); $instances = array_map(function (Actor $a) { return $a->findHomeInstance(); |
