aboutsummaryrefslogtreecommitdiffhomepage
path: root/Digitigrade/Timeline/LocalTimeline.php
blob: 612957645c2f3c83a3693aab2c842c2d61cf22df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
namespace Digitigrade\Timeline;

use Digitigrade\Db;
use Digitigrade\Model\Note;

class LocalTimeline extends Timeline {
    protected function getItems(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 AND note.deleted = false
        ORDER BY note.created DESC LIMIT ? OFFSET ?
        END);
        $stmt->execute([$limit, $offset]);
        $ids = $stmt->fetchAll(\PDO::FETCH_COLUMN, 0);
        return array_map(fn($id) => new TimelineItem(Note::find($id)), $ids);
    }
}