diff options
| author | grunfink <grunfink@noreply.codeberg.org> | 2025-09-28 15:46:56 +0200 |
|---|---|---|
| committer | grunfink <grunfink@noreply.codeberg.org> | 2025-09-28 15:46:56 +0200 |
| commit | ab698c2bd6cbe74b2cca0a17fe210e159a43a2ce (patch) | |
| tree | 868fa6b77c7697f972cb7b9ea8d3ff49ab8652e1 /mastoapi.c | |
| parent | 65d868092cd8bddad703f9dad77867bb45ca3286 (diff) | |
| parent | 5610ffb13bebe2739cb865f47ee73725512ec600 (diff) | |
Merge pull request 'implementing scopes' (#474) from byte/snac2:feature/visibility into master
Reviewed-on: https://codeberg.org/grunfink/snac2/pulls/474
Diffstat (limited to 'mastoapi.c')
| -rw-r--r-- | mastoapi.c | 21 |
1 files changed, 16 insertions, 5 deletions
@@ -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)) @@ -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); |