commit e1ce85d
default
·
2024-05-11 16:46:15 +0000 UTC
parent 3954361
Unified post-like object type match.
5 files changed,
+8,
-6
+1,
-1
1@@ -355,7 +355,7 @@ int timeline_request(snac *snac, char **id, xs_str **wrk, int level)
2 type = "(null)";
3 }
4
5- if (xs_match(type, "Note|Page|Article|Video")) {
6+ if (xs_match(type, POSTLIKE_OBJECT_TYPE)) {
7 const char *actor = get_atto(object);
8
9 if (content_check("filter_reject.txt", object))
M
data.c
+1,
-1
1@@ -2577,7 +2577,7 @@ xs_list *content_search(snac *user, const char *regex,
2 if (!valid_status(timeline_get_by_md5(user, md5, &post)))
3 continue;
4
5- if (!xs_match(xs_dict_get_def(post, "type", "-"), "Note|Question|Page|Article|Video"))
6+ if (!xs_match(xs_dict_get_def(post, "type", "-"), POSTLIKE_OBJECT_TYPE))
7 continue;
8
9 char *content = xs_dict_get(post, "content");
M
html.c
+2,
-2
1@@ -256,7 +256,7 @@ xs_html *html_msg_icon(snac *user, char *actor_id, const xs_dict *msg)
2 int priv = 0;
3 const char *type = xs_dict_get(msg, "type");
4
5- if (xs_match(type, "Note|Question|Page|Article|Video"))
6+ if (xs_match(type, POSTLIKE_OBJECT_TYPE))
7 url = xs_dict_get(msg, "id");
8
9 priv = !is_msg_public(msg);
10@@ -1405,7 +1405,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
11 html_msg_icon(read_only ? NULL : user, xs_dict_get(msg, "actor"), msg)));
12 }
13 else
14- if (!xs_match(type, "Note|Question|Page|Article|Video")) {
15+ if (!xs_match(type, POSTLIKE_OBJECT_TYPE)) {
16 /* skip oddities */
17 return NULL;
18 }
+2,
-2
1@@ -1504,7 +1504,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
2 /* discard non-Notes */
3 const char *id = xs_dict_get(msg, "id");
4 const char *type = xs_dict_get(msg, "type");
5- if (!xs_match(type, "Note|Question|Page|Article|Video"))
6+ if (!xs_match(type, POSTLIKE_OBJECT_TYPE))
7 continue;
8
9 const char *from = NULL;
10@@ -1681,7 +1681,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
11 /* discard non-Notes */
12 const char *id = xs_dict_get(msg, "id");
13 const char *type = xs_dict_get(msg, "type");
14- if (!xs_match(type, "Note|Question|Page|Article|Video"))
15+ if (!xs_match(type, POSTLIKE_OBJECT_TYPE))
16 continue;
17
18 const char *from = NULL;
M
snac.h
+2,
-0
1@@ -29,6 +29,8 @@ extern int dbglevel;
2
3 #define L(s) (s)
4
5+#define POSTLIKE_OBJECT_TYPE "Note|Question|Page|Article|Video"
6+
7 int mkdirx(const char *pathname);
8
9 int valid_status(int status);