aboutsummaryrefslogtreecommitdiff
path: root/mastoapi.c
diff options
context:
space:
mode:
authorbyte <gf3qyrmw7@mozmail.com>2025-09-14 00:30:00 +0200
committerbyte <gf3qyrmw7@mozmail.com>2025-09-20 17:16:54 +0200
commitdcf5acaf538924aab532ea95bb311e4b80538856 (patch)
tree47ae5f679eab641c1a0fe28edbe834fce242c68e /mastoapi.c
parent428ae12639e044df129cd5cb96e394c311e27d38 (diff)
implementing visibility scopes
Diffstat (limited to 'mastoapi.c')
-rw-r--r--mastoapi.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/mastoapi.c b/mastoapi.c
index 568426b..ed46b89 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -884,8 +884,16 @@ xs_dict *mastoapi_status(snac *snac, const xs_dict *msg)
st = xs_dict_append(st, "content", s1);
}
- st = xs_dict_append(st, "visibility",
- is_msg_public(msg) ? "public" : "private");
+ /* determine visibility: https://docs.joinmastodon.org/entities/Status/#visibility */
+ const int scope = get_msg_visibility(msg);
+ if (scope == SCOPE_PUBLIC)
+ st = xs_dict_append(st, "visibility", "public");
+ else if (scope == SCOPE_FOLLOWERS)
+ st = xs_dict_append(st, "visibility", "private");
+ else if (scope == SCOPE_MENTIONED)
+ st = xs_dict_append(st, "visibility", "direct");
+ else if (scope == SCOPE_UNLISTED)
+ st = xs_dict_append(st, "visibility", "unlisted");
tmp = xs_dict_get(msg, "sensitive");
if (xs_is_null(tmp))
@@ -1767,7 +1775,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
if (valid_status(timeline_get_by_md5(&snac2, v, &msg))) {
/* add only posts by the author */
if (strcmp(xs_dict_get(msg, "type"), "Note") == 0 &&
- xs_startswith(xs_dict_get(msg, "id"), snac2.actor)) {
+ xs_startswith(xs_dict_get(msg, "id"), snac2.actor) && is_msg_public(msg)) {
xs *st = mastoapi_status(&snac2, msg);
if (st)
@@ -2856,12 +2864,15 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
}
/* prepare the message */
- int scope = 1;
+ int scope = SCOPE_MENTIONED;
if (strcmp(visibility, "unlisted") == 0)
- scope = 2;
+ scope = SCOPE_UNLISTED;
else
if (strcmp(visibility, "public") == 0)
- scope = 0;
+ scope = SCOPE_PUBLIC;
+ else
+ if (strcmp(visibility, "private") == 0)
+ scope = SCOPE_FOLLOWERS;
xs *msg = msg_note(&snac, content, NULL, irt, attach_list, scope, language, NULL);