diff options
| author | 2024-10-27 09:02:45 +0100 | |
|---|---|---|
| committer | 2024-10-27 09:02:45 +0100 | |
| commit | 4563b9c2f5bd98117d3bb95c192aaafe525c0ce1 (patch) | |
| tree | 1fd05f3b30f8a31673d7a9541e14c902eb7918e9 /html.c | |
| parent | New command line action 'insert'. (diff) | |
| download | snac2-4563b9c2f5bd98117d3bb95c192aaafe525c0ce1.tar.gz snac2-4563b9c2f5bd98117d3bb95c192aaafe525c0ce1.tar.xz snac2-4563b9c2f5bd98117d3bb95c192aaafe525c0ce1.zip | |
If an attached image URL is already in the post content, don't show it.
Diffstat (limited to 'html.c')
| -rw-r--r-- | html.c | 7 |
1 files changed, 7 insertions, 0 deletions
| @@ -1934,6 +1934,8 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 1934 | xs_html_add(snac_content, | 1934 | xs_html_add(snac_content, |
| 1935 | content_attachments); | 1935 | content_attachments); |
| 1936 | 1936 | ||
| 1937 | const char *content = xs_dict_get(msg, "content"); | ||
| 1938 | |||
| 1937 | int c = 0; | 1939 | int c = 0; |
| 1938 | const xs_dict *a; | 1940 | const xs_dict *a; |
| 1939 | while (xs_list_next(attach, &a, &c)) { | 1941 | while (xs_list_next(attach, &a, &c)) { |
| @@ -1942,6 +1944,11 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 1942 | const char *name = xs_dict_get(a, "name"); | 1944 | const char *name = xs_dict_get(a, "name"); |
| 1943 | 1945 | ||
| 1944 | if (xs_startswith(type, "image/") || strcmp(type, "Image") == 0) { | 1946 | if (xs_startswith(type, "image/") || strcmp(type, "Image") == 0) { |
| 1947 | |||
| 1948 | /* if this image is already in the post content, skip */ | ||
| 1949 | if (xs_str_in(content, href) != -1) | ||
| 1950 | continue; | ||
| 1951 | |||
| 1945 | xs_html_add(content_attachments, | 1952 | xs_html_add(content_attachments, |
| 1946 | xs_html_tag("a", | 1953 | xs_html_tag("a", |
| 1947 | xs_html_attr("href", href), | 1954 | xs_html_attr("href", href), |