Renamed content_check() to content_match().

This commit is contained in:
default 2024-05-15 13:31:53 +02:00
parent 0a6cfba399
commit 0a6df8e504
3 changed files with 8 additions and 9 deletions

View File

@ -356,7 +356,7 @@ int timeline_request(snac *snac, char **id, xs_str **wrk, int level)
} }
if (xs_match(type, POSTLIKE_OBJECT_TYPE)) { if (xs_match(type, POSTLIKE_OBJECT_TYPE)) {
if (content_check("filter_reject.txt", object)) if (content_match("filter_reject.txt", object))
snac_log(snac, xs_fmt("timeline_request rejected by content %s", nid)); snac_log(snac, xs_fmt("timeline_request rejected by content %s", nid));
else { else {
const char *actor = get_atto(object); const char *actor = get_atto(object);
@ -2005,7 +2005,7 @@ int process_input_message(snac *snac, xs_dict *msg, xs_dict *req)
snac_debug(snac, 0, xs_fmt("dropped reply %s to hidden post %s", id, in_reply_to)); snac_debug(snac, 0, xs_fmt("dropped reply %s to hidden post %s", id, in_reply_to));
} }
else { else {
if (content_check("filter_reject.txt", object)) { if (content_match("filter_reject.txt", object)) {
snac_log(snac, xs_fmt("rejected by content %s", id)); snac_log(snac, xs_fmt("rejected by content %s", id));
return 1; return 1;
} }

6
data.c
View File

@ -2272,7 +2272,7 @@ int instance_unblock(const char *instance)
/** operations by content **/ /** operations by content **/
int content_check(const char *file, const xs_dict *msg) int content_match(const char *file, const xs_dict *msg)
/* checks if a message's 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 */ /* file format: one regex per line */
{ {
@ -2283,7 +2283,7 @@ int content_check(const char *file, const xs_dict *msg)
if (xs_type(v) == XSTYPE_STRING && *v) { if (xs_type(v) == XSTYPE_STRING && *v) {
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_match: loading regexes from %s", fn));
/* massage content (strip HTML tags, etc.) */ /* massage content (strip HTML tags, etc.) */
xs *c = xs_regex_replace(v, "<[^>]+>", " "); xs *c = xs_regex_replace(v, "<[^>]+>", " ");
@ -2294,7 +2294,7 @@ int content_check(const char *file, const xs_dict *msg)
xs *rx = xs_strip_i(xs_readline(f)); xs *rx = xs_strip_i(xs_readline(f));
if (*rx && xs_regex_match(c, rx)) { if (*rx && xs_regex_match(c, rx)) {
srv_debug(1, xs_fmt("content_check: match for '%s'", rx)); srv_debug(1, xs_fmt("content_match: match for '%s'", rx));
r = 1; r = 1;
} }
} }

7
snac.h
View File

@ -181,9 +181,6 @@ xs_list *list_timeline(snac *user, const char *list, int skip, int show);
xs_val *list_content(snac *user, const char *list_id, const char *actor_md5, int op); xs_val *list_content(snac *user, const char *list_id, const char *actor_md5, int op);
void list_distribute(snac *user, const char *who, const xs_dict *post); void list_distribute(snac *user, const char *who, const xs_dict *post);
xs_list *content_search(snac *user, const char *regex,
int priv, int skip, int show, int max_secs, int *timeout);
int actor_add(const char *actor, xs_dict *msg); int actor_add(const char *actor, xs_dict *msg);
int actor_get(const char *actor, xs_dict **data); int actor_get(const char *actor, xs_dict **data);
int actor_get_refresh(snac *user, const char *actor, xs_dict **data); int actor_get_refresh(snac *user, const char *actor, xs_dict **data);
@ -219,7 +216,9 @@ int is_instance_blocked(const char *instance);
int instance_block(const char *instance); int instance_block(const char *instance);
int instance_unblock(const char *instance); int instance_unblock(const char *instance);
int content_check(const char *file, const xs_dict *msg); int content_match(const char *file, const xs_dict *msg);
xs_list *content_search(snac *user, const char *regex,
int priv, int skip, int show, int max_secs, int *timeout);
void enqueue_input(snac *snac, const xs_dict *msg, const xs_dict *req, int retries); void enqueue_input(snac *snac, const xs_dict *msg, const xs_dict *req, int retries);
void enqueue_shared_input(const xs_dict *msg, const xs_dict *req, int retries); void enqueue_shared_input(const xs_dict *msg, const xs_dict *req, int retries);