commit 5344aca
grunfink
·
2026-08-28 10:02:52 +0000 UTC
parent 5107778
mastoapi: Return unauthorized in several unimplemented entrypoints.
1 files changed,
+56,
-26
+56,
-26
1@@ -2307,10 +2307,13 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
2 }
3 else
4 if (strcmp(cmd, "/v1/conversations") == 0) { /** **/
5- /* TBD */
6- *body = xs_dup("[]");
7- *ctype = "application/json";
8- status = HTTP_STATUS_OK;
9+ if (logged_in) {
10+ *body = xs_dup("[]");
11+ *ctype = "application/json";
12+ status = HTTP_STATUS_OK;
13+ }
14+ else
15+ status = HTTP_STATUS_UNAUTHORIZED;
16 }
17 else
18 if (strcmp(cmd, "/v1/notifications") == 0) { /** **/
19@@ -2471,25 +2474,37 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
20 else
21 if (strcmp(cmd, "/v1/filters") == 0) { /** **/
22 /* snac will never have filters */
23- *body = xs_dup("[]");
24- *ctype = "application/json";
25- status = HTTP_STATUS_OK;
26+ if (logged_in) {
27+ *body = xs_dup("[]");
28+ *ctype = "application/json";
29+ status = HTTP_STATUS_OK;
30+ }
31+ else
32+ status = HTTP_STATUS_UNAUTHORIZED;
33 }
34 else
35 if (strcmp(cmd, "/v2/filters") == 0) { /** **/
36 /* snac will never have filters
37 * but still, without a v2 endpoint a short delay is introduced
38 * in some apps */
39- *body = xs_dup("[]");
40- *ctype = "application/json";
41- status = HTTP_STATUS_OK;
42+ if (logged_in) {
43+ *body = xs_dup("[]");
44+ *ctype = "application/json";
45+ status = HTTP_STATUS_OK;
46+ }
47+ else
48+ status = HTTP_STATUS_UNAUTHORIZED;
49 }
50 else
51 if (strcmp(cmd, "/v1/favourites") == 0) { /** **/
52 /* snac will never support a list of favourites */
53- *body = xs_dup("[]");
54- *ctype = "application/json";
55- status = HTTP_STATUS_OK;
56+ if (logged_in) {
57+ *body = xs_dup("[]");
58+ *ctype = "application/json";
59+ status = HTTP_STATUS_OK;
60+ }
61+ else
62+ status = HTTP_STATUS_UNAUTHORIZED;
63 }
64 else
65 if (strcmp(cmd, "/v1/bookmarks") == 0) { /** **/
66@@ -2580,10 +2595,13 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
67 }
68 else
69 if (strcmp(cmd, "/v1/scheduled_statuses") == 0) { /** **/
70- /* TBD */
71- *body = xs_dup("[]");
72- *ctype = "application/json";
73- status = HTTP_STATUS_OK;
74+ if (logged_in) {
75+ *body = xs_dup("[]");
76+ *ctype = "application/json";
77+ status = HTTP_STATUS_OK;
78+ }
79+ else
80+ status = HTTP_STATUS_UNAUTHORIZED;
81 }
82 else
83 if (strcmp(cmd, "/v1/follow_requests") == 0) { /** **/
84@@ -2951,9 +2969,13 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
85 else
86 if (strcmp(cmd, "/v1/preferences") == 0) { /** **/
87 /* TBD */
88- *body = xs_dup("{}");
89- *ctype = "application/json";
90- status = HTTP_STATUS_OK;
91+ if (logged_in) {
92+ *body = xs_dup("{}");
93+ *ctype = "application/json";
94+ status = HTTP_STATUS_OK;
95+ }
96+ else
97+ status = HTTP_STATUS_UNAUTHORIZED;
98 }
99 else
100 if (strcmp(cmd, "/v1/markers") == 0) { /** **/
101@@ -3004,15 +3026,23 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
102 }
103 else
104 if (strcmp(cmd, "/v1/blocks") == 0) { /** **/
105- *body = xs_dup("[]");
106- *ctype = "application/json";
107- status = HTTP_STATUS_OK;
108+ if (logged_in) {
109+ *body = xs_dup("[]");
110+ *ctype = "application/json";
111+ status = HTTP_STATUS_OK;
112+ }
113+ else
114+ status = HTTP_STATUS_UNAUTHORIZED;
115 }
116 else
117 if (strcmp(cmd, "/v1/mutes") == 0) { /** **/
118- *body = xs_dup("[]");
119- *ctype = "application/json";
120- status = HTTP_STATUS_OK;
121+ if (logged_in) {
122+ *body = xs_dup("[]");
123+ *ctype = "application/json";
124+ status = HTTP_STATUS_OK;
125+ }
126+ else
127+ status = HTTP_STATUS_UNAUTHORIZED;
128 }
129 else
130 if (strcmp(cmd, "/v1/trends/tags") == 0) { /** **/