Browse Source

The list of bookmarked posts also work.

default 7 months ago
parent
commit
8ea199a996
3 changed files with 23 additions and 0 deletions
  1. 7 0
      data.c
  2. 15 0
      html.c
  3. 1 0
      snac.h

+ 7 - 0
data.c

@@ -1583,6 +1583,13 @@ int unbookmark(snac *user, const char *id)
 }
 
 
+xs_list *bookmark_list(snac *user)
+/* return the lists of bookmarked posts */
+{
+    return object_user_cache_list(user, "bookmark", XS_ALL, 1);
+}
+
+
 /** pinning **/
 
 int is_pinned(snac *user, const char *id)

+ 15 - 0
html.c

@@ -2925,6 +2925,21 @@ int html_get_handler(const xs_dict *req, const char *q_path,
         }
     }
     else
+    if (strcmp(p_path, "list/bookmarks") == 0) { /** list of bookmarked posts **/
+        if (!login(&snac, req)) {
+            *body  = xs_dup(uid);
+            status = HTTP_STATUS_UNAUTHORIZED;
+        }
+        else {
+            xs *list = bookmark_list(&snac);
+
+            *body = html_timeline(&snac, list, 0, skip, show,
+                0, L("Bookmarked posts"), "", 0);
+            *b_size = strlen(*body);
+            status  = HTTP_STATUS_OK;
+        }
+    }
+    else
     if (xs_startswith(p_path, "list/")) { /** list timelines **/
         if (!login(&snac, req)) {
             *body  = xs_dup(uid);

+ 1 - 0
snac.h

@@ -169,6 +169,7 @@ int is_muted(snac *snac, const char *actor);
 int is_bookmarked(snac *user, const char *id);
 int bookmark(snac *user, const char *id);
 int unbookmark(snac *user, const char *id);
+xs_list *bookmark_list(snac *user);
 
 int pin(snac *user, const char *id);
 int unpin(snac *user, const char *id);