mastoapi: added support for [un]bookmarking.

This commit is contained in:
default 2024-08-29 08:11:30 +02:00
parent 67f0efa689
commit 54520f0411

View File

@ -1061,7 +1061,8 @@ xs_dict *mastoapi_status(snac *snac, const xs_dict *msg)
else else
st = xs_dict_append(st, "poll", xs_stock(XSTYPE_NULL)); st = xs_dict_append(st, "poll", xs_stock(XSTYPE_NULL));
st = xs_dict_append(st, "bookmarked", xs_stock(XSTYPE_FALSE)); st = xs_dict_append(st, "bookmarked",
(snac && is_bookmarked(snac, id)) ? xs_stock(XSTYPE_TRUE) : xs_stock(XSTYPE_FALSE));
st = xs_dict_append(st, "pinned", st = xs_dict_append(st, "pinned",
(snac && is_pinned(snac, id)) ? xs_stock(XSTYPE_TRUE) : xs_stock(XSTYPE_FALSE)); (snac && is_pinned(snac, id)) ? xs_stock(XSTYPE_TRUE) : xs_stock(XSTYPE_FALSE));
@ -2570,16 +2571,22 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
} }
else else
if (strcmp(op, "bookmark") == 0) { /** **/ if (strcmp(op, "bookmark") == 0) { /** **/
/* snac does not support bookmarks */ /* bookmark this message */
if (bookmark(&snac, id) == 0)
out = mastoapi_status(&snac, msg);
else
status = HTTP_STATUS_UNPROCESSABLE_CONTENT;
} }
else else
if (strcmp(op, "unbookmark") == 0) { /** **/ if (strcmp(op, "unbookmark") == 0) { /** **/
/* snac does not support bookmarks */ /* unbookmark this message */
unbookmark(&snac, id);
out = mastoapi_status(&snac, msg);
} }
else else
if (strcmp(op, "pin") == 0) { /** **/ if (strcmp(op, "pin") == 0) { /** **/
/* pin this message */ /* pin this message */
if (pin(&snac, id)) if (pin(&snac, id) == 0)
out = mastoapi_status(&snac, msg); out = mastoapi_status(&snac, msg);
else else
status = HTTP_STATUS_UNPROCESSABLE_CONTENT; status = HTTP_STATUS_UNPROCESSABLE_CONTENT;