Quellcode durchsuchen

Added a new 'admiration' timeline.

violette vor 2 Monaten
Ursprung
Commit
d3309f8b5e
2 geänderte Dateien mit 32 neuen und 1 gelöschten Zeilen
  1. 4 1
      data.c
  2. 28 0
      html.c

+ 4 - 1
data.c

@@ -1606,12 +1606,15 @@ int timeline_admire(snac *snac, const char *id,
     const char *content = xs_dict_get_path(msg, "content");
     const char *type = xs_dict_get_path(msg, "type");
 
-    /* if we are admiring this, add to both timelines */
+    /* if we are admiring this, add to both timelines, and store for later */
     if (!like && strcmp(admirer, snac->actor) == 0) {
         object_user_cache_add(snac, id, "public");
         object_user_cache_add(snac, id, "private");
     }
 
+    if (strcmp(admirer, snac->actor) == 0)
+        object_user_cache_add(snac, id, "admire");
+
     /* use utf <3 as a like, as it is ugly */
     if (type && xs_match(type, "Like|EmojiReact|Emoji") &&
             content && strcmp(content, "❤") != 0) {

+ 28 - 0
html.c

@@ -3520,6 +3520,18 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
                         xs_html_text(L("pinned")))));
         }
 
+        {
+            /* show the list of bookmarked posts */
+            xs *url = xs_fmt("%s/admirations", user->actor);
+            xs_html_add(lol,
+                xs_html_tag("li",
+                    xs_html_tag("a",
+                        xs_html_attr("href", url),
+                        xs_html_attr("class", "snac-list-link"),
+                        xs_html_attr("title", L("Liked, boosted or reacted posts")),
+                        xs_html_text(L("admirations")))));
+        }
+
         {
             /* show the list of bookmarked posts */
             xs *url = xs_fmt("%s/bookmarks", user->actor);
@@ -5042,6 +5054,22 @@ int html_get_handler(const xs_dict *req, const char *q_path,
         }
     }
     else
+    if (strcmp(p_path, "admirations") == 0) { /** list of admired posts **/
+        if (!login(&snac, req)) {
+            *body  = xs_dup(uid);
+            status = HTTP_STATUS_UNAUTHORIZED;
+        }
+        else {
+            int more = 0;
+            xs *list = timeline_list(&snac, "admire", skip, show, &more);
+
+            *body = html_timeline(&snac, list, 0, skip, show,
+                more, L("Liked, boosted or reacted posts"), "/admirations", 0, error, terse);
+            *b_size = strlen(*body);
+            status  = HTTP_STATUS_OK;
+        }
+    }
+    else
     if (strcmp(p_path, "bookmarks") == 0) { /** list of bookmarked posts **/
         if (!login(&snac, req)) {
             *body  = xs_dup(uid);