commit b11795b
grunfink
·
2026-05-06 18:21:43 +0000 UTC
parent 9c033f4
mastoapi: fix lost hashtags when editing posts.
1 files changed,
+22,
-2
+22,
-2
1@@ -4205,17 +4205,37 @@ int mastoapi_put_handler(const xs_dict *req, const char *q_path,
2 if (valid_status(timeline_get_by_md5(&snac, md5, &msg))) {
3 const char *content = xs_dict_get(args, "status");
4 xs *atls = xs_list_new();
5- xs *f_content = not_really_markdown(content, &atls, NULL);
6+ xs *f_content0 = not_really_markdown(content, &atls, NULL);
7+ xs *tag = xs_list_new();
8+ xs *f_content = process_tags(&snac, f_content0, &tag);
9
10 /* replace fields with new content */
11 msg = xs_dict_set(msg, "sourceContent", content);
12 msg = xs_dict_set(msg, "content", f_content);
13
14+ xs *content_map = xs_dup(xs_dict_get(msg, "contentMap"));
15+ if (xs_is_dict(content_map)) {
16+ /* get the first pair */
17+ const char *k, *v;
18+ int c = 0;
19+
20+ if (xs_dict_next(content_map, &k, &v, &c)) {
21+ content_map = xs_dict_set(content_map, k, f_content);
22+ msg = xs_dict_set(msg, "contentMap", content_map);
23+ }
24+ }
25+
26 xs *updated = xs_str_utctime(0, ISO_DATE_SPEC);
27 msg = xs_dict_set(msg, "updated", updated);
28
29+ msg = xs_dict_set(msg, "tag", tag);
30+
31 /* overwrite object, not updating the indexes */
32- object_add_ow(xs_dict_get(msg, "id"), msg);
33+ const char *id = xs_dict_get(msg, "id");
34+
35+ object_add_ow(id, msg);
36+
37+ tag_index(id, msg);
38
39 /* update message */
40 xs *c_msg = msg_update(&snac, msg);