diff options
| -rw-r--r-- | mastoapi.c | 11 | ||||
| -rw-r--r-- | xs.h | 15 |
2 files changed, 23 insertions, 3 deletions
| @@ -1134,6 +1134,9 @@ xs_dict *mastoapi_status(snac *snac, const xs_dict *msg) | |||
| 1134 | bst = xs_dict_set(bst, "content", ""); | 1134 | bst = xs_dict_set(bst, "content", ""); |
| 1135 | bst = xs_dict_set(bst, "reblog", st); | 1135 | bst = xs_dict_set(bst, "reblog", st); |
| 1136 | 1136 | ||
| 1137 | xs *b_id = xs_toupper_i(xs_dup(xs_dict_get(st, "id"))); | ||
| 1138 | bst = xs_dict_set(bst, "id", b_id); | ||
| 1139 | |||
| 1137 | xs_free(st); | 1140 | xs_free(st); |
| 1138 | st = bst; | 1141 | st = bst; |
| 1139 | } | 1142 | } |
| @@ -2338,15 +2341,17 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 2338 | /* information about a status */ | 2341 | /* information about a status */ |
| 2339 | if (logged_in) { | 2342 | if (logged_in) { |
| 2340 | xs *l = xs_split(cmd, "/"); | 2343 | xs *l = xs_split(cmd, "/"); |
| 2341 | const char *id = xs_list_get(l, 3); | 2344 | const char *oid = xs_list_get(l, 3); |
| 2342 | const char *op = xs_list_get(l, 4); | 2345 | const char *op = xs_list_get(l, 4); |
| 2343 | 2346 | ||
| 2344 | if (!xs_is_null(id)) { | 2347 | if (!xs_is_null(oid)) { |
| 2345 | xs *msg = NULL; | 2348 | xs *msg = NULL; |
| 2346 | xs *out = NULL; | 2349 | xs *out = NULL; |
| 2347 | 2350 | ||
| 2348 | /* skip the 'fake' part of the id */ | 2351 | /* skip the 'fake' part of the id */ |
| 2349 | id = MID_TO_MD5(id); | 2352 | oid = MID_TO_MD5(oid); |
| 2353 | |||
| 2354 | xs *id = xs_tolower_i(xs_dup(oid)); | ||
| 2350 | 2355 | ||
| 2351 | if (valid_status(object_get_by_md5(id, &msg))) { | 2356 | if (valid_status(object_get_by_md5(id, &msg))) { |
| 2352 | if (op == NULL) { | 2357 | if (op == NULL) { |
| @@ -90,6 +90,7 @@ xs_str *xs_rstrip_chars_i(xs_str *str, const char *chars); | |||
| 90 | xs_str *xs_strip_chars_i(xs_str *str, const char *chars); | 90 | xs_str *xs_strip_chars_i(xs_str *str, const char *chars); |
| 91 | #define xs_strip_i(str) xs_strip_chars_i(str, " \r\n\t\v\f") | 91 | #define xs_strip_i(str) xs_strip_chars_i(str, " \r\n\t\v\f") |
| 92 | xs_str *xs_tolower_i(xs_str *str); | 92 | xs_str *xs_tolower_i(xs_str *str); |
| 93 | xs_str *xs_toupper_i(xs_str *str); | ||
| 93 | 94 | ||
| 94 | xs_list *xs_list_new(void); | 95 | xs_list *xs_list_new(void); |
| 95 | xs_list *xs_list_append_m(xs_list *list, const char *mem, int dsz); | 96 | xs_list *xs_list_append_m(xs_list *list, const char *mem, int dsz); |
| @@ -692,6 +693,20 @@ xs_str *xs_tolower_i(xs_str *str) | |||
| 692 | } | 693 | } |
| 693 | 694 | ||
| 694 | 695 | ||
| 696 | xs_str *xs_toupper_i(xs_str *str) | ||
| 697 | /* convert to lowercase */ | ||
| 698 | { | ||
| 699 | XS_ASSERT_TYPE(str, XSTYPE_STRING); | ||
| 700 | |||
| 701 | int n; | ||
| 702 | |||
| 703 | for (n = 0; str[n]; n++) | ||
| 704 | str[n] = toupper(str[n]); | ||
| 705 | |||
| 706 | return str; | ||
| 707 | } | ||
| 708 | |||
| 709 | |||
| 695 | /** lists **/ | 710 | /** lists **/ |
| 696 | 711 | ||
| 697 | xs_list *xs_list_new(void) | 712 | xs_list *xs_list_new(void) |