commit 54520f0

default  ·  2024-08-29 06:11:30 +0000 UTC
parent 67f0efa
mastoapi: added support for [un]bookmarking.
1 files changed,  +11, -4
+11, -4
 1@@ -1061,7 +1061,8 @@ xs_dict *mastoapi_status(snac *snac, const xs_dict *msg)
 2     else
 3         st = xs_dict_append(st, "poll", xs_stock(XSTYPE_NULL));
 4 
 5-    st = xs_dict_append(st, "bookmarked", xs_stock(XSTYPE_FALSE));
 6+    st = xs_dict_append(st, "bookmarked",
 7+        (snac && is_bookmarked(snac, id)) ? xs_stock(XSTYPE_TRUE) : xs_stock(XSTYPE_FALSE));
 8 
 9     st = xs_dict_append(st, "pinned",
10         (snac && is_pinned(snac, id)) ? xs_stock(XSTYPE_TRUE) : xs_stock(XSTYPE_FALSE));
11@@ -2570,16 +2571,22 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
12                     }
13                     else
14                     if (strcmp(op, "bookmark") == 0) { /** **/
15-                        /* snac does not support bookmarks */
16+                        /* bookmark this message */
17+                        if (bookmark(&snac, id) == 0)
18+                            out = mastoapi_status(&snac, msg);
19+                        else
20+                            status = HTTP_STATUS_UNPROCESSABLE_CONTENT;
21                     }
22                     else
23                     if (strcmp(op, "unbookmark") == 0) { /** **/
24-                        /* snac does not support bookmarks */
25+                        /* unbookmark this message */
26+                        unbookmark(&snac, id);
27+                        out = mastoapi_status(&snac, msg);
28                     }
29                     else
30                     if (strcmp(op, "pin") == 0) { /** **/
31                         /* pin this message */
32-                        if (pin(&snac, id))
33+                        if (pin(&snac, id) == 0)
34                             out = mastoapi_status(&snac, msg);
35                         else
36                             status = HTTP_STATUS_UNPROCESSABLE_CONTENT;