commit 5ede21a
grunfink
·
2026-10-01 06:41:24 +0000 UTC
parent e5a0a58
mastoapi: fixed modification of alt texts.
1 files changed,
+27,
-0
+27,
-0
1@@ -4355,6 +4355,33 @@ int mastoapi_put_handler(const xs_dict *req, const char *q_path,
2 msg = xs_dict_set(msg, "sensitive", xs_stock(XSTYPE_FALSE));
3 }
4
5+ const xs_list *media_attrs = xs_dict_get(args, "media_attributes");
6+
7+ if (xs_is_list(media_attrs)) {
8+ /* change alt texts */
9+ xs *n_att = xs_dup(xs_dict_get(msg, "attachment"));
10+
11+ if (xs_is_list(n_att)) {
12+ int num = xs_list_len(media_attrs);
13+
14+ for (int n = 0; n < num; n++) {
15+ const xs_dict *d = xs_list_get(media_attrs, n);
16+
17+ if (xs_is_dict(d)) {
18+ xs *na = xs_dup(xs_list_get(n_att, n));
19+
20+ if (xs_is_dict(na)) {
21+ const char *desc = xs_dict_get(d, "description");
22+ na = xs_dict_set(na, "name", desc);
23+ n_att = xs_list_set(n_att, n, na);
24+ }
25+ }
26+ }
27+ }
28+
29+ msg = xs_dict_set(msg, "attachment", n_att);
30+ }
31+
32 /* overwrite object, not updating the indexes */
33 const char *id = xs_dict_get(msg, "id");
34