commit 0a6df8e
default
·
2024-05-15 11:31:53 +0000 UTC
parent 0a6cfba
Renamed content_check() to content_match().
3 files changed,
+8,
-9
+2,
-2
1@@ -356,7 +356,7 @@ int timeline_request(snac *snac, char **id, xs_str **wrk, int level)
2 }
3
4 if (xs_match(type, POSTLIKE_OBJECT_TYPE)) {
5- if (content_check("filter_reject.txt", object))
6+ if (content_match("filter_reject.txt", object))
7 snac_log(snac, xs_fmt("timeline_request rejected by content %s", nid));
8 else {
9 const char *actor = get_atto(object);
10@@ -2005,7 +2005,7 @@ int process_input_message(snac *snac, xs_dict *msg, xs_dict *req)
11 snac_debug(snac, 0, xs_fmt("dropped reply %s to hidden post %s", id, in_reply_to));
12 }
13 else {
14- if (content_check("filter_reject.txt", object)) {
15+ if (content_match("filter_reject.txt", object)) {
16 snac_log(snac, xs_fmt("rejected by content %s", id));
17 return 1;
18 }
M
data.c
+3,
-3
1@@ -2272,7 +2272,7 @@ int instance_unblock(const char *instance)
2
3 /** operations by content **/
4
5-int content_check(const char *file, const xs_dict *msg)
6+int content_match(const char *file, const xs_dict *msg)
7 /* checks if a message's content matches any of the regexes in file */
8 /* file format: one regex per line */
9 {
10@@ -2283,7 +2283,7 @@ int content_check(const char *file, const xs_dict *msg)
11
12 if (xs_type(v) == XSTYPE_STRING && *v) {
13 if ((f = fopen(fn, "r")) != NULL) {
14- srv_debug(1, xs_fmt("content_check: loading regexes from %s", fn));
15+ srv_debug(1, xs_fmt("content_match: loading regexes from %s", fn));
16
17 /* massage content (strip HTML tags, etc.) */
18 xs *c = xs_regex_replace(v, "<[^>]+>", " ");
19@@ -2294,7 +2294,7 @@ int content_check(const char *file, const xs_dict *msg)
20 xs *rx = xs_strip_i(xs_readline(f));
21
22 if (*rx && xs_regex_match(c, rx)) {
23- srv_debug(1, xs_fmt("content_check: match for '%s'", rx));
24+ srv_debug(1, xs_fmt("content_match: match for '%s'", rx));
25 r = 1;
26 }
27 }
M
snac.h
+3,
-4
1@@ -181,9 +181,6 @@ xs_list *list_timeline(snac *user, const char *list, int skip, int show);
2 xs_val *list_content(snac *user, const char *list_id, const char *actor_md5, int op);
3 void list_distribute(snac *user, const char *who, const xs_dict *post);
4
5-xs_list *content_search(snac *user, const char *regex,
6- int priv, int skip, int show, int max_secs, int *timeout);
7-
8 int actor_add(const char *actor, xs_dict *msg);
9 int actor_get(const char *actor, xs_dict **data);
10 int actor_get_refresh(snac *user, const char *actor, xs_dict **data);
11@@ -219,7 +216,9 @@ int is_instance_blocked(const char *instance);
12 int instance_block(const char *instance);
13 int instance_unblock(const char *instance);
14
15-int content_check(const char *file, const xs_dict *msg);
16+int content_match(const char *file, const xs_dict *msg);
17+xs_list *content_search(snac *user, const char *regex,
18+ int priv, int skip, int show, int max_secs, int *timeout);
19
20 void enqueue_input(snac *snac, const xs_dict *msg, const xs_dict *req, int retries);
21 void enqueue_shared_input(const xs_dict *msg, const xs_dict *req, int retries);