aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgrunfink <grunfink@comam.es>2026-03-19 19:15:22 +0100
committergrunfink <grunfink@comam.es>2026-03-19 19:15:22 +0100
commitd67436fb9a4b86e65ed72f344cab678cd2d0bdec (patch)
treeaaaf1d5cef50562666ebe88cbed822ba2c895376
parentc208611e669eb450fb239af244ab5858f9099cb4 (diff)
Add attachments to RSS.
-rw-r--r--rss.c42
1 files changed, 41 insertions, 1 deletions
diff --git a/rss.c b/rss.c
index dc26071..8aa7f68 100644
--- a/rss.c
+++ b/rss.c
@@ -101,6 +101,46 @@ xs_str *rss_from_timeline(snac *user, const xs_list *timeline,
xs_html_tag("lastBuildDate",
xs_html_text(rss_date)));
+ xs *att_content = xs_dup(content);
+ xs *attach_list = get_attachments(msg);
+
+ /* add possible attachments */
+ if (xs_list_len(attach_list)) {
+ const xs_val *a;
+ xs_html *content_attachments = xs_html_tag("div",
+ xs_html_attr("class", "snac-content-attachments"));
+
+ xs_list_foreach(attach_list, a) {
+ const char *type = xs_dict_get(a, "type");
+ const char *o_href = xs_dict_get(a, "href");
+ const char *name = xs_dict_get_def(a, "name", "");
+
+ if (!xs_is_string(type) || !xs_is_string(o_href))
+ continue;
+
+ if (xs_startswith(type, "image/")) {
+ xs_html_add(content_attachments,
+ xs_html_tag("figure",
+ xs_html_sctag("img",
+ xs_html_attr("src", o_href)),
+ xs_html_tag("figcaption",
+ xs_html_text(name))));
+ }
+ else {
+ xs_html_add(content_attachments,
+ xs_html_tag("a",
+ xs_html_attr("href", o_href),
+ xs_html_text(name),
+ xs_html_text(" "),
+ xs_html_text(o_href),
+ xs_html_sctag("br", NULL)));
+ }
+ }
+
+ xs *s1 = xs_html_render(content_attachments);
+ att_content = xs_str_cat(att_content, s1);
+ }
+
xs_html_add(channel,
xs_html_tag("item",
xs_html_tag("title",
@@ -112,7 +152,7 @@ xs_str *rss_from_timeline(snac *user, const xs_list *timeline,
xs_html_tag("pubDate",
xs_html_text(rss_date)),
xs_html_tag("description",
- xs_html_text(content))));
+ xs_html_text(att_content))));
cnt++;
}