commit 52e3d60

default  ·  2023-04-16 06:13:45 +0000 UTC
parent 0240c87
Also accept /api/v2 urls.
1 files changed,  +9, -3
+9, -3
 1@@ -652,7 +652,7 @@ int process_auth_token(snac *snac, const xs_dict *req)
 2 int mastoapi_get_handler(const xs_dict *req, const char *q_path,
 3                          char **body, int *b_size, char **ctype)
 4 {
 5-    if (!xs_startswith(q_path, "/api/v1/"))
 6+    if (!xs_startswith(q_path, "/api/v1/") && !xs_startswith(q_path, "/api/v2/"))
 7         return 0;
 8 
 9     srv_debug(1, xs_fmt("mastoapi_get_handler %s", q_path));
10@@ -1168,7 +1168,7 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
11                           const char *payload, int p_size,
12                           char **body, int *b_size, char **ctype)
13 {
14-    if (!xs_startswith(q_path, "/api/v1/"))
15+    if (!xs_startswith(q_path, "/api/v1/") && !xs_startswith(q_path, "/api/v2/"))
16         return 0;
17 
18     srv_debug(1, xs_fmt("mastoapi_post_handler %s", q_path));
19@@ -1416,7 +1416,13 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
20         }
21         else
22             status = 401;
23-
24+    }
25+    else
26+    if (strcmp(cmd, "/v1/media") == 0 || strcmp(cmd, "/v2/media") == 0) {
27+        if (logged_in) {
28+        }
29+        else
30+            status = 401;
31     }
32 
33     /* user cleanup */