aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates/actor_rss.php
blob: 03fc4f5c1ee79bfc8f61b48de56323b392030800 (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
<?php
/** @var \Digitigrade\Model\Actor $actor */
/** @var string $lang */

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

// putting this here because otherwise my ide yells about "shorthand <?"
// because it thinks i'm trying to do a php thing instead of xml directive
echo '<?xml version="1.0" encoding="utf-8"?>';
?>
<rss version="2.0">
    <channel>
        <title>
            <?= htmlspecialchars($actor->displayName) ?> — <?= GlobalSettings::getInstance()->get('instance.name') ?>
        </title>
        <link><?= path_to_uri("/@/$actor->handle") ?></link>
        <description><?= __f('user.rss.description', htmlspecialchars($actor->displayName)) ?></description>
        <language><?= $lang ?></language>
        <generator><?= __f('version', get_version()) ?></generator>
        <?php if (isset($actor->avatar)): ?>
            <image>
                <url><?= $actor->avatar ?></url>
            </image>
        <?php endif; ?>
        <?php foreach (Note::findAllWithAuthor($actor, limit: 50) as $note): ?>
            <?php
            /** @var Note $note */
            if ($note->privacy->scope != NotePrivacyScope::PUBLIC || $note->inReplyTo != null) {
                continue;
            }
            ?>
            <item>
                <link><?= path_to_uri("/@/$actor->handle/note/$note->id") ?></link>
                <guid><?= path_to_uri("/note/$note->id") ?></guid>
                <title><![CDATA[<?= htmlspecialchars(substr($note->plainContent, 0, 50), double_encode: false) ?>]]></title>
                <description><![CDATA[<?= $note->getBestContentAsHtml() ?>]]></description>
                <pubDate><?= $note->created->format(DateTime::RSS) ?></pubDate>
                <?php foreach ($note->attachments as $file): ?>
                    <enclosure url="<?= $file->href ?>" type="<?= $file->type ?>" size="-1" /><!-- size unknown sorry :( -->
                <?php endforeach; ?>
            </item>
        <?php endforeach; ?>
    </channel>
</rss>