summaryrefslogtreecommitdiff
path: root/mastoapi.c
diff options
context:
space:
mode:
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)
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))
@@ -1767,7 +1775,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
1767 if (valid_status(timeline_get_by_md5(&snac2, v, &msg))) { 1775 if (valid_status(timeline_get_by_md5(&snac2, v, &msg))) {
1768 /* add only posts by the author */ 1776 /* add only posts by the author */
1769 if (strcmp(xs_dict_get(msg, "type"), "Note") == 0 && 1777 if (strcmp(xs_dict_get(msg, "type"), "Note") == 0 &&
1770 xs_startswith(xs_dict_get(msg, "id"), snac2.actor)) { 1778 xs_startswith(xs_dict_get(msg, "id"), snac2.actor) && is_msg_public(msg)) {
1771 xs *st = mastoapi_status(&snac2, msg); 1779 xs *st = mastoapi_status(&snac2, msg);
1772 1780
1773 if (st) 1781 if (st)
@@ -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