commit d3309f8

violette  ·  2026-05-21 17:40:58 +0000 UTC
parent f1bd924
Added a new 'admiration' timeline.
2 files changed,  +32, -1
M data.c
M html.c
M data.c
+4, -1
 1@@ -1606,12 +1606,15 @@ int timeline_admire(snac *snac, const char *id,
 2     const char *content = xs_dict_get_path(msg, "content");
 3     const char *type = xs_dict_get_path(msg, "type");
 4 
 5-    /* if we are admiring this, add to both timelines */
 6+    /* if we are admiring this, add to both timelines, and store for later */
 7     if (!like && strcmp(admirer, snac->actor) == 0) {
 8         object_user_cache_add(snac, id, "public");
 9         object_user_cache_add(snac, id, "private");
10     }
11 
12+    if (strcmp(admirer, snac->actor) == 0)
13+        object_user_cache_add(snac, id, "admire");
14+
15     /* use utf <3 as a like, as it is ugly */
16     if (type && xs_match(type, "Like|EmojiReact|Emoji") &&
17             content && strcmp(content, "❤") != 0) {
M html.c
+28, -0
 1@@ -3520,6 +3520,18 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
 2                         xs_html_text(L("pinned")))));
 3         }
 4 
 5+        {
 6+            /* show the list of bookmarked posts */
 7+            xs *url = xs_fmt("%s/admirations", user->actor);
 8+            xs_html_add(lol,
 9+                xs_html_tag("li",
10+                    xs_html_tag("a",
11+                        xs_html_attr("href", url),
12+                        xs_html_attr("class", "snac-list-link"),
13+                        xs_html_attr("title", L("Liked, boosted or reacted posts")),
14+                        xs_html_text(L("admirations")))));
15+        }
16+
17         {
18             /* show the list of bookmarked posts */
19             xs *url = xs_fmt("%s/bookmarks", user->actor);
20@@ -5042,6 +5054,22 @@ int html_get_handler(const xs_dict *req, const char *q_path,
21         }
22     }
23     else
24+    if (strcmp(p_path, "admirations") == 0) { /** list of admired posts **/
25+        if (!login(&snac, req)) {
26+            *body  = xs_dup(uid);
27+            status = HTTP_STATUS_UNAUTHORIZED;
28+        }
29+        else {
30+            int more = 0;
31+            xs *list = timeline_list(&snac, "admire", skip, show, &more);
32+
33+            *body = html_timeline(&snac, list, 0, skip, show,
34+                more, L("Liked, boosted or reacted posts"), "/admirations", 0, error, terse);
35+            *b_size = strlen(*body);
36+            status  = HTTP_STATUS_OK;
37+        }
38+    }
39+    else
40     if (strcmp(p_path, "bookmarks") == 0) { /** list of bookmarked posts **/
41         if (!login(&snac, req)) {
42             *body  = xs_dup(uid);