mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 05:15:04 +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)
|
int _object_user_cache(snac *user, const char *id, const char *cachedir, int del)
|
||||||
/* adds or deletes from a user cache */
|
/* adds or deletes from a user cache */
|
||||||
{
|
{
|
||||||
xs *ofn = _object_fn(id);
|
xs *ofn = _object_fn(id);
|
||||||
xs *cfn = object_user_cache_fn(user, id, cachedir);
|
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;
|
int ret;
|
||||||
|
|
||||||
if (del) {
|
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 **/
|
/** pinning **/
|
||||||
|
|
||||||
int is_pinned(snac *user, const char *id)
|
int is_pinned(snac *user, const char *id)
|
||||||
|
|
18
mastoapi.c
18
mastoapi.c
|
@ -1822,10 +1822,16 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (strcmp(cmd, "/v1/bookmarks") == 0) { /** **/
|
if (strcmp(cmd, "/v1/bookmarks") == 0) { /** **/
|
||||||
/* snac does not support bookmarks */
|
if (logged_in) {
|
||||||
*body = xs_dup("[]");
|
xs *ifn = bookmark_index_fn(&snac1);
|
||||||
*ctype = "application/json";
|
xs *out = mastoapi_timeline(&snac1, args, ifn);
|
||||||
status = HTTP_STATUS_OK;
|
|
||||||
|
*body = xs_json_dumps(out, 4);
|
||||||
|
*ctype = "application/json";
|
||||||
|
status = HTTP_STATUS_OK;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
status = HTTP_STATUS_UNAUTHORIZED;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (strcmp(cmd, "/v1/lists") == 0) { /** list of lists **/
|
if (strcmp(cmd, "/v1/lists") == 0) { /** list of lists **/
|
||||||
|
@ -1850,6 +1856,8 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
|
||||||
*ctype = "application/json";
|
*ctype = "application/json";
|
||||||
status = HTTP_STATUS_OK;
|
status = HTTP_STATUS_OK;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
status = HTTP_STATUS_UNAUTHORIZED;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (xs_startswith(cmd, "/v1/lists/")) { /** list information **/
|
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
|
else
|
||||||
if (strcmp(cmd, "/v1/scheduled_statuses") == 0) { /** **/
|
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 bookmark(snac *user, const char *id);
|
||||||
int unbookmark(snac *user, const char *id);
|
int unbookmark(snac *user, const char *id);
|
||||||
xs_list *bookmark_list(snac *user);
|
xs_list *bookmark_list(snac *user);
|
||||||
|
xs_str *bookmark_index_fn(snac *user);
|
||||||
|
|
||||||
int pin(snac *user, const char *id);
|
int pin(snac *user, const char *id);
|
||||||
int unpin(snac *user, const char *id);
|
int unpin(snac *user, const char *id);
|
||||||
|
|
Loading…
Reference in a new issue