mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-15 01:55:03 +00:00
mastoapi: added bookmark list.
This commit is contained in:
parent
54520f0411
commit
08de491395
3 changed files with 28 additions and 5 deletions
14
data.c
14
data.c
|
@ -1026,12 +1026,18 @@ xs_str *object_user_cache_fn(snac *user, const char *id, const char *cachedir)
|
|||
}
|
||||
|
||||
|
||||
xs_str *object_user_cache_index_fn(snac *user, const char *cachedir)
|
||||
{
|
||||
return xs_fmt("%s/%s.idx", user->basedir, cachedir);
|
||||
}
|
||||
|
||||
|
||||
int _object_user_cache(snac *user, const char *id, const char *cachedir, int del)
|
||||
/* adds or deletes from a user cache */
|
||||
{
|
||||
xs *ofn = _object_fn(id);
|
||||
xs *cfn = object_user_cache_fn(user, id, cachedir);
|
||||
xs *idx = xs_fmt("%s/%s.idx", user->basedir, cachedir);
|
||||
xs *idx = object_user_cache_index_fn(user, cachedir);
|
||||
int ret;
|
||||
|
||||
if (del) {
|
||||
|
@ -1590,6 +1596,12 @@ xs_list *bookmark_list(snac *user)
|
|||
}
|
||||
|
||||
|
||||
xs_str *bookmark_index_fn(snac *user)
|
||||
{
|
||||
return object_user_cache_index_fn(user, "bookmark");
|
||||
}
|
||||
|
||||
|
||||
/** pinning **/
|
||||
|
||||
int is_pinned(snac *user, const char *id)
|
||||
|
|
14
mastoapi.c
14
mastoapi.c
|
@ -1822,11 +1822,17 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
|
|||
}
|
||||
else
|
||||
if (strcmp(cmd, "/v1/bookmarks") == 0) { /** **/
|
||||
/* snac does not support bookmarks */
|
||||
*body = xs_dup("[]");
|
||||
if (logged_in) {
|
||||
xs *ifn = bookmark_index_fn(&snac1);
|
||||
xs *out = mastoapi_timeline(&snac1, args, ifn);
|
||||
|
||||
*body = xs_json_dumps(out, 4);
|
||||
*ctype = "application/json";
|
||||
status = HTTP_STATUS_OK;
|
||||
}
|
||||
else
|
||||
status = HTTP_STATUS_UNAUTHORIZED;
|
||||
}
|
||||
else
|
||||
if (strcmp(cmd, "/v1/lists") == 0) { /** list of lists **/
|
||||
if (logged_in) {
|
||||
|
@ -1850,6 +1856,8 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
|
|||
*ctype = "application/json";
|
||||
status = HTTP_STATUS_OK;
|
||||
}
|
||||
else
|
||||
status = HTTP_STATUS_UNAUTHORIZED;
|
||||
}
|
||||
else
|
||||
if (xs_startswith(cmd, "/v1/lists/")) { /** list information **/
|
||||
|
@ -1910,6 +1918,8 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
|
|||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
status = HTTP_STATUS_UNAUTHORIZED;
|
||||
}
|
||||
else
|
||||
if (strcmp(cmd, "/v1/scheduled_statuses") == 0) { /** **/
|
||||
|
|
1
snac.h
1
snac.h
|
@ -170,6 +170,7 @@ 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);
|
||||
xs_str *bookmark_index_fn(snac *user);
|
||||
|
||||
int pin(snac *user, const char *id);
|
||||
int unpin(snac *user, const char *id);
|
||||
|
|
Loading…
Reference in a new issue