diff options
Diffstat (limited to 'mastoapi.c')
| -rw-r--r-- | mastoapi.c | 184 |
1 files changed, 92 insertions, 92 deletions
| @@ -32,9 +32,9 @@ int app_add(const char *id, const xs_dict *app) | |||
| 32 | /* stores an app */ | 32 | /* stores an app */ |
| 33 | { | 33 | { |
| 34 | if (!xs_is_hex(id)) | 34 | if (!xs_is_hex(id)) |
| 35 | return 500; | 35 | return HTTP_STATUS_INTERNAL_SERVER_ERROR; |
| 36 | 36 | ||
| 37 | int status = 201; | 37 | int status = HTTP_STATUS_CREATED; |
| 38 | xs *fn = xs_fmt("%s/app/", srv_basedir); | 38 | xs *fn = xs_fmt("%s/app/", srv_basedir); |
| 39 | FILE *f; | 39 | FILE *f; |
| 40 | 40 | ||
| @@ -47,7 +47,7 @@ int app_add(const char *id, const xs_dict *app) | |||
| 47 | fclose(f); | 47 | fclose(f); |
| 48 | } | 48 | } |
| 49 | else | 49 | else |
| 50 | status = 500; | 50 | status = HTTP_STATUS_INTERNAL_SERVER_ERROR; |
| 51 | 51 | ||
| 52 | return status; | 52 | return status; |
| 53 | } | 53 | } |
| @@ -95,9 +95,9 @@ int token_add(const char *id, const xs_dict *token) | |||
| 95 | /* stores a token */ | 95 | /* stores a token */ |
| 96 | { | 96 | { |
| 97 | if (!xs_is_hex(id)) | 97 | if (!xs_is_hex(id)) |
| 98 | return 500; | 98 | return HTTP_STATUS_INTERNAL_SERVER_ERROR; |
| 99 | 99 | ||
| 100 | int status = 201; | 100 | int status = HTTP_STATUS_CREATED; |
| 101 | xs *fn = xs_fmt("%s/token/", srv_basedir); | 101 | xs *fn = xs_fmt("%s/token/", srv_basedir); |
| 102 | FILE *f; | 102 | FILE *f; |
| 103 | 103 | ||
| @@ -110,7 +110,7 @@ int token_add(const char *id, const xs_dict *token) | |||
| 110 | fclose(f); | 110 | fclose(f); |
| 111 | } | 111 | } |
| 112 | else | 112 | else |
| 113 | status = 500; | 113 | status = HTTP_STATUS_INTERNAL_SERVER_ERROR; |
| 114 | 114 | ||
| 115 | return status; | 115 | return status; |
| 116 | } | 116 | } |
| @@ -174,7 +174,7 @@ int oauth_get_handler(const xs_dict *req, const char *q_path, | |||
| 174 | if (!xs_startswith(q_path, "/oauth/")) | 174 | if (!xs_startswith(q_path, "/oauth/")) |
| 175 | return 0; | 175 | return 0; |
| 176 | 176 | ||
| 177 | int status = 404; | 177 | int status = HTTP_STATUS_NOT_FOUND; |
| 178 | const xs_dict *msg = xs_dict_get(req, "q_vars"); | 178 | const xs_dict *msg = xs_dict_get(req, "q_vars"); |
| 179 | xs *cmd = xs_replace_n(q_path, "/oauth", "", 1); | 179 | xs *cmd = xs_replace_n(q_path, "/oauth", "", 1); |
| 180 | 180 | ||
| @@ -186,7 +186,7 @@ int oauth_get_handler(const xs_dict *req, const char *q_path, | |||
| 186 | const char *rtype = xs_dict_get(msg, "response_type"); | 186 | const char *rtype = xs_dict_get(msg, "response_type"); |
| 187 | const char *state = xs_dict_get(msg, "state"); | 187 | const char *state = xs_dict_get(msg, "state"); |
| 188 | 188 | ||
| 189 | status = 400; | 189 | status = HTTP_STATUS_BAD_REQUEST; |
| 190 | 190 | ||
| 191 | if (cid && ruri && rtype && strcmp(rtype, "code") == 0) { | 191 | if (cid && ruri && rtype && strcmp(rtype, "code") == 0) { |
| 192 | xs *app = app_get(cid); | 192 | xs *app = app_get(cid); |
| @@ -201,7 +201,7 @@ int oauth_get_handler(const xs_dict *req, const char *q_path, | |||
| 201 | *body = xs_fmt(login_page, host, host, "", proto, host, "oauth/x-snac-login", | 201 | *body = xs_fmt(login_page, host, host, "", proto, host, "oauth/x-snac-login", |
| 202 | ruri, cid, state, USER_AGENT); | 202 | ruri, cid, state, USER_AGENT); |
| 203 | *ctype = "text/html"; | 203 | *ctype = "text/html"; |
| 204 | status = 200; | 204 | status = HTTP_STATUS_OK; |
| 205 | 205 | ||
| 206 | srv_debug(1, xs_fmt("oauth authorize: generating login page")); | 206 | srv_debug(1, xs_fmt("oauth authorize: generating login page")); |
| 207 | } | 207 | } |
| @@ -219,7 +219,7 @@ int oauth_get_handler(const xs_dict *req, const char *q_path, | |||
| 219 | *body = xs_fmt(login_page, host, host, "", proto, host, "oauth/x-snac-get-token", | 219 | *body = xs_fmt(login_page, host, host, "", proto, host, "oauth/x-snac-get-token", |
| 220 | "", "", "", USER_AGENT); | 220 | "", "", "", USER_AGENT); |
| 221 | *ctype = "text/html"; | 221 | *ctype = "text/html"; |
| 222 | status = 200; | 222 | status = HTTP_STATUS_OK; |
| 223 | 223 | ||
| 224 | } | 224 | } |
| 225 | 225 | ||
| @@ -237,7 +237,7 @@ int oauth_post_handler(const xs_dict *req, const char *q_path, | |||
| 237 | if (!xs_startswith(q_path, "/oauth/")) | 237 | if (!xs_startswith(q_path, "/oauth/")) |
| 238 | return 0; | 238 | return 0; |
| 239 | 239 | ||
| 240 | int status = 404; | 240 | int status = HTTP_STATUS_NOT_FOUND; |
| 241 | 241 | ||
| 242 | const char *i_ctype = xs_dict_get(req, "content-type"); | 242 | const char *i_ctype = xs_dict_get(req, "content-type"); |
| 243 | xs *args = NULL; | 243 | xs *args = NULL; |
| @@ -255,7 +255,7 @@ int oauth_post_handler(const xs_dict *req, const char *q_path, | |||
| 255 | args = xs_dup(xs_dict_get(req, "p_vars")); | 255 | args = xs_dup(xs_dict_get(req, "p_vars")); |
| 256 | 256 | ||
| 257 | if (args == NULL) | 257 | if (args == NULL) |
| 258 | return 400; | 258 | return HTTP_STATUS_BAD_REQUEST; |
| 259 | 259 | ||
| 260 | xs *cmd = xs_replace_n(q_path, "/oauth", "", 1); | 260 | xs *cmd = xs_replace_n(q_path, "/oauth", "", 1); |
| 261 | 261 | ||
| @@ -274,7 +274,7 @@ int oauth_post_handler(const xs_dict *req, const char *q_path, | |||
| 274 | *body = xs_fmt(login_page, host, host, "LOGIN INCORRECT", proto, host, "oauth/x-snac-login", | 274 | *body = xs_fmt(login_page, host, host, "LOGIN INCORRECT", proto, host, "oauth/x-snac-login", |
| 275 | redir, cid, state, USER_AGENT); | 275 | redir, cid, state, USER_AGENT); |
| 276 | *ctype = "text/html"; | 276 | *ctype = "text/html"; |
| 277 | status = 200; | 277 | status = HTTP_STATUS_OK; |
| 278 | 278 | ||
| 279 | if (login && passwd && redir && cid) { | 279 | if (login && passwd && redir && cid) { |
| 280 | snac snac; | 280 | snac snac; |
| @@ -296,7 +296,7 @@ int oauth_post_handler(const xs_dict *req, const char *q_path, | |||
| 296 | else | 296 | else |
| 297 | *body = xs_fmt("%s?code=%s", redir, code); | 297 | *body = xs_fmt("%s?code=%s", redir, code); |
| 298 | 298 | ||
| 299 | status = 303; | 299 | status = HTTP_STATUS_SEE_OTHER; |
| 300 | } | 300 | } |
| 301 | 301 | ||
| 302 | /* if there is a state, add it */ | 302 | /* if there is a state, add it */ |
| @@ -375,12 +375,12 @@ int oauth_post_handler(const xs_dict *req, const char *q_path, | |||
| 375 | xs *app = app_get(cid); | 375 | xs *app = app_get(cid); |
| 376 | 376 | ||
| 377 | if (app == NULL) { | 377 | if (app == NULL) { |
| 378 | status = 401; | 378 | status = HTTP_STATUS_UNAUTHORIZED; |
| 379 | srv_log(xs_fmt("oauth token: invalid app %s", cid)); | 379 | srv_log(xs_fmt("oauth token: invalid app %s", cid)); |
| 380 | } | 380 | } |
| 381 | else | 381 | else |
| 382 | if (strcmp(csec, xs_dict_get(app, "client_secret")) != 0) { | 382 | if (strcmp(csec, xs_dict_get(app, "client_secret")) != 0) { |
| 383 | status = 401; | 383 | status = HTTP_STATUS_UNAUTHORIZED; |
| 384 | srv_log(xs_fmt("oauth token: invalid client_secret for app %s", cid)); | 384 | srv_log(xs_fmt("oauth token: invalid client_secret for app %s", cid)); |
| 385 | } | 385 | } |
| 386 | else { | 386 | else { |
| @@ -397,7 +397,7 @@ int oauth_post_handler(const xs_dict *req, const char *q_path, | |||
| 397 | 397 | ||
| 398 | *body = xs_json_dumps(rsp, 4); | 398 | *body = xs_json_dumps(rsp, 4); |
| 399 | *ctype = "application/json"; | 399 | *ctype = "application/json"; |
| 400 | status = 200; | 400 | status = HTTP_STATUS_OK; |
| 401 | 401 | ||
| 402 | const char *uid = xs_dict_get(app, "uid"); | 402 | const char *uid = xs_dict_get(app, "uid"); |
| 403 | 403 | ||
| @@ -416,7 +416,7 @@ int oauth_post_handler(const xs_dict *req, const char *q_path, | |||
| 416 | } | 416 | } |
| 417 | else { | 417 | else { |
| 418 | srv_debug(1, xs_fmt("oauth token: invalid or unset arguments")); | 418 | srv_debug(1, xs_fmt("oauth token: invalid or unset arguments")); |
| 419 | status = 400; | 419 | status = HTTP_STATUS_BAD_REQUEST; |
| 420 | } | 420 | } |
| 421 | } | 421 | } |
| 422 | else | 422 | else |
| @@ -433,12 +433,12 @@ int oauth_post_handler(const xs_dict *req, const char *q_path, | |||
| 433 | 433 | ||
| 434 | if (token == NULL || strcmp(csec, xs_dict_get(token, "client_secret")) != 0) { | 434 | if (token == NULL || strcmp(csec, xs_dict_get(token, "client_secret")) != 0) { |
| 435 | srv_debug(1, xs_fmt("oauth revoke: bad secret for token %s", tokid)); | 435 | srv_debug(1, xs_fmt("oauth revoke: bad secret for token %s", tokid)); |
| 436 | status = 403; | 436 | status = HTTP_STATUS_FORBIDDEN; |
| 437 | } | 437 | } |
| 438 | else { | 438 | else { |
| 439 | token_del(tokid); | 439 | token_del(tokid); |
| 440 | srv_debug(1, xs_fmt("oauth revoke: revoked token %s", tokid)); | 440 | srv_debug(1, xs_fmt("oauth revoke: revoked token %s", tokid)); |
| 441 | status = 200; | 441 | status = HTTP_STATUS_OK; |
| 442 | 442 | ||
| 443 | /* also delete the app, as it serves no purpose from now on */ | 443 | /* also delete the app, as it serves no purpose from now on */ |
| 444 | app_del(cid); | 444 | app_del(cid); |
| @@ -446,7 +446,7 @@ int oauth_post_handler(const xs_dict *req, const char *q_path, | |||
| 446 | } | 446 | } |
| 447 | else { | 447 | else { |
| 448 | srv_debug(1, xs_fmt("oauth revoke: invalid or unset arguments")); | 448 | srv_debug(1, xs_fmt("oauth revoke: invalid or unset arguments")); |
| 449 | status = 403; | 449 | status = HTTP_STATUS_FORBIDDEN; |
| 450 | } | 450 | } |
| 451 | } | 451 | } |
| 452 | if (strcmp(cmd, "/x-snac-get-token") == 0) { /** **/ | 452 | if (strcmp(cmd, "/x-snac-get-token") == 0) { /** **/ |
| @@ -459,7 +459,7 @@ int oauth_post_handler(const xs_dict *req, const char *q_path, | |||
| 459 | *body = xs_fmt(login_page, host, host, "LOGIN INCORRECT", proto, host, "oauth/x-snac-get-token", | 459 | *body = xs_fmt(login_page, host, host, "LOGIN INCORRECT", proto, host, "oauth/x-snac-get-token", |
| 460 | "", "", "", USER_AGENT); | 460 | "", "", "", USER_AGENT); |
| 461 | *ctype = "text/html"; | 461 | *ctype = "text/html"; |
| 462 | status = 200; | 462 | status = HTTP_STATUS_OK; |
| 463 | 463 | ||
| 464 | if (login && passwd) { | 464 | if (login && passwd) { |
| 465 | snac user; | 465 | snac user; |
| @@ -1159,7 +1159,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1159 | if (!xs_startswith(q_path, "/api/v1/") && !xs_startswith(q_path, "/api/v2/")) | 1159 | if (!xs_startswith(q_path, "/api/v1/") && !xs_startswith(q_path, "/api/v2/")) |
| 1160 | return 0; | 1160 | return 0; |
| 1161 | 1161 | ||
| 1162 | int status = 404; | 1162 | int status = HTTP_STATUS_NOT_FOUND; |
| 1163 | const xs_dict *args = xs_dict_get(req, "q_vars"); | 1163 | const xs_dict *args = xs_dict_get(req, "q_vars"); |
| 1164 | xs *cmd = xs_replace_n(q_path, "/api", "", 1); | 1164 | xs *cmd = xs_replace_n(q_path, "/api", "", 1); |
| 1165 | 1165 | ||
| @@ -1249,10 +1249,10 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1249 | 1249 | ||
| 1250 | *body = xs_json_dumps(acct, 4); | 1250 | *body = xs_json_dumps(acct, 4); |
| 1251 | *ctype = "application/json"; | 1251 | *ctype = "application/json"; |
| 1252 | status = 200; | 1252 | status = HTTP_STATUS_OK; |
| 1253 | } | 1253 | } |
| 1254 | else { | 1254 | else { |
| 1255 | status = 422; // "Unprocessable entity" (no login) | 1255 | status = HTTP_STATUS_UNPROCESSABLE_CONTENT; // (no login) |
| 1256 | } | 1256 | } |
| 1257 | } | 1257 | } |
| 1258 | else | 1258 | else |
| @@ -1279,10 +1279,10 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1279 | 1279 | ||
| 1280 | *body = xs_json_dumps(res, 4); | 1280 | *body = xs_json_dumps(res, 4); |
| 1281 | *ctype = "application/json"; | 1281 | *ctype = "application/json"; |
| 1282 | status = 200; | 1282 | status = HTTP_STATUS_OK; |
| 1283 | } | 1283 | } |
| 1284 | else | 1284 | else |
| 1285 | status = 422; | 1285 | status = HTTP_STATUS_UNPROCESSABLE_CONTENT; |
| 1286 | } | 1286 | } |
| 1287 | else | 1287 | else |
| 1288 | if (strcmp(cmd, "/v1/accounts/lookup") == 0) { /** **/ | 1288 | if (strcmp(cmd, "/v1/accounts/lookup") == 0) { /** **/ |
| @@ -1304,7 +1304,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1304 | 1304 | ||
| 1305 | *body = xs_json_dumps(macct, 4); | 1305 | *body = xs_json_dumps(macct, 4); |
| 1306 | *ctype = "application/json"; | 1306 | *ctype = "application/json"; |
| 1307 | status = 200; | 1307 | status = HTTP_STATUS_OK; |
| 1308 | 1308 | ||
| 1309 | user_free(&user); | 1309 | user_free(&user); |
| 1310 | } | 1310 | } |
| @@ -1450,7 +1450,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1450 | if (out != NULL) { | 1450 | if (out != NULL) { |
| 1451 | *body = xs_json_dumps(out, 4); | 1451 | *body = xs_json_dumps(out, 4); |
| 1452 | *ctype = "application/json"; | 1452 | *ctype = "application/json"; |
| 1453 | status = 200; | 1453 | status = HTTP_STATUS_OK; |
| 1454 | } | 1454 | } |
| 1455 | } | 1455 | } |
| 1456 | } | 1456 | } |
| @@ -1554,12 +1554,12 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1554 | 1554 | ||
| 1555 | *body = xs_json_dumps(out, 4); | 1555 | *body = xs_json_dumps(out, 4); |
| 1556 | *ctype = "application/json"; | 1556 | *ctype = "application/json"; |
| 1557 | status = 200; | 1557 | status = HTTP_STATUS_OK; |
| 1558 | 1558 | ||
| 1559 | srv_debug(2, xs_fmt("mastoapi timeline: returned %d entries", xs_list_len(out))); | 1559 | srv_debug(2, xs_fmt("mastoapi timeline: returned %d entries", xs_list_len(out))); |
| 1560 | } | 1560 | } |
| 1561 | else { | 1561 | else { |
| 1562 | status = 401; // unauthorized | 1562 | status = HTTP_STATUS_UNAUTHORIZED; |
| 1563 | } | 1563 | } |
| 1564 | } | 1564 | } |
| 1565 | else | 1565 | else |
| @@ -1612,7 +1612,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1612 | 1612 | ||
| 1613 | *body = xs_json_dumps(out, 4); | 1613 | *body = xs_json_dumps(out, 4); |
| 1614 | *ctype = "application/json"; | 1614 | *ctype = "application/json"; |
| 1615 | status = 200; | 1615 | status = HTTP_STATUS_OK; |
| 1616 | } | 1616 | } |
| 1617 | else | 1617 | else |
| 1618 | if (xs_startswith(cmd, "/v1/timelines/tag/")) { /** **/ | 1618 | if (xs_startswith(cmd, "/v1/timelines/tag/")) { /** **/ |
| @@ -1661,7 +1661,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1661 | 1661 | ||
| 1662 | *body = xs_json_dumps(out, 4); | 1662 | *body = xs_json_dumps(out, 4); |
| 1663 | *ctype = "application/json"; | 1663 | *ctype = "application/json"; |
| 1664 | status = 200; | 1664 | status = HTTP_STATUS_OK; |
| 1665 | } | 1665 | } |
| 1666 | else | 1666 | else |
| 1667 | if (xs_startswith(cmd, "/v1/timelines/list/")) { /** **/ | 1667 | if (xs_startswith(cmd, "/v1/timelines/list/")) { /** **/ |
| @@ -1729,17 +1729,17 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1729 | 1729 | ||
| 1730 | *body = xs_json_dumps(out, 4); | 1730 | *body = xs_json_dumps(out, 4); |
| 1731 | *ctype = "application/json"; | 1731 | *ctype = "application/json"; |
| 1732 | status = 200; | 1732 | status = HTTP_STATUS_OK; |
| 1733 | } | 1733 | } |
| 1734 | else | 1734 | else |
| 1735 | status = 421; | 1735 | status = HTTP_STATUS_MISDIRECTED_REQUEST; |
| 1736 | } | 1736 | } |
| 1737 | else | 1737 | else |
| 1738 | if (strcmp(cmd, "/v1/conversations") == 0) { /** **/ | 1738 | if (strcmp(cmd, "/v1/conversations") == 0) { /** **/ |
| 1739 | /* TBD */ | 1739 | /* TBD */ |
| 1740 | *body = xs_dup("[]"); | 1740 | *body = xs_dup("[]"); |
| 1741 | *ctype = "application/json"; | 1741 | *ctype = "application/json"; |
| 1742 | status = 200; | 1742 | status = HTTP_STATUS_OK; |
| 1743 | } | 1743 | } |
| 1744 | else | 1744 | else |
| 1745 | if (strcmp(cmd, "/v1/notifications") == 0) { /** **/ | 1745 | if (strcmp(cmd, "/v1/notifications") == 0) { /** **/ |
| @@ -1817,17 +1817,17 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1817 | 1817 | ||
| 1818 | *body = xs_json_dumps(out, 4); | 1818 | *body = xs_json_dumps(out, 4); |
| 1819 | *ctype = "application/json"; | 1819 | *ctype = "application/json"; |
| 1820 | status = 200; | 1820 | status = HTTP_STATUS_OK; |
| 1821 | } | 1821 | } |
| 1822 | else | 1822 | else |
| 1823 | status = 401; | 1823 | status = HTTP_STATUS_UNAUTHORIZED; |
| 1824 | } | 1824 | } |
| 1825 | else | 1825 | else |
| 1826 | if (strcmp(cmd, "/v1/filters") == 0) { /** **/ | 1826 | if (strcmp(cmd, "/v1/filters") == 0) { /** **/ |
| 1827 | /* snac will never have filters */ | 1827 | /* snac will never have filters */ |
| 1828 | *body = xs_dup("[]"); | 1828 | *body = xs_dup("[]"); |
| 1829 | *ctype = "application/json"; | 1829 | *ctype = "application/json"; |
| 1830 | status = 200; | 1830 | status = HTTP_STATUS_OK; |
| 1831 | } | 1831 | } |
| 1832 | else | 1832 | else |
| 1833 | if (strcmp(cmd, "/v2/filters") == 0) { /** **/ | 1833 | if (strcmp(cmd, "/v2/filters") == 0) { /** **/ |
| @@ -1836,21 +1836,21 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1836 | * in some apps */ | 1836 | * in some apps */ |
| 1837 | *body = xs_dup("[]"); | 1837 | *body = xs_dup("[]"); |
| 1838 | *ctype = "application/json"; | 1838 | *ctype = "application/json"; |
| 1839 | status = 200; | 1839 | status = HTTP_STATUS_OK; |
| 1840 | } | 1840 | } |
| 1841 | else | 1841 | else |
| 1842 | if (strcmp(cmd, "/v1/favourites") == 0) { /** **/ | 1842 | if (strcmp(cmd, "/v1/favourites") == 0) { /** **/ |
| 1843 | /* snac will never support a list of favourites */ | 1843 | /* snac will never support a list of favourites */ |
| 1844 | *body = xs_dup("[]"); | 1844 | *body = xs_dup("[]"); |
| 1845 | *ctype = "application/json"; | 1845 | *ctype = "application/json"; |
| 1846 | status = 200; | 1846 | status = HTTP_STATUS_OK; |
| 1847 | } | 1847 | } |
| 1848 | else | 1848 | else |
| 1849 | if (strcmp(cmd, "/v1/bookmarks") == 0) { /** **/ | 1849 | if (strcmp(cmd, "/v1/bookmarks") == 0) { /** **/ |
| 1850 | /* snac does not support bookmarks */ | 1850 | /* snac does not support bookmarks */ |
| 1851 | *body = xs_dup("[]"); | 1851 | *body = xs_dup("[]"); |
| 1852 | *ctype = "application/json"; | 1852 | *ctype = "application/json"; |
| 1853 | status = 200; | 1853 | status = HTTP_STATUS_OK; |
| 1854 | } | 1854 | } |
| 1855 | else | 1855 | else |
| 1856 | if (strcmp(cmd, "/v1/lists") == 0) { /** list of lists **/ | 1856 | if (strcmp(cmd, "/v1/lists") == 0) { /** list of lists **/ |
| @@ -1873,7 +1873,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1873 | 1873 | ||
| 1874 | *body = xs_json_dumps(l, 4); | 1874 | *body = xs_json_dumps(l, 4); |
| 1875 | *ctype = "application/json"; | 1875 | *ctype = "application/json"; |
| 1876 | status = 200; | 1876 | status = HTTP_STATUS_OK; |
| 1877 | } | 1877 | } |
| 1878 | } | 1878 | } |
| 1879 | else | 1879 | else |
| @@ -1903,7 +1903,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1903 | 1903 | ||
| 1904 | *body = xs_json_dumps(out, 4); | 1904 | *body = xs_json_dumps(out, 4); |
| 1905 | *ctype = "application/json"; | 1905 | *ctype = "application/json"; |
| 1906 | status = 200; | 1906 | status = HTTP_STATUS_OK; |
| 1907 | } | 1907 | } |
| 1908 | } | 1908 | } |
| 1909 | else | 1909 | else |
| @@ -1931,7 +1931,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1931 | 1931 | ||
| 1932 | *body = xs_json_dumps(out, 4); | 1932 | *body = xs_json_dumps(out, 4); |
| 1933 | *ctype = "application/json"; | 1933 | *ctype = "application/json"; |
| 1934 | status = 200; | 1934 | status = HTTP_STATUS_OK; |
| 1935 | } | 1935 | } |
| 1936 | } | 1936 | } |
| 1937 | } | 1937 | } |
| @@ -1941,28 +1941,28 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1941 | /* snac does not schedule notes */ | 1941 | /* snac does not schedule notes */ |
| 1942 | *body = xs_dup("[]"); | 1942 | *body = xs_dup("[]"); |
| 1943 | *ctype = "application/json"; | 1943 | *ctype = "application/json"; |
| 1944 | status = 200; | 1944 | status = HTTP_STATUS_OK; |
| 1945 | } | 1945 | } |
| 1946 | else | 1946 | else |
| 1947 | if (strcmp(cmd, "/v1/follow_requests") == 0) { /** **/ | 1947 | if (strcmp(cmd, "/v1/follow_requests") == 0) { /** **/ |
| 1948 | /* snac does not support optional follow confirmations */ | 1948 | /* snac does not support optional follow confirmations */ |
| 1949 | *body = xs_dup("[]"); | 1949 | *body = xs_dup("[]"); |
| 1950 | *ctype = "application/json"; | 1950 | *ctype = "application/json"; |
| 1951 | status = 200; | 1951 | status = HTTP_STATUS_OK; |
| 1952 | } | 1952 | } |
| 1953 | else | 1953 | else |
| 1954 | if (strcmp(cmd, "/v1/announcements") == 0) { /** **/ | 1954 | if (strcmp(cmd, "/v1/announcements") == 0) { /** **/ |
| 1955 | /* snac has no announcements (yet?) */ | 1955 | /* snac has no announcements (yet?) */ |
| 1956 | *body = xs_dup("[]"); | 1956 | *body = xs_dup("[]"); |
| 1957 | *ctype = "application/json"; | 1957 | *ctype = "application/json"; |
| 1958 | status = 200; | 1958 | status = HTTP_STATUS_OK; |
| 1959 | } | 1959 | } |
| 1960 | else | 1960 | else |
| 1961 | if (strcmp(cmd, "/v1/custom_emojis") == 0) { /** **/ | 1961 | if (strcmp(cmd, "/v1/custom_emojis") == 0) { /** **/ |
| 1962 | /* are you kidding me? */ | 1962 | /* are you kidding me? */ |
| 1963 | *body = xs_dup("[]"); | 1963 | *body = xs_dup("[]"); |
| 1964 | *ctype = "application/json"; | 1964 | *ctype = "application/json"; |
| 1965 | status = 200; | 1965 | status = HTTP_STATUS_OK; |
| 1966 | } | 1966 | } |
| 1967 | else | 1967 | else |
| 1968 | if (strcmp(cmd, "/v1/instance") == 0) { /** **/ | 1968 | if (strcmp(cmd, "/v1/instance") == 0) { /** **/ |
| @@ -2075,7 +2075,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 2075 | 2075 | ||
| 2076 | *body = xs_json_dumps(ins, 4); | 2076 | *body = xs_json_dumps(ins, 4); |
| 2077 | *ctype = "application/json"; | 2077 | *ctype = "application/json"; |
| 2078 | status = 200; | 2078 | status = HTTP_STATUS_OK; |
| 2079 | } | 2079 | } |
| 2080 | else | 2080 | else |
| 2081 | if (xs_startswith(cmd, "/v1/statuses/")) { /** **/ | 2081 | if (xs_startswith(cmd, "/v1/statuses/")) { /** **/ |
| @@ -2188,30 +2188,30 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 2188 | if (out != NULL) { | 2188 | if (out != NULL) { |
| 2189 | *body = xs_json_dumps(out, 4); | 2189 | *body = xs_json_dumps(out, 4); |
| 2190 | *ctype = "application/json"; | 2190 | *ctype = "application/json"; |
| 2191 | status = 200; | 2191 | status = HTTP_STATUS_OK; |
| 2192 | } | 2192 | } |
| 2193 | } | 2193 | } |
| 2194 | } | 2194 | } |
| 2195 | else | 2195 | else |
| 2196 | status = 401; | 2196 | status = HTTP_STATUS_UNAUTHORIZED; |
| 2197 | } | 2197 | } |
| 2198 | else | 2198 | else |
| 2199 | if (strcmp(cmd, "/v1/preferences") == 0) { /** **/ | 2199 | if (strcmp(cmd, "/v1/preferences") == 0) { /** **/ |
| 2200 | *body = xs_dup("{}"); | 2200 | *body = xs_dup("{}"); |
| 2201 | *ctype = "application/json"; | 2201 | *ctype = "application/json"; |
| 2202 | status = 200; | 2202 | status = HTTP_STATUS_OK; |
| 2203 | } | 2203 | } |
| 2204 | else | 2204 | else |
| 2205 | if (strcmp(cmd, "/v1/markers") == 0) { /** **/ | 2205 | if (strcmp(cmd, "/v1/markers") == 0) { /** **/ |
| 2206 | *body = xs_dup("{}"); | 2206 | *body = xs_dup("{}"); |
| 2207 | *ctype = "application/json"; | 2207 | *ctype = "application/json"; |
| 2208 | status = 200; | 2208 | status = HTTP_STATUS_OK; |
| 2209 | } | 2209 | } |
| 2210 | else | 2210 | else |
| 2211 | if (strcmp(cmd, "/v1/followed_tags") == 0) { /** **/ | 2211 | if (strcmp(cmd, "/v1/followed_tags") == 0) { /** **/ |
| 2212 | *body = xs_dup("[]"); | 2212 | *body = xs_dup("[]"); |
| 2213 | *ctype = "application/json"; | 2213 | *ctype = "application/json"; |
| 2214 | status = 200; | 2214 | status = HTTP_STATUS_OK; |
| 2215 | } | 2215 | } |
| 2216 | else | 2216 | else |
| 2217 | if (strcmp(cmd, "/v2/search") == 0) { /** **/ | 2217 | if (strcmp(cmd, "/v2/search") == 0) { /** **/ |
| @@ -2290,10 +2290,10 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 2290 | 2290 | ||
| 2291 | *body = xs_json_dumps(res, 4); | 2291 | *body = xs_json_dumps(res, 4); |
| 2292 | *ctype = "application/json"; | 2292 | *ctype = "application/json"; |
| 2293 | status = 200; | 2293 | status = HTTP_STATUS_OK; |
| 2294 | } | 2294 | } |
| 2295 | else | 2295 | else |
| 2296 | status = 401; | 2296 | status = HTTP_STATUS_UNAUTHORIZED; |
| 2297 | } | 2297 | } |
| 2298 | 2298 | ||
| 2299 | /* user cleanup */ | 2299 | /* user cleanup */ |
| @@ -2316,7 +2316,7 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path, | |||
| 2316 | if (!xs_startswith(q_path, "/api/v1/") && !xs_startswith(q_path, "/api/v2/")) | 2316 | if (!xs_startswith(q_path, "/api/v1/") && !xs_startswith(q_path, "/api/v2/")) |
| 2317 | return 0; | 2317 | return 0; |
| 2318 | 2318 | ||
| 2319 | int status = 404; | 2319 | int status = HTTP_STATUS_NOT_FOUND; |
| 2320 | xs *args = NULL; | 2320 | xs *args = NULL; |
| 2321 | const char *i_ctype = xs_dict_get(req, "content-type"); | 2321 | const char *i_ctype = xs_dict_get(req, "content-type"); |
| 2322 | 2322 | ||
| @@ -2336,7 +2336,7 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path, | |||
| 2336 | args = xs_dup(xs_dict_get(req, "p_vars")); | 2336 | args = xs_dup(xs_dict_get(req, "p_vars")); |
| 2337 | 2337 | ||
| 2338 | if (args == NULL) | 2338 | if (args == NULL) |
| 2339 | return 400; | 2339 | return HTTP_STATUS_BAD_REQUEST; |
| 2340 | 2340 | ||
| 2341 | xs *cmd = xs_replace_n(q_path, "/api", "", 1); | 2341 | xs *cmd = xs_replace_n(q_path, "/api", "", 1); |
| 2342 | 2342 | ||
| @@ -2378,7 +2378,7 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path, | |||
| 2378 | 2378 | ||
| 2379 | *body = xs_json_dumps(app, 4); | 2379 | *body = xs_json_dumps(app, 4); |
| 2380 | *ctype = "application/json"; | 2380 | *ctype = "application/json"; |
| 2381 | status = 200; | 2381 | status = HTTP_STATUS_OK; |
| 2382 | 2382 | ||
| 2383 | app = xs_dict_append(app, "code", ""); | 2383 | app = xs_dict_append(app, "code", ""); |
| 2384 | 2384 | ||
| @@ -2470,10 +2470,10 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path, | |||
| 2470 | 2470 | ||
| 2471 | *body = xs_json_dumps(st, 4); | 2471 | *body = xs_json_dumps(st, 4); |
| 2472 | *ctype = "application/json"; | 2472 | *ctype = "application/json"; |
| 2473 | status = 200; | 2473 | status = HTTP_STATUS_OK; |
| 2474 | } | 2474 | } |
| 2475 | else | 2475 | else |
| 2476 | status = 401; | 2476 | status = HTTP_STATUS_UNAUTHORIZED; |
| 2477 | } | 2477 | } |
| 2478 | else | 2478 | else |
| 2479 | if (xs_startswith(cmd, "/v1/statuses")) { /** **/ | 2479 | if (xs_startswith(cmd, "/v1/statuses")) { /** **/ |
| @@ -2552,7 +2552,7 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path, | |||
| 2552 | if (pin(&snac, id)) | 2552 | if (pin(&snac, id)) |
| 2553 | out = mastoapi_status(&snac, msg); | 2553 | out = mastoapi_status(&snac, msg); |
| 2554 | else | 2554 | else |
| 2555 | status = 422; | 2555 | status = HTTP_STATUS_UNPROCESSABLE_CONTENT; |
| 2556 | } | 2556 | } |
| 2557 | else | 2557 | else |
| 2558 | if (strcmp(op, "unpin") == 0) { /** **/ | 2558 | if (strcmp(op, "unpin") == 0) { /** **/ |
| @@ -2573,12 +2573,12 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path, | |||
| 2573 | if (out != NULL) { | 2573 | if (out != NULL) { |
| 2574 | *body = xs_json_dumps(out, 4); | 2574 | *body = xs_json_dumps(out, 4); |
| 2575 | *ctype = "application/json"; | 2575 | *ctype = "application/json"; |
| 2576 | status = 200; | 2576 | status = HTTP_STATUS_OK; |
| 2577 | } | 2577 | } |
| 2578 | } | 2578 | } |
| 2579 | } | 2579 | } |
| 2580 | else | 2580 | else |
| 2581 | status = 401; | 2581 | status = HTTP_STATUS_UNAUTHORIZED; |
| 2582 | } | 2582 | } |
| 2583 | else | 2583 | else |
| 2584 | if (strcmp(cmd, "/v1/notifications/clear") == 0) { /** **/ | 2584 | if (strcmp(cmd, "/v1/notifications/clear") == 0) { /** **/ |
| @@ -2588,10 +2588,10 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path, | |||
| 2588 | 2588 | ||
| 2589 | *body = xs_dup("{}"); | 2589 | *body = xs_dup("{}"); |
| 2590 | *ctype = "application/json"; | 2590 | *ctype = "application/json"; |
| 2591 | status = 200; | 2591 | status = HTTP_STATUS_OK; |
| 2592 | } | 2592 | } |
| 2593 | else | 2593 | else |
| 2594 | status = 401; | 2594 | status = HTTP_STATUS_UNAUTHORIZED; |
| 2595 | } | 2595 | } |
| 2596 | else | 2596 | else |
| 2597 | if (strcmp(cmd, "/v1/push/subscription") == 0) { /** **/ | 2597 | if (strcmp(cmd, "/v1/push/subscription") == 0) { /** **/ |
| @@ -2616,10 +2616,10 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path, | |||
| 2616 | 2616 | ||
| 2617 | *body = xs_json_dumps(wpush, 4); | 2617 | *body = xs_json_dumps(wpush, 4); |
| 2618 | *ctype = "application/json"; | 2618 | *ctype = "application/json"; |
| 2619 | status = 200; | 2619 | status = HTTP_STATUS_OK; |
| 2620 | } | 2620 | } |
| 2621 | else | 2621 | else |
| 2622 | status = 401; | 2622 | status = HTTP_STATUS_UNAUTHORIZED; |
| 2623 | } | 2623 | } |
| 2624 | else | 2624 | else |
| 2625 | if (strcmp(cmd, "/v1/media") == 0 || strcmp(cmd, "/v2/media") == 0) { /** **/ | 2625 | if (strcmp(cmd, "/v1/media") == 0 || strcmp(cmd, "/v2/media") == 0) { /** **/ |
| @@ -2630,7 +2630,7 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path, | |||
| 2630 | if (xs_is_null(desc)) | 2630 | if (xs_is_null(desc)) |
| 2631 | desc = ""; | 2631 | desc = ""; |
| 2632 | 2632 | ||
| 2633 | status = 400; | 2633 | status = HTTP_STATUS_BAD_REQUEST; |
| 2634 | 2634 | ||
| 2635 | if (xs_type(file) == XSTYPE_LIST) { | 2635 | if (xs_type(file) == XSTYPE_LIST) { |
| 2636 | const char *fn = xs_list_get(file, 0); | 2636 | const char *fn = xs_list_get(file, 0); |
| @@ -2659,12 +2659,12 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path, | |||
| 2659 | 2659 | ||
| 2660 | *body = xs_json_dumps(rsp, 4); | 2660 | *body = xs_json_dumps(rsp, 4); |
| 2661 | *ctype = "application/json"; | 2661 | *ctype = "application/json"; |
| 2662 | status = 200; | 2662 | status = HTTP_STATUS_OK; |
| 2663 | } | 2663 | } |
| 2664 | } | 2664 | } |
| 2665 | } | 2665 | } |
| 2666 | else | 2666 | else |
| 2667 | status = 401; | 2667 | status = HTTP_STATUS_UNAUTHORIZED; |
| 2668 | } | 2668 | } |
| 2669 | else | 2669 | else |
| 2670 | if (xs_startswith(cmd, "/v1/accounts")) { /** **/ | 2670 | if (xs_startswith(cmd, "/v1/accounts")) { /** **/ |
| @@ -2744,11 +2744,11 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path, | |||
| 2744 | if (rsp != NULL) { | 2744 | if (rsp != NULL) { |
| 2745 | *body = xs_json_dumps(rsp, 4); | 2745 | *body = xs_json_dumps(rsp, 4); |
| 2746 | *ctype = "application/json"; | 2746 | *ctype = "application/json"; |
| 2747 | status = 200; | 2747 | status = HTTP_STATUS_OK; |
| 2748 | } | 2748 | } |
| 2749 | } | 2749 | } |
| 2750 | else | 2750 | else |
| 2751 | status = 401; | 2751 | status = HTTP_STATUS_UNAUTHORIZED; |
| 2752 | } | 2752 | } |
| 2753 | else | 2753 | else |
| 2754 | if (xs_startswith(cmd, "/v1/polls")) { /** **/ | 2754 | if (xs_startswith(cmd, "/v1/polls")) { /** **/ |
| @@ -2810,12 +2810,12 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path, | |||
| 2810 | if (out != NULL) { | 2810 | if (out != NULL) { |
| 2811 | *body = xs_json_dumps(out, 4); | 2811 | *body = xs_json_dumps(out, 4); |
| 2812 | *ctype = "application/json"; | 2812 | *ctype = "application/json"; |
| 2813 | status = 200; | 2813 | status = HTTP_STATUS_OK; |
| 2814 | } | 2814 | } |
| 2815 | } | 2815 | } |
| 2816 | } | 2816 | } |
| 2817 | else | 2817 | else |
| 2818 | status = 401; | 2818 | status = HTTP_STATUS_UNAUTHORIZED; |
| 2819 | } | 2819 | } |
| 2820 | else | 2820 | else |
| 2821 | if (strcmp(cmd, "/v1/lists") == 0) { | 2821 | if (strcmp(cmd, "/v1/lists") == 0) { |
| @@ -2831,18 +2831,18 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path, | |||
| 2831 | out = xs_dict_append(out, "replies_policy", xs_dict_get_def(args, "replies_policy", "list")); | 2831 | out = xs_dict_append(out, "replies_policy", xs_dict_get_def(args, "replies_policy", "list")); |
| 2832 | out = xs_dict_append(out, "exclusive", xs_stock(XSTYPE_FALSE)); | 2832 | out = xs_dict_append(out, "exclusive", xs_stock(XSTYPE_FALSE)); |
| 2833 | 2833 | ||
| 2834 | status = 200; | 2834 | status = HTTP_STATUS_OK; |
| 2835 | } | 2835 | } |
| 2836 | else { | 2836 | else { |
| 2837 | out = xs_dict_append(out, "error", "cannot create list"); | 2837 | out = xs_dict_append(out, "error", "cannot create list"); |
| 2838 | status = 422; | 2838 | status = HTTP_STATUS_UNPROCESSABLE_CONTENT; |
| 2839 | } | 2839 | } |
| 2840 | 2840 | ||
| 2841 | *body = xs_json_dumps(out, 4); | 2841 | *body = xs_json_dumps(out, 4); |
| 2842 | *ctype = "application/json"; | 2842 | *ctype = "application/json"; |
| 2843 | } | 2843 | } |
| 2844 | else | 2844 | else |
| 2845 | status = 422; | 2845 | status = HTTP_STATUS_UNPROCESSABLE_CONTENT; |
| 2846 | } | 2846 | } |
| 2847 | } | 2847 | } |
| 2848 | if (xs_startswith(cmd, "/v1/lists/")) { /** list maintenance **/ | 2848 | if (xs_startswith(cmd, "/v1/lists/")) { /** list maintenance **/ |
| @@ -2861,12 +2861,12 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path, | |||
| 2861 | list_content(&snac, id, v, 1); | 2861 | list_content(&snac, id, v, 1); |
| 2862 | } | 2862 | } |
| 2863 | 2863 | ||
| 2864 | status = 200; | 2864 | status = HTTP_STATUS_OK; |
| 2865 | } | 2865 | } |
| 2866 | } | 2866 | } |
| 2867 | } | 2867 | } |
| 2868 | else | 2868 | else |
| 2869 | status = 422; | 2869 | status = HTTP_STATUS_UNPROCESSABLE_CONTENT; |
| 2870 | } | 2870 | } |
| 2871 | 2871 | ||
| 2872 | /* user cleanup */ | 2872 | /* user cleanup */ |
| @@ -2891,7 +2891,7 @@ int mastoapi_delete_handler(const xs_dict *req, const char *q_path, | |||
| 2891 | if (!xs_startswith(q_path, "/api/v1/") && !xs_startswith(q_path, "/api/v2/")) | 2891 | if (!xs_startswith(q_path, "/api/v1/") && !xs_startswith(q_path, "/api/v2/")) |
| 2892 | return 0; | 2892 | return 0; |
| 2893 | 2893 | ||
| 2894 | int status = 404; | 2894 | int status = HTTP_STATUS_NOT_FOUND; |
| 2895 | xs *args = NULL; | 2895 | xs *args = NULL; |
| 2896 | const char *i_ctype = xs_dict_get(req, "content-type"); | 2896 | const char *i_ctype = xs_dict_get(req, "content-type"); |
| 2897 | 2897 | ||
| @@ -2911,7 +2911,7 @@ int mastoapi_delete_handler(const xs_dict *req, const char *q_path, | |||
| 2911 | args = xs_dup(xs_dict_get(req, "p_vars")); | 2911 | args = xs_dup(xs_dict_get(req, "p_vars")); |
| 2912 | 2912 | ||
| 2913 | if (args == NULL) | 2913 | if (args == NULL) |
| 2914 | return 400; | 2914 | return HTTP_STATUS_BAD_REQUEST; |
| 2915 | 2915 | ||
| 2916 | snac snac = {0}; | 2916 | snac snac = {0}; |
| 2917 | int logged_in = process_auth_token(&snac, req); | 2917 | int logged_in = process_auth_token(&snac, req); |
| @@ -2920,7 +2920,7 @@ int mastoapi_delete_handler(const xs_dict *req, const char *q_path, | |||
| 2920 | 2920 | ||
| 2921 | if (xs_startswith(cmd, "/v1/push/subscription") || xs_startswith(cmd, "/v2/push/subscription")) { /** **/ | 2921 | if (xs_startswith(cmd, "/v1/push/subscription") || xs_startswith(cmd, "/v2/push/subscription")) { /** **/ |
| 2922 | // pretend we deleted it, since it doesn't exist anyway | 2922 | // pretend we deleted it, since it doesn't exist anyway |
| 2923 | status = 200; | 2923 | status = HTTP_STATUS_OK; |
| 2924 | } | 2924 | } |
| 2925 | else | 2925 | else |
| 2926 | if (xs_startswith(cmd, "/v1/lists/")) { | 2926 | if (xs_startswith(cmd, "/v1/lists/")) { |
| @@ -2948,10 +2948,10 @@ int mastoapi_delete_handler(const xs_dict *req, const char *q_path, | |||
| 2948 | } | 2948 | } |
| 2949 | } | 2949 | } |
| 2950 | 2950 | ||
| 2951 | status = 200; | 2951 | status = HTTP_STATUS_OK; |
| 2952 | } | 2952 | } |
| 2953 | else | 2953 | else |
| 2954 | status = 401; | 2954 | status = HTTP_STATUS_UNAUTHORIZED; |
| 2955 | } | 2955 | } |
| 2956 | 2956 | ||
| 2957 | /* user cleanup */ | 2957 | /* user cleanup */ |
| @@ -2974,7 +2974,7 @@ int mastoapi_put_handler(const xs_dict *req, const char *q_path, | |||
| 2974 | if (!xs_startswith(q_path, "/api/v1/") && !xs_startswith(q_path, "/api/v2/")) | 2974 | if (!xs_startswith(q_path, "/api/v1/") && !xs_startswith(q_path, "/api/v2/")) |
| 2975 | return 0; | 2975 | return 0; |
| 2976 | 2976 | ||
| 2977 | int status = 404; | 2977 | int status = HTTP_STATUS_NOT_FOUND; |
| 2978 | xs *args = NULL; | 2978 | xs *args = NULL; |
| 2979 | const char *i_ctype = xs_dict_get(req, "content-type"); | 2979 | const char *i_ctype = xs_dict_get(req, "content-type"); |
| 2980 | 2980 | ||
| @@ -2986,7 +2986,7 @@ int mastoapi_put_handler(const xs_dict *req, const char *q_path, | |||
| 2986 | args = xs_dup(xs_dict_get(req, "p_vars")); | 2986 | args = xs_dup(xs_dict_get(req, "p_vars")); |
| 2987 | 2987 | ||
| 2988 | if (args == NULL) | 2988 | if (args == NULL) |
| 2989 | return 400; | 2989 | return HTTP_STATUS_BAD_REQUEST; |
| 2990 | 2990 | ||
| 2991 | xs *cmd = xs_replace_n(q_path, "/api", "", 1); | 2991 | xs *cmd = xs_replace_n(q_path, "/api", "", 1); |
| 2992 | 2992 | ||
| @@ -3017,11 +3017,11 @@ int mastoapi_put_handler(const xs_dict *req, const char *q_path, | |||
| 3017 | 3017 | ||
| 3018 | *body = xs_json_dumps(rsp, 4); | 3018 | *body = xs_json_dumps(rsp, 4); |
| 3019 | *ctype = "application/json"; | 3019 | *ctype = "application/json"; |
| 3020 | status = 200; | 3020 | status = HTTP_STATUS_OK; |
| 3021 | } | 3021 | } |
| 3022 | } | 3022 | } |
| 3023 | else | 3023 | else |
| 3024 | status = 401; | 3024 | status = HTTP_STATUS_UNAUTHORIZED; |
| 3025 | } | 3025 | } |
| 3026 | else | 3026 | else |
| 3027 | if (xs_startswith(cmd, "/v1/statuses")) { | 3027 | if (xs_startswith(cmd, "/v1/statuses")) { |
| @@ -3060,12 +3060,12 @@ int mastoapi_put_handler(const xs_dict *req, const char *q_path, | |||
| 3060 | if (rsp != NULL) { | 3060 | if (rsp != NULL) { |
| 3061 | *body = xs_json_dumps(rsp, 4); | 3061 | *body = xs_json_dumps(rsp, 4); |
| 3062 | *ctype = "application/json"; | 3062 | *ctype = "application/json"; |
| 3063 | status = 200; | 3063 | status = HTTP_STATUS_OK; |
| 3064 | } | 3064 | } |
| 3065 | } | 3065 | } |
| 3066 | } | 3066 | } |
| 3067 | else | 3067 | else |
| 3068 | status = 401; | 3068 | status = HTTP_STATUS_UNAUTHORIZED; |
| 3069 | } | 3069 | } |
| 3070 | 3070 | ||
| 3071 | /* user cleanup */ | 3071 | /* user cleanup */ |