aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates/actor/atom.php
blob: 8bd40fbbd26ec0ad96e3e37106b2adc33daa7036 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/** @var \Digitigrade\Model\Actor $actor */
/** @var string $lang */

use Digitigrade\GlobalSettings;
use Digitigrade\Model\Note;
use Digitigrade\Model\NotePrivacyScope;

$selfUri = path_to_uri("/actor/$actor->id/feed/$lang/feed.atom");
$actorPage = path_to_uri("/@/$actor->handle");

echo '<?xml version="1.0" encoding="utf-8"?>';
?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <id><?= $selfUri ?></id>
    <title>
        <?= htmlspecialchars($actor->displayName) ?> — <?= GlobalSettings::getInstance()->get('instance.name') ?>
    </title>
    <updated><?= Note::findAllWithAuthor($actor, 1)[0]->created->format(DateTime::ATOM) ?></updated>
    <author>
        <name><?= htmlspecialchars($actor->displayName) ?></name>
        <uri><?= $actorPage ?></uri>
    </author>
    <link rel="self" href="<?= $selfUri ?>" />
    <link rel="alternate" type="text/html" href="<?= $actorPage ?>" />
    <generator version="<?= get_version() ?>">Digitigrade</generator>
    <?php if (isset($actor->avatar)): ?>
        <icon><?= $actor->avatar ?></icon>
    <?php endif; ?>
    <subtitle><?= __f('user.rss.description', $actor->displayName) ?></subtitle>

    <?php foreach (Note::findAllWithAuthor($actor, limit: 50) as $note): ?>
        <?php
        /** @var Note $note */
        if ($note->privacy->scope != NotePrivacyScope::PUBLIC || $note->inReplyTo != null) {
            continue;
        }
        ?>
        <entry>
            <id><?= path_to_uri("/note/$note->id") ?></id>
            <title><![CDATA[<?= htmlspecialchars(substr($note->plainContent, 0, 50), double_encode: false) ?>]]></title>
            <updated><?= ($note->modified ?? $note->created)->format(DateTime::ATOM) ?></updated>
            <link rel="alternate" type="text/html" href="<?= path_to_uri("/@/$actor->handle/note/$note->id") ?>" />
            <content type="html"><![CDATA[<?= $note->getBestContentAsHtml() ?>]]></content>
            <?php foreach ($note->attachments as $file): ?>
                <link rel="enclosure" title="<?= htmlspecialchars($file->description) ?>" type="<?= $file->type ?>"
                    href="<?= $file->href ?>" />
            <?php endforeach; ?>
        </entry>
    <?php endforeach; ?>
</feed>