summaryrefslogtreecommitdiff
path: root/mastoapi.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2023-10-08 00:06:37 +0200
committerdefault <nobody@localhost>2023-10-08 00:06:37 +0200
commit8524ace23f1ebec07fd4d51171e121b1f1e75007 (patch)
tree03f98d1ce6d29b85c31dc85e104dbfda2ff9aab8 /mastoapi.c
parent8676d872996c7486ada76c344deee0d3fdc3f188 (diff)
Hide posts from the public web for accounts with 'private' == true.
Diffstat (limited to 'mastoapi.c')
-rw-r--r--mastoapi.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/mastoapi.c b/mastoapi.c
index 40ad12b..273807b 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -1377,6 +1377,25 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
if (strcmp(type, "Note") != 0 && strcmp(type, "Question") != 0)
continue;
+ /* discard private users */
+ {
+ const char *atto = xs_dict_get(msg, "attributedTo");
+ xs *l = xs_split(atto, "/");
+ const char *uid = xs_list_get(l, -1);
+ snac p_user;
+ int skip = 1;
+
+ if (uid && user_open(&p_user, uid)) {
+ if (xs_type(xs_dict_get(p_user.config, "private")) != XSTYPE_TRUE)
+ skip = 0;
+
+ user_free(&p_user);
+ }
+
+ if (skip)
+ continue;
+ }
+
/* convert the Note into a Mastodon status */
xs *st = mastoapi_status(user, msg);