diff options
| author | 2024-05-15 13:31:53 +0200 | |
|---|---|---|
| committer | 2024-05-15 13:31:53 +0200 | |
| commit | 0a6df8e504569be4caf39930c473f12b328e5b2a (patch) | |
| tree | ca0dd5767719d5b96f73b77d42b8da69e0a32a7d | |
| parent | Moved functions around. (diff) | |
| download | penes-snac2-0a6df8e504569be4caf39930c473f12b328e5b2a.tar.gz penes-snac2-0a6df8e504569be4caf39930c473f12b328e5b2a.tar.xz penes-snac2-0a6df8e504569be4caf39930c473f12b328e5b2a.zip | |
Renamed content_check() to content_match().
| -rw-r--r-- | activitypub.c | 4 | ||||
| -rw-r--r-- | data.c | 6 | ||||
| -rw-r--r-- | snac.h | 7 |
3 files changed, 8 insertions, 9 deletions
diff --git a/activitypub.c b/activitypub.c index dee127d..231715b 100644 --- a/activitypub.c +++ b/activitypub.c | |||
| @@ -356,7 +356,7 @@ int timeline_request(snac *snac, char **id, xs_str **wrk, int level) | |||
| 356 | } | 356 | } |
| 357 | 357 | ||
| 358 | if (xs_match(type, POSTLIKE_OBJECT_TYPE)) { | 358 | if (xs_match(type, POSTLIKE_OBJECT_TYPE)) { |
| 359 | if (content_check("filter_reject.txt", object)) | 359 | if (content_match("filter_reject.txt", object)) |
| 360 | snac_log(snac, xs_fmt("timeline_request rejected by content %s", nid)); | 360 | snac_log(snac, xs_fmt("timeline_request rejected by content %s", nid)); |
| 361 | else { | 361 | else { |
| 362 | const char *actor = get_atto(object); | 362 | const char *actor = get_atto(object); |
| @@ -2005,7 +2005,7 @@ int process_input_message(snac *snac, xs_dict *msg, xs_dict *req) | |||
| 2005 | snac_debug(snac, 0, xs_fmt("dropped reply %s to hidden post %s", id, in_reply_to)); | 2005 | snac_debug(snac, 0, xs_fmt("dropped reply %s to hidden post %s", id, in_reply_to)); |
| 2006 | } | 2006 | } |
| 2007 | else { | 2007 | else { |
| 2008 | if (content_check("filter_reject.txt", object)) { | 2008 | if (content_match("filter_reject.txt", object)) { |
| 2009 | snac_log(snac, xs_fmt("rejected by content %s", id)); | 2009 | snac_log(snac, xs_fmt("rejected by content %s", id)); |
| 2010 | return 1; | 2010 | return 1; |
| 2011 | } | 2011 | } |
| @@ -2272,7 +2272,7 @@ int instance_unblock(const char *instance) | |||
| 2272 | 2272 | ||
| 2273 | /** operations by content **/ | 2273 | /** operations by content **/ |
| 2274 | 2274 | ||
| 2275 | int content_check(const char *file, const xs_dict *msg) | 2275 | int content_match(const char *file, const xs_dict *msg) |
| 2276 | /* checks if a message's content matches any of the regexes in file */ | 2276 | /* checks if a message's content matches any of the regexes in file */ |
| 2277 | /* file format: one regex per line */ | 2277 | /* file format: one regex per line */ |
| 2278 | { | 2278 | { |
| @@ -2283,7 +2283,7 @@ int content_check(const char *file, const xs_dict *msg) | |||
| 2283 | 2283 | ||
| 2284 | if (xs_type(v) == XSTYPE_STRING && *v) { | 2284 | if (xs_type(v) == XSTYPE_STRING && *v) { |
| 2285 | if ((f = fopen(fn, "r")) != NULL) { | 2285 | if ((f = fopen(fn, "r")) != NULL) { |
| 2286 | srv_debug(1, xs_fmt("content_check: loading regexes from %s", fn)); | 2286 | srv_debug(1, xs_fmt("content_match: loading regexes from %s", fn)); |
| 2287 | 2287 | ||
| 2288 | /* massage content (strip HTML tags, etc.) */ | 2288 | /* massage content (strip HTML tags, etc.) */ |
| 2289 | xs *c = xs_regex_replace(v, "<[^>]+>", " "); | 2289 | xs *c = xs_regex_replace(v, "<[^>]+>", " "); |
| @@ -2294,7 +2294,7 @@ int content_check(const char *file, const xs_dict *msg) | |||
| 2294 | xs *rx = xs_strip_i(xs_readline(f)); | 2294 | xs *rx = xs_strip_i(xs_readline(f)); |
| 2295 | 2295 | ||
| 2296 | if (*rx && xs_regex_match(c, rx)) { | 2296 | if (*rx && xs_regex_match(c, rx)) { |
| 2297 | srv_debug(1, xs_fmt("content_check: match for '%s'", rx)); | 2297 | srv_debug(1, xs_fmt("content_match: match for '%s'", rx)); |
| 2298 | r = 1; | 2298 | r = 1; |
| 2299 | } | 2299 | } |
| 2300 | } | 2300 | } |
| @@ -181,9 +181,6 @@ xs_list *list_timeline(snac *user, const char *list, int skip, int show); | |||
| 181 | xs_val *list_content(snac *user, const char *list_id, const char *actor_md5, int op); | 181 | xs_val *list_content(snac *user, const char *list_id, const char *actor_md5, int op); |
| 182 | void list_distribute(snac *user, const char *who, const xs_dict *post); | 182 | void list_distribute(snac *user, const char *who, const xs_dict *post); |
| 183 | 183 | ||
| 184 | xs_list *content_search(snac *user, const char *regex, | ||
| 185 | int priv, int skip, int show, int max_secs, int *timeout); | ||
| 186 | |||
| 187 | int actor_add(const char *actor, xs_dict *msg); | 184 | int actor_add(const char *actor, xs_dict *msg); |
| 188 | int actor_get(const char *actor, xs_dict **data); | 185 | int actor_get(const char *actor, xs_dict **data); |
| 189 | int actor_get_refresh(snac *user, const char *actor, xs_dict **data); | 186 | int actor_get_refresh(snac *user, const char *actor, xs_dict **data); |
| @@ -219,7 +216,9 @@ int is_instance_blocked(const char *instance); | |||
| 219 | int instance_block(const char *instance); | 216 | int instance_block(const char *instance); |
| 220 | int instance_unblock(const char *instance); | 217 | int instance_unblock(const char *instance); |
| 221 | 218 | ||
| 222 | int content_check(const char *file, const xs_dict *msg); | 219 | int content_match(const char *file, const xs_dict *msg); |
| 220 | xs_list *content_search(snac *user, const char *regex, | ||
| 221 | int priv, int skip, int show, int max_secs, int *timeout); | ||
| 223 | 222 | ||
| 224 | void enqueue_input(snac *snac, const xs_dict *msg, const xs_dict *req, int retries); | 223 | void enqueue_input(snac *snac, const xs_dict *msg, const xs_dict *req, int retries); |
| 225 | void enqueue_shared_input(const xs_dict *msg, const xs_dict *req, int retries); | 224 | void enqueue_shared_input(const xs_dict *msg, const xs_dict *req, int retries); |