diff options
| author | 2025-06-08 03:20:18 +0000 | |
|---|---|---|
| committer | 2025-06-08 03:20:18 +0000 | |
| commit | 43f7ca1d555dbeeacd068925596ab0cbcd84ab71 (patch) | |
| tree | 635cf643935eb891cc2206148a26980ed39a4177 /html.c | |
| parent | Differentiate the version from upstream (diff) | |
| download | penes-snac2-43f7ca1d555dbeeacd068925596ab0cbcd84ab71.tar.gz penes-snac2-43f7ca1d555dbeeacd068925596ab0cbcd84ab71.tar.xz penes-snac2-43f7ca1d555dbeeacd068925596ab0cbcd84ab71.zip | |
Add missing quoteUrl to the body of the message.ukko-2.78
Diffstat (limited to 'html.c')
| -rw-r--r-- | html.c | 32 |
1 files changed, 30 insertions, 2 deletions
| @@ -1901,6 +1901,31 @@ xs_html *html_entry_controls(snac *user, const char *actor, | |||
| 1901 | } | 1901 | } |
| 1902 | 1902 | ||
| 1903 | 1903 | ||
| 1904 | static void | ||
| 1905 | addQuoteUrl(xs_html* snac_content, xs_dict* msg, const char* content) | ||
| 1906 | { | ||
| 1907 | /* https://www.w3.org/ns/activitystreams#quoteUrl */ | ||
| 1908 | const char* quoteUri = xs_dict_get(msg, "quoteUrl"); | ||
| 1909 | if (!xs_is_string(quoteUri)) { | ||
| 1910 | /* http://fedibird.com/ns#quoteUri */ | ||
| 1911 | quoteUri = xs_dict_get(msg, "quoteUri"); | ||
| 1912 | } | ||
| 1913 | |||
| 1914 | // TODO: This should probably be a better check | ||
| 1915 | if (!xs_is_string(quoteUri) || xs_str_in(content, quoteUri) != -1) { | ||
| 1916 | return; | ||
| 1917 | } | ||
| 1918 | |||
| 1919 | xs_html_add(snac_content, | ||
| 1920 | xs_html_sctag("hr", NULL), | ||
| 1921 | xs_html_tag("p", | ||
| 1922 | xs_html_tag("a", | ||
| 1923 | xs_html_attr("href", quoteUri), | ||
| 1924 | xs_html_attr("target", "_blank"), | ||
| 1925 | xs_html_text("THIS FUCKER'S INSTANCE CAN'T DO “RE: URL”!")))); | ||
| 1926 | } | ||
| 1927 | |||
| 1928 | |||
| 1904 | xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | 1929 | xs_html *html_entry(snac *user, xs_dict *msg, int read_only, |
| 1905 | int level, const char *md5, int hide_children) | 1930 | int level, const char *md5, int hide_children) |
| 1906 | { | 1931 | { |
| @@ -2393,6 +2418,11 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 2393 | poll); | 2418 | poll); |
| 2394 | } | 2419 | } |
| 2395 | 2420 | ||
| 2421 | const char *content = xs_dict_get(msg, "content"); | ||
| 2422 | |||
| 2423 | /* Add a RE: <quoted post URL> if it doesn't exist already */ | ||
| 2424 | addQuoteUrl(snac_content, msg, content); | ||
| 2425 | |||
| 2396 | /** attachments **/ | 2426 | /** attachments **/ |
| 2397 | xs *attach = get_attachments(msg); | 2427 | xs *attach = get_attachments(msg); |
| 2398 | 2428 | ||
| @@ -2404,8 +2434,6 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 2404 | xs_html_add(snac_content, | 2434 | xs_html_add(snac_content, |
| 2405 | content_attachments); | 2435 | content_attachments); |
| 2406 | 2436 | ||
| 2407 | const char *content = xs_dict_get(msg, "content"); | ||
| 2408 | |||
| 2409 | int c = 0; | 2437 | int c = 0; |
| 2410 | const xs_dict *a; | 2438 | const xs_dict *a; |
| 2411 | while (xs_list_next(attach, &a, &c)) { | 2439 | while (xs_list_next(attach, &a, &c)) { |