mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-11-14 10:44:27 +00:00
Improve RSS/Atom feed
This commit is contained in:
parent
4f16e3b940
commit
6fe51ecff2
1 changed files with 15 additions and 2 deletions
17
app/main.py
17
app/main.py
|
@ -1064,12 +1064,25 @@ async def _gen_rss_feed(
|
|||
for outbox_object in outbox_objects:
|
||||
if not outbox_object.ap_published_at:
|
||||
raise ValueError(f"{outbox_object} has no published date")
|
||||
|
||||
content = outbox_object.content
|
||||
if content is None:
|
||||
raise ValueError("Should never happen")
|
||||
|
||||
if outbox_object.attachments:
|
||||
for attachment in outbox_object.attachments:
|
||||
if attachment.type == "Image" or attachment.media_type.startswith(
|
||||
"image"
|
||||
):
|
||||
content += f'<img src="{attachment.url}">'
|
||||
# TODO(ts): other attachment types
|
||||
|
||||
fe = fg.add_entry()
|
||||
fe.id(outbox_object.url)
|
||||
fe.link(href=outbox_object.url)
|
||||
fe.title(outbox_object.url)
|
||||
fe.description(outbox_object.content)
|
||||
fe.content(outbox_object.content)
|
||||
fe.description(content)
|
||||
fe.content(content)
|
||||
fe.published(outbox_object.ap_published_at.replace(tzinfo=timezone.utc))
|
||||
|
||||
return fg
|
||||
|
|
Loading…
Reference in a new issue