diff options
Diffstat (limited to 'Digitigrade')
| -rw-r--r-- | Digitigrade/Model/Note.php | 9 | ||||
| -rw-r--r-- | Digitigrade/Timeline/LocalTimeline.php | 20 |
2 files changed, 29 insertions, 0 deletions
diff --git a/Digitigrade/Model/Note.php b/Digitigrade/Model/Note.php index 9d73a89..8dbec90 100644 --- a/Digitigrade/Model/Note.php +++ b/Digitigrade/Model/Note.php @@ -124,6 +124,15 @@ class Note extends PushableModel { return array_unique($instances); } + /** + * Gets this note's formatted content in the given mimetype or null if there isn't one + * @param string $mimetype content type to return + * @return ?string the marked up content + */ + public function getFormattedContent(string $mimetype): ?string { + return array_filter($this->formattedContent, fn($item) => $item['mimetype'] == $mimetype)[0]['body'] ?? null; + } + public function jsonSerialize(): array { if ($this->deleted) { return [ diff --git a/Digitigrade/Timeline/LocalTimeline.php b/Digitigrade/Timeline/LocalTimeline.php new file mode 100644 index 0000000..e4594af --- /dev/null +++ b/Digitigrade/Timeline/LocalTimeline.php @@ -0,0 +1,20 @@ +<?php +namespace Digitigrade\Timeline; + +use Digitigrade\Db; +use Digitigrade\Timeline; + +class LocalTimeline extends Timeline { + protected function getNoteIds(int $limit, int $offset): array { + $db = Db::getInstance()->getPdo(); + $stmt = $db->prepare(<<<END + SELECT note.id FROM note + LEFT JOIN note_privacy ON note_privacy.note_id = note.id + LEFT JOIN actor ON note.author = actor.id + WHERE note_privacy.scope = 'public' AND note_privacy.indexable = true AND actor.is_local = true + ORDER BY note.created DESC LIMIT ? OFFSET ? + END); + $stmt->execute([$limit, $offset]); + return $stmt->fetchAll(\PDO::FETCH_COLUMN, 0); + } +}
\ No newline at end of file |
