Also call content_check() from timeline_request().

This commit is contained in:
default 2024-03-11 09:53:20 +01:00
parent bb28b1c090
commit 48941cfeaf
2 changed files with 16 additions and 10 deletions

View file

@ -354,18 +354,22 @@ int timeline_request(snac *snac, char **id, xs_str **wrk, int level)
if (xs_match(type, "Note|Page|Article|Video")) { if (xs_match(type, "Note|Page|Article|Video")) {
const char *actor = get_atto(object); const char *actor = get_atto(object);
/* request (and drop) the actor for this entry */ if (content_check("filter_reject.txt", object))
if (!xs_is_null(actor)) snac_log(snac, xs_fmt("timeline_request rejected by content %s", nid));
actor_request(snac, actor, NULL); else {
/* request (and drop) the actor for this entry */
if (!xs_is_null(actor))
actor_request(snac, actor, NULL);
/* does it have an ancestor? */ /* does it have an ancestor? */
char *in_reply_to = xs_dict_get(object, "inReplyTo"); char *in_reply_to = xs_dict_get(object, "inReplyTo");
/* store */ /* store */
timeline_add(snac, nid, object); timeline_add(snac, nid, object);
/* recurse! */ /* recurse! */
timeline_request(snac, &in_reply_to, NULL, level + 1); timeline_request(snac, &in_reply_to, NULL, level + 1);
}
} }
} }
} }

4
data.c
View file

@ -2010,7 +2010,8 @@ int instance_unblock(const char *instance)
/** content filtering **/ /** content filtering **/
int content_check(const char *file, const xs_dict *msg) int content_check(const char *file, const xs_dict *msg)
/* checks if message content matches any of the regexes in file */ /* checks if a message's content matches any of the regexes in file */
/* file format: one regex per line */
{ {
xs *fn = xs_fmt("%s/%s", srv_basedir, file); xs *fn = xs_fmt("%s/%s", srv_basedir, file);
FILE *f; FILE *f;
@ -2021,6 +2022,7 @@ int content_check(const char *file, const xs_dict *msg)
if ((f = fopen(fn, "r")) != NULL) { if ((f = fopen(fn, "r")) != NULL) {
srv_debug(1, xs_fmt("content_check: loading regexes from %s", fn)); srv_debug(1, xs_fmt("content_check: loading regexes from %s", fn));
/* massage content (strip HTML tags, etc.) */
xs *c = xs_regex_replace(v, "<[^>]+>", " "); xs *c = xs_regex_replace(v, "<[^>]+>", " ");
c = xs_regex_replace_i(c, " {2,}", " "); c = xs_regex_replace_i(c, " {2,}", " ");
c = xs_tolower_i(c); c = xs_tolower_i(c);