diff options
| -rw-r--r-- | mastoapi.c | 27 |
1 files changed, 14 insertions, 13 deletions
| @@ -178,7 +178,7 @@ int oauth_get_handler(const xs_dict *req, const char *q_path, | |||
| 178 | xs_dict *msg = xs_dict_get(req, "q_vars"); | 178 | xs_dict *msg = xs_dict_get(req, "q_vars"); |
| 179 | xs *cmd = xs_replace(q_path, "/oauth", ""); | 179 | xs *cmd = xs_replace(q_path, "/oauth", ""); |
| 180 | 180 | ||
| 181 | srv_debug(0, xs_fmt("oauth_get_handler %s", q_path)); | 181 | srv_debug(1, xs_fmt("oauth_get_handler %s", q_path)); |
| 182 | 182 | ||
| 183 | if (strcmp(cmd, "/authorize") == 0) { | 183 | if (strcmp(cmd, "/authorize") == 0) { |
| 184 | const char *cid = xs_dict_get(msg, "client_id"); | 184 | const char *cid = xs_dict_get(msg, "client_id"); |
| @@ -230,7 +230,7 @@ int oauth_post_handler(const xs_dict *req, const char *q_path, | |||
| 230 | xs_dict *msg = xs_dict_get(req, "p_vars"); | 230 | xs_dict *msg = xs_dict_get(req, "p_vars"); |
| 231 | xs *cmd = xs_replace(q_path, "/oauth", ""); | 231 | xs *cmd = xs_replace(q_path, "/oauth", ""); |
| 232 | 232 | ||
| 233 | srv_debug(0, xs_fmt("oauth_post_handler %s", q_path)); | 233 | srv_debug(1, xs_fmt("oauth_post_handler %s", q_path)); |
| 234 | 234 | ||
| 235 | if (strcmp(cmd, "/x-snac-login") == 0) { | 235 | if (strcmp(cmd, "/x-snac-login") == 0) { |
| 236 | const char *login = xs_dict_get(msg, "login"); | 236 | const char *login = xs_dict_get(msg, "login"); |
| @@ -266,7 +266,8 @@ int oauth_post_handler(const xs_dict *req, const char *q_path, | |||
| 266 | *body = xs_str_cat(*body, state); | 266 | *body = xs_str_cat(*body, state); |
| 267 | } | 267 | } |
| 268 | 268 | ||
| 269 | srv_debug(0, xs_fmt("oauth x-snac-login: success, redirect to %s", *body)); | 269 | srv_log(xs_fmt("oauth x-snac-login: '%s' success, redirect to %s", |
| 270 | login, *body)); | ||
| 270 | 271 | ||
| 271 | /* assign the login to the app */ | 272 | /* assign the login to the app */ |
| 272 | xs *app = app_get(cid); | 273 | xs *app = app_get(cid); |
| @@ -280,15 +281,15 @@ int oauth_post_handler(const xs_dict *req, const char *q_path, | |||
| 280 | srv_log(xs_fmt("oauth x-snac-login: error getting app %s", cid)); | 281 | srv_log(xs_fmt("oauth x-snac-login: error getting app %s", cid)); |
| 281 | } | 282 | } |
| 282 | else | 283 | else |
| 283 | srv_debug(0, xs_fmt("oauth x-snac-login: login '%s' incorrect", login)); | 284 | srv_debug(1, xs_fmt("oauth x-snac-login: login '%s' incorrect", login)); |
| 284 | 285 | ||
| 285 | user_free(&snac); | 286 | user_free(&snac); |
| 286 | } | 287 | } |
| 287 | else | 288 | else |
| 288 | srv_debug(0, xs_fmt("oauth x-snac-login: bad user '%s'", login)); | 289 | srv_debug(1, xs_fmt("oauth x-snac-login: bad user '%s'", login)); |
| 289 | } | 290 | } |
| 290 | else | 291 | else |
| 291 | srv_debug(0, xs_fmt("oauth x-snac-login: invalid or unset arguments")); | 292 | srv_debug(1, xs_fmt("oauth x-snac-login: invalid or unset arguments")); |
| 292 | } | 293 | } |
| 293 | else | 294 | else |
| 294 | if (strcmp(cmd, "/token") == 0) { | 295 | if (strcmp(cmd, "/token") == 0) { |
| @@ -378,7 +379,7 @@ int oauth_post_handler(const xs_dict *req, const char *q_path, | |||
| 378 | *ctype = "application/json"; | 379 | *ctype = "application/json"; |
| 379 | 380 | ||
| 380 | if (token == NULL || strcmp(csec, xs_dict_get(token, "client_secret")) != 0) { | 381 | if (token == NULL || strcmp(csec, xs_dict_get(token, "client_secret")) != 0) { |
| 381 | srv_debug(0, xs_fmt("oauth revoke: bad secret for token %s", tokid)); | 382 | srv_debug(1, xs_fmt("oauth revoke: bad secret for token %s", tokid)); |
| 382 | status = 403; | 383 | status = 403; |
| 383 | } | 384 | } |
| 384 | else { | 385 | else { |
| @@ -614,7 +615,7 @@ int process_auth_token(snac *snac, const xs_dict *req) | |||
| 614 | 615 | ||
| 615 | if (!xs_is_null(uid) && user_open(snac, uid)) { | 616 | if (!xs_is_null(uid) && user_open(snac, uid)) { |
| 616 | logged_in = 1; | 617 | logged_in = 1; |
| 617 | srv_debug(0, xs_fmt("mastoapi auth: valid token for user %s", uid)); | 618 | srv_debug(1, xs_fmt("mastoapi auth: valid token for user %s", uid)); |
| 618 | } | 619 | } |
| 619 | else | 620 | else |
| 620 | srv_log(xs_fmt("mastoapi auth: corrupted token %s", tokid)); | 621 | srv_log(xs_fmt("mastoapi auth: corrupted token %s", tokid)); |
| @@ -633,7 +634,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 633 | if (!xs_startswith(q_path, "/api/v1/")) | 634 | if (!xs_startswith(q_path, "/api/v1/")) |
| 634 | return 0; | 635 | return 0; |
| 635 | 636 | ||
| 636 | srv_debug(0, xs_fmt("mastoapi_get_handler %s", q_path)); | 637 | srv_debug(1, xs_fmt("mastoapi_get_handler %s", q_path)); |
| 637 | /* { | 638 | /* { |
| 638 | xs *j = xs_json_dumps_pp(req, 4); | 639 | xs *j = xs_json_dumps_pp(req, 4); |
| 639 | printf("mastoapi get:\n%s\n", j); | 640 | printf("mastoapi get:\n%s\n", j); |
| @@ -825,12 +826,12 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 825 | { | 826 | { |
| 826 | xs *j = xs_json_loads(*body); | 827 | xs *j = xs_json_loads(*body); |
| 827 | if (j == NULL) { | 828 | if (j == NULL) { |
| 828 | srv_debug(0, xs_fmt("mastoapi timeline: bad JSON")); | 829 | srv_log(xs_fmt("mastoapi timeline: bad JSON")); |
| 829 | srv_archive_error("mastoapi_timeline", "bad JSON", req, *body); | 830 | srv_archive_error("mastoapi_timeline", "bad JSON", req, *body); |
| 830 | } | 831 | } |
| 831 | } | 832 | } |
| 832 | 833 | ||
| 833 | srv_debug(0, xs_fmt("mastoapi timeline: returned %d entries", xs_list_len(out))); | 834 | srv_debug(2, xs_fmt("mastoapi timeline: returned %d entries", xs_list_len(out))); |
| 834 | } | 835 | } |
| 835 | else { | 836 | else { |
| 836 | status = 401; // unauthorized | 837 | status = 401; // unauthorized |
| @@ -1030,7 +1031,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1030 | } | 1031 | } |
| 1031 | } | 1032 | } |
| 1032 | else | 1033 | else |
| 1033 | srv_debug(0, xs_fmt("mastoapi status: bad id %s", id)); | 1034 | srv_debug(1, xs_fmt("mastoapi status: bad id %s", id)); |
| 1034 | 1035 | ||
| 1035 | if (out != NULL) { | 1036 | if (out != NULL) { |
| 1036 | *body = xs_json_dumps_pp(out, 4); | 1037 | *body = xs_json_dumps_pp(out, 4); |
| @@ -1061,7 +1062,7 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path, | |||
| 1061 | if (!xs_startswith(q_path, "/api/v1/")) | 1062 | if (!xs_startswith(q_path, "/api/v1/")) |
| 1062 | return 0; | 1063 | return 0; |
| 1063 | 1064 | ||
| 1064 | srv_debug(0, xs_fmt("mastoapi_post_handler %s", q_path)); | 1065 | srv_debug(1, xs_fmt("mastoapi_post_handler %s", q_path)); |
| 1065 | /* { | 1066 | /* { |
| 1066 | xs *j = xs_json_dumps_pp(req, 4); | 1067 | xs *j = xs_json_dumps_pp(req, 4); |
| 1067 | printf("mastoapi post:\n%s\n", j); | 1068 | printf("mastoapi post:\n%s\n", j); |