diff options
Diffstat (limited to 'Digitigrade/Model')
| -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(); |
