diff options
| author | 2023-10-13 09:01:07 +0200 | |
|---|---|---|
| committer | 2023-10-13 09:01:07 +0200 | |
| commit | 7c1550e566554a06ebd5ecb862fecabdb811fc8c (patch) | |
| tree | 0328960ccad264701de041037ab425865e48e8cd | |
| parent | mastoapi: show any boosted note, not only by us. (diff) | |
| download | snac2-7c1550e566554a06ebd5ecb862fecabdb811fc8c.tar.gz snac2-7c1550e566554a06ebd5ecb862fecabdb811fc8c.tar.xz snac2-7c1550e566554a06ebd5ecb862fecabdb811fc8c.zip | |
mastoapi: boosted posts by others are correctly returned.
| -rw-r--r-- | mastoapi.c | 27 |
1 files changed, 27 insertions, 0 deletions
| @@ -878,6 +878,11 @@ xs_dict *mastoapi_status(snac *snac, const xs_dict *msg) | |||
| 878 | st = xs_dict_append(st, "reblogged", | 878 | st = xs_dict_append(st, "reblogged", |
| 879 | (snac && xs_list_in(idx, snac->md5) != -1) ? xs_stock_true : xs_stock_false); | 879 | (snac && xs_list_in(idx, snac->md5) != -1) ? xs_stock_true : xs_stock_false); |
| 880 | 880 | ||
| 881 | /* get the last person who boosted this */ | ||
| 882 | xs *boosted_by_md5 = NULL; | ||
| 883 | if (xs_list_len(idx)) | ||
| 884 | boosted_by_md5 = xs_dup(xs_list_get(idx, -1)); | ||
| 885 | |||
| 881 | xs_free(idx); | 886 | xs_free(idx); |
| 882 | xs_free(ixc); | 887 | xs_free(ixc); |
| 883 | idx = object_children(id); | 888 | idx = object_children(id); |
| @@ -933,6 +938,28 @@ xs_dict *mastoapi_status(snac *snac, const xs_dict *msg) | |||
| 933 | st = xs_dict_append(st, "pinned", | 938 | st = xs_dict_append(st, "pinned", |
| 934 | (snac && is_pinned(snac, id)) ? xs_stock_true : xs_stock_false); | 939 | (snac && is_pinned(snac, id)) ? xs_stock_true : xs_stock_false); |
| 935 | 940 | ||
| 941 | /* is it a boost? */ | ||
| 942 | if (!xs_is_null(boosted_by_md5)) { | ||
| 943 | /* create a new dummy status, using st as the 'reblog' field */ | ||
| 944 | xs_dict *bst = xs_dict_new(); | ||
| 945 | xs *b_actor = NULL; | ||
| 946 | |||
| 947 | if (valid_status(object_get_by_md5(boosted_by_md5, &b_actor))) { | ||
| 948 | xs *b_acct = mastoapi_account(b_actor); | ||
| 949 | xs *fake_uri = xs_fmt("%s/d/%s", srv_baseurl, mid); | ||
| 950 | |||
| 951 | bst = xs_dict_append(bst, "id", mid); | ||
| 952 | bst = xs_dict_append(bst, "created_at", xs_dict_get(st, "created_at")); | ||
| 953 | bst = xs_dict_append(bst, "account", b_acct); | ||
| 954 | bst = xs_dict_append(bst, "uri", fake_uri); | ||
| 955 | bst = xs_dict_append(bst, "content", ""); | ||
| 956 | bst = xs_dict_append(bst, "reblog", st); | ||
| 957 | |||
| 958 | xs_free(st); | ||
| 959 | st = bst; | ||
| 960 | } | ||
| 961 | } | ||
| 962 | |||
| 936 | return st; | 963 | return st; |
| 937 | } | 964 | } |
| 938 | 965 | ||