commit 55213f6

grunfink  ·  2025-06-12 08:59:26 +0000 UTC
parent 2391d2a
mastoapi: another try to fix collapsing boosted posts in some apps.
2 files changed,  +23, -3
M xs.h
+8, -3
 1@@ -1134,6 +1134,9 @@ xs_dict *mastoapi_status(snac *snac, const xs_dict *msg)
 2             bst = xs_dict_set(bst, "content", "");
 3             bst = xs_dict_set(bst, "reblog", st);
 4 
 5+            xs *b_id = xs_toupper_i(xs_dup(xs_dict_get(st, "id")));
 6+            bst = xs_dict_set(bst, "id", b_id);
 7+
 8             xs_free(st);
 9             st = bst;
10         }
11@@ -2338,15 +2341,17 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
12         /* information about a status */
13         if (logged_in) {
14             xs *l = xs_split(cmd, "/");
15-            const char *id = xs_list_get(l, 3);
16+            const char *oid = xs_list_get(l, 3);
17             const char *op = xs_list_get(l, 4);
18 
19-            if (!xs_is_null(id)) {
20+            if (!xs_is_null(oid)) {
21                 xs *msg = NULL;
22                 xs *out = NULL;
23 
24                 /* skip the 'fake' part of the id */
25-                id = MID_TO_MD5(id);
26+                oid = MID_TO_MD5(oid);
27+
28+                xs *id = xs_tolower_i(xs_dup(oid));
29 
30                 if (valid_status(object_get_by_md5(id, &msg))) {
31                     if (op == NULL) {
M xs.h
+15, -0
 1@@ -90,6 +90,7 @@ xs_str *xs_rstrip_chars_i(xs_str *str, const char *chars);
 2 xs_str *xs_strip_chars_i(xs_str *str, const char *chars);
 3 #define xs_strip_i(str) xs_strip_chars_i(str, " \r\n\t\v\f")
 4 xs_str *xs_tolower_i(xs_str *str);
 5+xs_str *xs_toupper_i(xs_str *str);
 6 
 7 xs_list *xs_list_new(void);
 8 xs_list *xs_list_append_m(xs_list *list, const char *mem, int dsz);
 9@@ -692,6 +693,20 @@ xs_str *xs_tolower_i(xs_str *str)
10 }
11 
12 
13+xs_str *xs_toupper_i(xs_str *str)
14+/* convert to lowercase */
15+{
16+    XS_ASSERT_TYPE(str, XSTYPE_STRING);
17+
18+    int n;
19+
20+    for (n = 0; str[n]; n++)
21+        str[n] = toupper(str[n]);
22+
23+    return str;
24+}
25+
26+
27 /** lists **/
28 
29 xs_list *xs_list_new(void)