diff options
| author | 2024-05-11 18:46:15 +0200 | |
|---|---|---|
| committer | 2024-05-11 18:46:15 +0200 | |
| commit | e1ce85debd5b192b5dc56a4e9810839cc52b0f8b (patch) | |
| tree | 76b44e0d587b7476bd0dcf2f054e813583001a4b | |
| parent | Updated TODO. (diff) | |
| download | snac2-e1ce85debd5b192b5dc56a4e9810839cc52b0f8b.tar.gz snac2-e1ce85debd5b192b5dc56a4e9810839cc52b0f8b.tar.xz snac2-e1ce85debd5b192b5dc56a4e9810839cc52b0f8b.zip | |
Unified post-like object type match.
| -rw-r--r-- | activitypub.c | 2 | ||||
| -rw-r--r-- | data.c | 2 | ||||
| -rw-r--r-- | html.c | 4 | ||||
| -rw-r--r-- | mastoapi.c | 4 | ||||
| -rw-r--r-- | snac.h | 2 |
5 files changed, 8 insertions, 6 deletions
diff --git a/activitypub.c b/activitypub.c index 301fd4c..4a04000 100644 --- a/activitypub.c +++ b/activitypub.c | |||
| @@ -355,7 +355,7 @@ int timeline_request(snac *snac, char **id, xs_str **wrk, int level) | |||
| 355 | type = "(null)"; | 355 | type = "(null)"; |
| 356 | } | 356 | } |
| 357 | 357 | ||
| 358 | if (xs_match(type, "Note|Page|Article|Video")) { | 358 | if (xs_match(type, POSTLIKE_OBJECT_TYPE)) { |
| 359 | const char *actor = get_atto(object); | 359 | const char *actor = get_atto(object); |
| 360 | 360 | ||
| 361 | if (content_check("filter_reject.txt", object)) | 361 | if (content_check("filter_reject.txt", object)) |
| @@ -2577,7 +2577,7 @@ xs_list *content_search(snac *user, const char *regex, | |||
| 2577 | if (!valid_status(timeline_get_by_md5(user, md5, &post))) | 2577 | if (!valid_status(timeline_get_by_md5(user, md5, &post))) |
| 2578 | continue; | 2578 | continue; |
| 2579 | 2579 | ||
| 2580 | if (!xs_match(xs_dict_get_def(post, "type", "-"), "Note|Question|Page|Article|Video")) | 2580 | if (!xs_match(xs_dict_get_def(post, "type", "-"), POSTLIKE_OBJECT_TYPE)) |
| 2581 | continue; | 2581 | continue; |
| 2582 | 2582 | ||
| 2583 | char *content = xs_dict_get(post, "content"); | 2583 | char *content = xs_dict_get(post, "content"); |
| @@ -256,7 +256,7 @@ xs_html *html_msg_icon(snac *user, char *actor_id, const xs_dict *msg) | |||
| 256 | int priv = 0; | 256 | int priv = 0; |
| 257 | const char *type = xs_dict_get(msg, "type"); | 257 | const char *type = xs_dict_get(msg, "type"); |
| 258 | 258 | ||
| 259 | if (xs_match(type, "Note|Question|Page|Article|Video")) | 259 | if (xs_match(type, POSTLIKE_OBJECT_TYPE)) |
| 260 | url = xs_dict_get(msg, "id"); | 260 | url = xs_dict_get(msg, "id"); |
| 261 | 261 | ||
| 262 | priv = !is_msg_public(msg); | 262 | priv = !is_msg_public(msg); |
| @@ -1405,7 +1405,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 1405 | html_msg_icon(read_only ? NULL : user, xs_dict_get(msg, "actor"), msg))); | 1405 | html_msg_icon(read_only ? NULL : user, xs_dict_get(msg, "actor"), msg))); |
| 1406 | } | 1406 | } |
| 1407 | else | 1407 | else |
| 1408 | if (!xs_match(type, "Note|Question|Page|Article|Video")) { | 1408 | if (!xs_match(type, POSTLIKE_OBJECT_TYPE)) { |
| 1409 | /* skip oddities */ | 1409 | /* skip oddities */ |
| 1410 | return NULL; | 1410 | return NULL; |
| 1411 | } | 1411 | } |
| @@ -1504,7 +1504,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1504 | /* discard non-Notes */ | 1504 | /* discard non-Notes */ |
| 1505 | const char *id = xs_dict_get(msg, "id"); | 1505 | const char *id = xs_dict_get(msg, "id"); |
| 1506 | const char *type = xs_dict_get(msg, "type"); | 1506 | const char *type = xs_dict_get(msg, "type"); |
| 1507 | if (!xs_match(type, "Note|Question|Page|Article|Video")) | 1507 | if (!xs_match(type, POSTLIKE_OBJECT_TYPE)) |
| 1508 | continue; | 1508 | continue; |
| 1509 | 1509 | ||
| 1510 | const char *from = NULL; | 1510 | const char *from = NULL; |
| @@ -1681,7 +1681,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1681 | /* discard non-Notes */ | 1681 | /* discard non-Notes */ |
| 1682 | const char *id = xs_dict_get(msg, "id"); | 1682 | const char *id = xs_dict_get(msg, "id"); |
| 1683 | const char *type = xs_dict_get(msg, "type"); | 1683 | const char *type = xs_dict_get(msg, "type"); |
| 1684 | if (!xs_match(type, "Note|Question|Page|Article|Video")) | 1684 | if (!xs_match(type, POSTLIKE_OBJECT_TYPE)) |
| 1685 | continue; | 1685 | continue; |
| 1686 | 1686 | ||
| 1687 | const char *from = NULL; | 1687 | const char *from = NULL; |
| @@ -29,6 +29,8 @@ extern int dbglevel; | |||
| 29 | 29 | ||
| 30 | #define L(s) (s) | 30 | #define L(s) (s) |
| 31 | 31 | ||
| 32 | #define POSTLIKE_OBJECT_TYPE "Note|Question|Page|Article|Video" | ||
| 33 | |||
| 32 | int mkdirx(const char *pathname); | 34 | int mkdirx(const char *pathname); |
| 33 | 35 | ||
| 34 | int valid_status(int status); | 36 | int valid_status(int status); |