Forráskód Böngészése

mastoapi: another try to fix collapsing boosted posts in some apps.

grunfink 1 éve
szülő
commit
55213f660d
2 módosított fájl, 23 hozzáadás és 3 törlés
  1. 8 3
      mastoapi.c
  2. 15 0
      xs.h

+ 8 - 3
mastoapi.c

@@ -1134,6 +1134,9 @@ xs_dict *mastoapi_status(snac *snac, const xs_dict *msg)
             bst = xs_dict_set(bst, "content", "");
             bst = xs_dict_set(bst, "content", "");
             bst = xs_dict_set(bst, "reblog", st);
             bst = xs_dict_set(bst, "reblog", st);
 
 
+            xs *b_id = xs_toupper_i(xs_dup(xs_dict_get(st, "id")));
+            bst = xs_dict_set(bst, "id", b_id);
+
             xs_free(st);
             xs_free(st);
             st = bst;
             st = bst;
         }
         }
@@ -2338,15 +2341,17 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
         /* information about a status */
         /* information about a status */
         if (logged_in) {
         if (logged_in) {
             xs *l = xs_split(cmd, "/");
             xs *l = xs_split(cmd, "/");
-            const char *id = xs_list_get(l, 3);
+            const char *oid = xs_list_get(l, 3);
             const char *op = xs_list_get(l, 4);
             const char *op = xs_list_get(l, 4);
 
 
-            if (!xs_is_null(id)) {
+            if (!xs_is_null(oid)) {
                 xs *msg = NULL;
                 xs *msg = NULL;
                 xs *out = NULL;
                 xs *out = NULL;
 
 
                 /* skip the 'fake' part of the id */
                 /* skip the 'fake' part of the id */
-                id = MID_TO_MD5(id);
+                oid = MID_TO_MD5(oid);
+
+                xs *id = xs_tolower_i(xs_dup(oid));
 
 
                 if (valid_status(object_get_by_md5(id, &msg))) {
                 if (valid_status(object_get_by_md5(id, &msg))) {
                     if (op == NULL) {
                     if (op == NULL) {

+ 15 - 0
xs.h

@@ -90,6 +90,7 @@ xs_str *xs_rstrip_chars_i(xs_str *str, const char *chars);
 xs_str *xs_strip_chars_i(xs_str *str, const char *chars);
 xs_str *xs_strip_chars_i(xs_str *str, const char *chars);
 #define xs_strip_i(str) xs_strip_chars_i(str, " \r\n\t\v\f")
 #define xs_strip_i(str) xs_strip_chars_i(str, " \r\n\t\v\f")
 xs_str *xs_tolower_i(xs_str *str);
 xs_str *xs_tolower_i(xs_str *str);
+xs_str *xs_toupper_i(xs_str *str);
 
 
 xs_list *xs_list_new(void);
 xs_list *xs_list_new(void);
 xs_list *xs_list_append_m(xs_list *list, const char *mem, int dsz);
 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)
 }
 }
 
 
 
 
+xs_str *xs_toupper_i(xs_str *str)
+/* convert to lowercase */
+{
+    XS_ASSERT_TYPE(str, XSTYPE_STRING);
+
+    int n;
+
+    for (n = 0; str[n]; n++)
+        str[n] = toupper(str[n]);
+
+    return str;
+}
+
+
 /** lists **/
 /** lists **/
 
 
 xs_list *xs_list_new(void)
 xs_list *xs_list_new(void)