diff options
author | default <nobody@localhost> | 2024-08-11 17:29:09 +0200 |
---|---|---|
committer | default <nobody@localhost> | 2024-08-11 17:29:09 +0200 |
commit | 382ff0334994a11b9905a5b9eceea95ef3153424 (patch) | |
tree | 1689f60a85584df11cbba611a50168e4886b7879 /data.c | |
parent | 35503ed2b4b557d369ca887719c8b79fa4eff37e (diff) |
content_search() also search into alt-text from attachments.
Diffstat (limited to 'data.c')
-rw-r--r-- | data.c | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -2491,8 +2491,22 @@ xs_list *content_search(snac *user, const char *regex, if (xs_is_null(content)) 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 */ - xs *c = xs_regex_replace(content, "<[^>]+>", " "); + c = xs_regex_replace_i(c, "<[^>]+>", " "); c = xs_regex_replace_i(c, " {2,}", " "); c = xs_tolower_i(c); |