summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar grunfink2026-03-19 19:15:22 +0100
committerGravatar grunfink2026-03-19 19:15:22 +0100
commitd67436fb9a4b86e65ed72f344cab678cd2d0bdec (patch)
treeaaaf1d5cef50562666ebe88cbed822ba2c895376
parentUpdated TODO. (diff)
downloadsnac2-d67436fb9a4b86e65ed72f344cab678cd2d0bdec.tar.gz
snac2-d67436fb9a4b86e65ed72f344cab678cd2d0bdec.tar.xz
snac2-d67436fb9a4b86e65ed72f344cab678cd2d0bdec.zip
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,
101 xs_html_tag("lastBuildDate", 101 xs_html_tag("lastBuildDate",
102 xs_html_text(rss_date))); 102 xs_html_text(rss_date)));
103 103
104 xs *att_content = xs_dup(content);
105 xs *attach_list = get_attachments(msg);
106
107 /* add possible attachments */
108 if (xs_list_len(attach_list)) {
109 const xs_val *a;
110 xs_html *content_attachments = xs_html_tag("div",
111 xs_html_attr("class", "snac-content-attachments"));
112
113 xs_list_foreach(attach_list, a) {
114 const char *type = xs_dict_get(a, "type");
115 const char *o_href = xs_dict_get(a, "href");
116 const char *name = xs_dict_get_def(a, "name", "");
117
118 if (!xs_is_string(type) || !xs_is_string(o_href))
119 continue;
120
121 if (xs_startswith(type, "image/")) {
122 xs_html_add(content_attachments,
123 xs_html_tag("figure",
124 xs_html_sctag("img",
125 xs_html_attr("src", o_href)),
126 xs_html_tag("figcaption",
127 xs_html_text(name))));
128 }
129 else {
130 xs_html_add(content_attachments,
131 xs_html_tag("a",
132 xs_html_attr("href", o_href),
133 xs_html_text(name),
134 xs_html_text(" "),
135 xs_html_text(o_href),
136 xs_html_sctag("br", NULL)));
137 }
138 }
139
140 xs *s1 = xs_html_render(content_attachments);
141 att_content = xs_str_cat(att_content, s1);
142 }
143
104 xs_html_add(channel, 144 xs_html_add(channel,
105 xs_html_tag("item", 145 xs_html_tag("item",
106 xs_html_tag("title", 146 xs_html_tag("title",
@@ -112,7 +152,7 @@ xs_str *rss_from_timeline(snac *user, const xs_list *timeline,
112 xs_html_tag("pubDate", 152 xs_html_tag("pubDate",
113 xs_html_text(rss_date)), 153 xs_html_text(rss_date)),
114 xs_html_tag("description", 154 xs_html_tag("description",
115 xs_html_text(content)))); 155 xs_html_text(att_content))));
116 156
117 cnt++; 157 cnt++;
118 } 158 }