commit 382ff03

default  ·  2024-08-11 15:29:09 +0000 UTC
parent 35503ed
content_search() also search into alt-text from attachments.
1 files changed,  +15, -1
M data.c
M data.c
+15, -1
 1@@ -2491,8 +2491,22 @@ xs_list *content_search(snac *user, const char *regex,
 2         if (xs_is_null(content))
 3             continue;
 4 
 5+        xs *c = xs_dup(content);
 6+
 7+        /* add alt-texts from attachments */
 8+        const xs_list *atts = xs_dict_get(post, "attachment");
 9+        int tc = 0;
10+        const xs_dict *att;
11+
12+        while (xs_list_next(atts, &att, &tc)) {
13+            const char *name = xs_dict_get(att, "name");
14+
15+            if (name != NULL)
16+                c = xs_str_cat(c, " ", name);
17+        }
18+
19         /* strip HTML */
20-        xs *c = xs_regex_replace(content, "<[^>]+>", " ");
21+        c = xs_regex_replace_i(c, "<[^>]+>", " ");
22         c = xs_regex_replace_i(c, " {2,}", " ");
23         c = xs_tolower_i(c);
24