diff options
| author | 2025-09-28 15:46:56 +0200 | |
|---|---|---|
| committer | 2025-09-28 15:46:56 +0200 | |
| commit | ab698c2bd6cbe74b2cca0a17fe210e159a43a2ce (patch) | |
| tree | 868fa6b77c7697f972cb7b9ea8d3ff49ab8652e1 /mastoapi.c | |
| parent | Temporary tweak. (diff) | |
| parent | Merge branch 'master' into feature/visibility (diff) | |
| download | snac2-ab698c2bd6cbe74b2cca0a17fe210e159a43a2ce.tar.gz snac2-ab698c2bd6cbe74b2cca0a17fe210e159a43a2ce.tar.xz snac2-ab698c2bd6cbe74b2cca0a17fe210e159a43a2ce.zip | |
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) | |||
| 884 | st = xs_dict_append(st, "content", s1); | 884 | st = xs_dict_append(st, "content", s1); |
| 885 | } | 885 | } |
| 886 | 886 | ||
| 887 | st = xs_dict_append(st, "visibility", | 887 | /* determine visibility: https://docs.joinmastodon.org/entities/Status/#visibility */ |
| 888 | is_msg_public(msg) ? "public" : "private"); | 888 | const int scope = get_msg_visibility(msg); |
| 889 | if (scope == SCOPE_PUBLIC) | ||
| 890 | st = xs_dict_append(st, "visibility", "public"); | ||
| 891 | else if (scope == SCOPE_FOLLOWERS) | ||
| 892 | st = xs_dict_append(st, "visibility", "private"); | ||
| 893 | else if (scope == SCOPE_MENTIONED) | ||
| 894 | st = xs_dict_append(st, "visibility", "direct"); | ||
| 895 | else if (scope == SCOPE_UNLISTED) | ||
| 896 | st = xs_dict_append(st, "visibility", "unlisted"); | ||
| 889 | 897 | ||
| 890 | tmp = xs_dict_get(msg, "sensitive"); | 898 | tmp = xs_dict_get(msg, "sensitive"); |
| 891 | if (xs_is_null(tmp)) | 899 | if (xs_is_null(tmp)) |
| @@ -2856,12 +2864,15 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path, | |||
| 2856 | } | 2864 | } |
| 2857 | 2865 | ||
| 2858 | /* prepare the message */ | 2866 | /* prepare the message */ |
| 2859 | int scope = 1; | 2867 | int scope = SCOPE_MENTIONED; |
| 2860 | if (strcmp(visibility, "unlisted") == 0) | 2868 | if (strcmp(visibility, "unlisted") == 0) |
| 2861 | scope = 2; | 2869 | scope = SCOPE_UNLISTED; |
| 2862 | else | 2870 | else |
| 2863 | if (strcmp(visibility, "public") == 0) | 2871 | if (strcmp(visibility, "public") == 0) |
| 2864 | scope = 0; | 2872 | scope = SCOPE_PUBLIC; |
| 2873 | else | ||
| 2874 | if (strcmp(visibility, "private") == 0) | ||
| 2875 | scope = SCOPE_FOLLOWERS; | ||
| 2865 | 2876 | ||
| 2866 | xs *msg = msg_note(&snac, content, NULL, irt, attach_list, scope, language, NULL); | 2877 | xs *msg = msg_note(&snac, content, NULL, irt, attach_list, scope, language, NULL); |
| 2867 | 2878 | ||