commit 4563b9c
default
·
2024-10-27 08:02:45 +0000 UTC
parent be98082
If an attached image URL is already in the post content, don't show it.
1 files changed,
+7,
-0
M
html.c
M
html.c
+7,
-0
1@@ -1934,6 +1934,8 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
2 xs_html_add(snac_content,
3 content_attachments);
4
5+ const char *content = xs_dict_get(msg, "content");
6+
7 int c = 0;
8 const xs_dict *a;
9 while (xs_list_next(attach, &a, &c)) {
10@@ -1942,6 +1944,11 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
11 const char *name = xs_dict_get(a, "name");
12
13 if (xs_startswith(type, "image/") || strcmp(type, "Image") == 0) {
14+
15+ /* if this image is already in the post content, skip */
16+ if (xs_str_in(content, href) != -1)
17+ continue;
18+
19 xs_html_add(content_attachments,
20 xs_html_tag("a",
21 xs_html_attr("href", href),