commit b7d0f29
default
·
2023-10-16 18:49:58 +0000 UTC
parent 759042d
mastoapi: Don't exclude posts of type Page or Article.
2 files changed,
+12,
-7
M
Makefile
M
Makefile
+1,
-1
1@@ -46,7 +46,7 @@ httpd.o: httpd.c xs.h xs_io.h xs_json.h xs_socket.h xs_httpd.h xs_mime.h \
2 xs_time.h xs_openssl.h snac.h
3 main.o: main.c xs.h xs_io.h xs_json.h snac.h
4 mastoapi.o: mastoapi.c xs.h xs_openssl.h xs_json.h xs_io.h xs_time.h \
5- xs_glob.h xs_set.h xs_random.h xs_url.h xs_mime.h snac.h
6+ xs_glob.h xs_set.h xs_random.h xs_url.h xs_mime.h xs_match.h snac.h
7 snac.o: snac.c xs.h xs_io.h xs_unicode.h xs_json.h xs_curl.h xs_openssl.h \
8 xs_socket.h xs_url.h xs_httpd.h xs_mime.h xs_regex.h xs_set.h xs_time.h \
9 xs_glob.h xs_random.h xs_match.h snac.h
+11,
-6
1@@ -13,6 +13,7 @@
2 #include "xs_random.h"
3 #include "xs_url.h"
4 #include "xs_mime.h"
5+#include "xs_match.h"
6
7 #include "snac.h"
8
9@@ -1336,15 +1337,19 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
10 continue;
11
12 /* discard non-Notes */
13+ const char *id = xs_dict_get(msg, "id");
14 const char *type = xs_dict_get(msg, "type");
15- if (strcmp(type, "Note") != 0 && strcmp(type, "Question") != 0)
16+ if (!xs_match(type, "Note|Question|Page|Article"))
17 continue;
18
19- const char *atto = xs_dict_get(msg, "attributedTo");
20- const char *id = xs_dict_get(msg, "id");
21+ const char *from;
22+ if (strcmp(type, "Page") == 0)
23+ from = xs_dict_get(msg, "audience");
24+ else
25+ from = xs_dict_get(msg, "attributedTo");
26
27 /* is this message from a person we don't follow? */
28- if (strcmp(atto, snac1.actor) && !following_check(&snac1, atto)) {
29+ if (strcmp(from, snac1.actor) && !following_check(&snac1, from)) {
30 /* discard if it was not boosted */
31 xs *idx = object_announces(id);
32
33@@ -1353,7 +1358,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
34 }
35
36 /* discard notes from muted morons */
37- if (is_muted(&snac1, atto))
38+ if (is_muted(&snac1, from))
39 continue;
40
41 /* discard hidden notes */
42@@ -1361,7 +1366,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
43 continue;
44
45 /* discard poll votes (they have a name) */
46- if (!xs_is_null(xs_dict_get(msg, "name")))
47+ if (strcmp(type, "Page") != 0 && !xs_is_null(xs_dict_get(msg, "name")))
48 continue;
49
50 /* convert the Note into a Mastodon status */