mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-15 01:55:03 +00:00
mastoapi: Don't exclude posts of type Page or Article.
This commit is contained in:
parent
759042dc9f
commit
b7d0f297c3
2 changed files with 12 additions and 7 deletions
2
Makefile
2
Makefile
|
@ -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 \
|
||||||
xs_time.h xs_openssl.h snac.h
|
xs_time.h xs_openssl.h snac.h
|
||||||
main.o: main.c xs.h xs_io.h xs_json.h snac.h
|
main.o: main.c xs.h xs_io.h xs_json.h snac.h
|
||||||
mastoapi.o: mastoapi.c xs.h xs_openssl.h xs_json.h xs_io.h xs_time.h \
|
mastoapi.o: mastoapi.c xs.h xs_openssl.h xs_json.h xs_io.h xs_time.h \
|
||||||
xs_glob.h xs_set.h xs_random.h xs_url.h xs_mime.h snac.h
|
xs_glob.h xs_set.h xs_random.h xs_url.h xs_mime.h xs_match.h snac.h
|
||||||
snac.o: snac.c xs.h xs_io.h xs_unicode.h xs_json.h xs_curl.h xs_openssl.h \
|
snac.o: snac.c xs.h xs_io.h xs_unicode.h xs_json.h xs_curl.h xs_openssl.h \
|
||||||
xs_socket.h xs_url.h xs_httpd.h xs_mime.h xs_regex.h xs_set.h xs_time.h \
|
xs_socket.h xs_url.h xs_httpd.h xs_mime.h xs_regex.h xs_set.h xs_time.h \
|
||||||
xs_glob.h xs_random.h xs_match.h snac.h
|
xs_glob.h xs_random.h xs_match.h snac.h
|
||||||
|
|
17
mastoapi.c
17
mastoapi.c
|
@ -13,6 +13,7 @@
|
||||||
#include "xs_random.h"
|
#include "xs_random.h"
|
||||||
#include "xs_url.h"
|
#include "xs_url.h"
|
||||||
#include "xs_mime.h"
|
#include "xs_mime.h"
|
||||||
|
#include "xs_match.h"
|
||||||
|
|
||||||
#include "snac.h"
|
#include "snac.h"
|
||||||
|
|
||||||
|
@ -1336,15 +1337,19 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* discard non-Notes */
|
/* discard non-Notes */
|
||||||
|
const char *id = xs_dict_get(msg, "id");
|
||||||
const char *type = xs_dict_get(msg, "type");
|
const char *type = xs_dict_get(msg, "type");
|
||||||
if (strcmp(type, "Note") != 0 && strcmp(type, "Question") != 0)
|
if (!xs_match(type, "Note|Question|Page|Article"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const char *atto = xs_dict_get(msg, "attributedTo");
|
const char *from;
|
||||||
const char *id = xs_dict_get(msg, "id");
|
if (strcmp(type, "Page") == 0)
|
||||||
|
from = xs_dict_get(msg, "audience");
|
||||||
|
else
|
||||||
|
from = xs_dict_get(msg, "attributedTo");
|
||||||
|
|
||||||
/* is this message from a person we don't follow? */
|
/* is this message from a person we don't follow? */
|
||||||
if (strcmp(atto, snac1.actor) && !following_check(&snac1, atto)) {
|
if (strcmp(from, snac1.actor) && !following_check(&snac1, from)) {
|
||||||
/* discard if it was not boosted */
|
/* discard if it was not boosted */
|
||||||
xs *idx = object_announces(id);
|
xs *idx = object_announces(id);
|
||||||
|
|
||||||
|
@ -1353,7 +1358,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* discard notes from muted morons */
|
/* discard notes from muted morons */
|
||||||
if (is_muted(&snac1, atto))
|
if (is_muted(&snac1, from))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* discard hidden notes */
|
/* discard hidden notes */
|
||||||
|
@ -1361,7 +1366,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* discard poll votes (they have a name) */
|
/* discard poll votes (they have a name) */
|
||||||
if (!xs_is_null(xs_dict_get(msg, "name")))
|
if (strcmp(type, "Page") != 0 && !xs_is_null(xs_dict_get(msg, "name")))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* convert the Note into a Mastodon status */
|
/* convert the Note into a Mastodon status */
|
||||||
|
|
Loading…
Reference in a new issue