commit 7c1550e
default
·
2023-10-13 07:01:07 +0000 UTC
parent b08d455
mastoapi: boosted posts by others are correctly returned.
1 files changed,
+27,
-0
+27,
-0
1@@ -878,6 +878,11 @@ xs_dict *mastoapi_status(snac *snac, const xs_dict *msg)
2 st = xs_dict_append(st, "reblogged",
3 (snac && xs_list_in(idx, snac->md5) != -1) ? xs_stock_true : xs_stock_false);
4
5+ /* get the last person who boosted this */
6+ xs *boosted_by_md5 = NULL;
7+ if (xs_list_len(idx))
8+ boosted_by_md5 = xs_dup(xs_list_get(idx, -1));
9+
10 xs_free(idx);
11 xs_free(ixc);
12 idx = object_children(id);
13@@ -933,6 +938,28 @@ xs_dict *mastoapi_status(snac *snac, const xs_dict *msg)
14 st = xs_dict_append(st, "pinned",
15 (snac && is_pinned(snac, id)) ? xs_stock_true : xs_stock_false);
16
17+ /* is it a boost? */
18+ if (!xs_is_null(boosted_by_md5)) {
19+ /* create a new dummy status, using st as the 'reblog' field */
20+ xs_dict *bst = xs_dict_new();
21+ xs *b_actor = NULL;
22+
23+ if (valid_status(object_get_by_md5(boosted_by_md5, &b_actor))) {
24+ xs *b_acct = mastoapi_account(b_actor);
25+ xs *fake_uri = xs_fmt("%s/d/%s", srv_baseurl, mid);
26+
27+ bst = xs_dict_append(bst, "id", mid);
28+ bst = xs_dict_append(bst, "created_at", xs_dict_get(st, "created_at"));
29+ bst = xs_dict_append(bst, "account", b_acct);
30+ bst = xs_dict_append(bst, "uri", fake_uri);
31+ bst = xs_dict_append(bst, "content", "");
32+ bst = xs_dict_append(bst, "reblog", st);
33+
34+ xs_free(st);
35+ st = bst;
36+ }
37+ }
38+
39 return st;
40 }
41