mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-15 01:55:03 +00:00
content_search() also search into alt-text from attachments.
This commit is contained in:
parent
35503ed2b4
commit
382ff03349
1 changed files with 15 additions and 1 deletions
16
data.c
16
data.c
|
@ -2491,8 +2491,22 @@ xs_list *content_search(snac *user, const char *regex,
|
||||||
if (xs_is_null(content))
|
if (xs_is_null(content))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
xs *c = xs_dup(content);
|
||||||
|
|
||||||
|
/* add alt-texts from attachments */
|
||||||
|
const xs_list *atts = xs_dict_get(post, "attachment");
|
||||||
|
int tc = 0;
|
||||||
|
const xs_dict *att;
|
||||||
|
|
||||||
|
while (xs_list_next(atts, &att, &tc)) {
|
||||||
|
const char *name = xs_dict_get(att, "name");
|
||||||
|
|
||||||
|
if (name != NULL)
|
||||||
|
c = xs_str_cat(c, " ", name);
|
||||||
|
}
|
||||||
|
|
||||||
/* strip HTML */
|
/* strip HTML */
|
||||||
xs *c = xs_regex_replace(content, "<[^>]+>", " ");
|
c = xs_regex_replace_i(c, "<[^>]+>", " ");
|
||||||
c = xs_regex_replace_i(c, " {2,}", " ");
|
c = xs_regex_replace_i(c, " {2,}", " ");
|
||||||
c = xs_tolower_i(c);
|
c = xs_tolower_i(c);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue