diff options
| author | 2023-10-16 20:49:58 +0200 | |
|---|---|---|
| committer | 2023-10-16 20:49:58 +0200 | |
| commit | b7d0f297c3a6984327f808eb60af177078e5c742 (patch) | |
| tree | 61d06ce7a8a5ae2d5156e33c37d7bd12c9f4c020 | |
| parent | Drop updates for unknown posts. (diff) | |
| download | snac2-b7d0f297c3a6984327f808eb60af177078e5c742.tar.gz snac2-b7d0f297c3a6984327f808eb60af177078e5c742.tar.xz snac2-b7d0f297c3a6984327f808eb60af177078e5c742.zip | |
mastoapi: Don't exclude posts of type Page or Article.
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | mastoapi.c | 17 |
2 files changed, 12 insertions, 7 deletions
| @@ -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 \ | |||
| 46 | xs_time.h xs_openssl.h snac.h | 46 | xs_time.h xs_openssl.h snac.h |
| 47 | main.o: main.c xs.h xs_io.h xs_json.h snac.h | 47 | main.o: main.c xs.h xs_io.h xs_json.h snac.h |
| 48 | mastoapi.o: mastoapi.c xs.h xs_openssl.h xs_json.h xs_io.h xs_time.h \ | 48 | mastoapi.o: mastoapi.c xs.h xs_openssl.h xs_json.h xs_io.h xs_time.h \ |
| 49 | xs_glob.h xs_set.h xs_random.h xs_url.h xs_mime.h snac.h | 49 | xs_glob.h xs_set.h xs_random.h xs_url.h xs_mime.h xs_match.h snac.h |
| 50 | snac.o: snac.c xs.h xs_io.h xs_unicode.h xs_json.h xs_curl.h xs_openssl.h \ | 50 | snac.o: snac.c xs.h xs_io.h xs_unicode.h xs_json.h xs_curl.h xs_openssl.h \ |
| 51 | xs_socket.h xs_url.h xs_httpd.h xs_mime.h xs_regex.h xs_set.h xs_time.h \ | 51 | xs_socket.h xs_url.h xs_httpd.h xs_mime.h xs_regex.h xs_set.h xs_time.h \ |
| 52 | xs_glob.h xs_random.h xs_match.h snac.h | 52 | xs_glob.h xs_random.h xs_match.h snac.h |
| @@ -13,6 +13,7 @@ | |||
| 13 | #include "xs_random.h" | 13 | #include "xs_random.h" |
| 14 | #include "xs_url.h" | 14 | #include "xs_url.h" |
| 15 | #include "xs_mime.h" | 15 | #include "xs_mime.h" |
| 16 | #include "xs_match.h" | ||
| 16 | 17 | ||
| 17 | #include "snac.h" | 18 | #include "snac.h" |
| 18 | 19 | ||
| @@ -1336,15 +1337,19 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1336 | continue; | 1337 | continue; |
| 1337 | 1338 | ||
| 1338 | /* discard non-Notes */ | 1339 | /* discard non-Notes */ |
| 1340 | const char *id = xs_dict_get(msg, "id"); | ||
| 1339 | const char *type = xs_dict_get(msg, "type"); | 1341 | const char *type = xs_dict_get(msg, "type"); |
| 1340 | if (strcmp(type, "Note") != 0 && strcmp(type, "Question") != 0) | 1342 | if (!xs_match(type, "Note|Question|Page|Article")) |
| 1341 | continue; | 1343 | continue; |
| 1342 | 1344 | ||
| 1343 | const char *atto = xs_dict_get(msg, "attributedTo"); | 1345 | const char *from; |
| 1344 | const char *id = xs_dict_get(msg, "id"); | 1346 | if (strcmp(type, "Page") == 0) |
| 1347 | from = xs_dict_get(msg, "audience"); | ||
| 1348 | else | ||
| 1349 | from = xs_dict_get(msg, "attributedTo"); | ||
| 1345 | 1350 | ||
| 1346 | /* is this message from a person we don't follow? */ | 1351 | /* is this message from a person we don't follow? */ |
| 1347 | if (strcmp(atto, snac1.actor) && !following_check(&snac1, atto)) { | 1352 | if (strcmp(from, snac1.actor) && !following_check(&snac1, from)) { |
| 1348 | /* discard if it was not boosted */ | 1353 | /* discard if it was not boosted */ |
| 1349 | xs *idx = object_announces(id); | 1354 | xs *idx = object_announces(id); |
| 1350 | 1355 | ||
| @@ -1353,7 +1358,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1353 | } | 1358 | } |
| 1354 | 1359 | ||
| 1355 | /* discard notes from muted morons */ | 1360 | /* discard notes from muted morons */ |
| 1356 | if (is_muted(&snac1, atto)) | 1361 | if (is_muted(&snac1, from)) |
| 1357 | continue; | 1362 | continue; |
| 1358 | 1363 | ||
| 1359 | /* discard hidden notes */ | 1364 | /* discard hidden notes */ |
| @@ -1361,7 +1366,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1361 | continue; | 1366 | continue; |
| 1362 | 1367 | ||
| 1363 | /* discard poll votes (they have a name) */ | 1368 | /* discard poll votes (they have a name) */ |
| 1364 | if (!xs_is_null(xs_dict_get(msg, "name"))) | 1369 | if (strcmp(type, "Page") != 0 && !xs_is_null(xs_dict_get(msg, "name"))) |
| 1365 | continue; | 1370 | continue; |
| 1366 | 1371 | ||
| 1367 | /* convert the Note into a Mastodon status */ | 1372 | /* convert the Note into a Mastodon status */ |