diff --git a/include/mastodont_status.h b/include/mastodont_status.h index cb5dc5d..57a6a83 100644 --- a/include/mastodont_status.h +++ b/include/mastodont_status.h @@ -183,6 +183,33 @@ struct _mstdnt_status_context_result_cb_args size_t* size_after; }; +struct mstdnt_bookmarks_args +{ + char* max_id; + char* since_id; + char* min_id; + int limit; +}; + +struct mstdnt_favourites_args +{ + char* max_id; + char* min_id; + int limit; +}; + +int mastodont_get_bookmarks(mastodont_t* data, + struct mstdnt_bookmarks_args* args, + struct mstdnt_storage* storage, + struct mstdnt_status* statuses[], + size_t* size); + +int mastodont_get_favourites(mastodont_t* data, + struct mstdnt_favourites_args* args, + struct mstdnt_storage* storage, + struct mstdnt_status* statuses[], + size_t* size); + int _mstdnt_statuses_result_callback(struct mstdnt_fetch_results* results, struct mstdnt_storage* storage, void* _args); diff --git a/src/account.c b/src/account.c index 0b7f3f3..a4896ef 100644 --- a/src/account.c +++ b/src/account.c @@ -161,6 +161,8 @@ int mstdnt_account_from_json(struct mstdnt_account* acct, cJSON* js) { _mstdnt_key_val_ref(v, refs, _mstdnt_arr_len(refs)); } + + return 0; } @@ -186,7 +188,6 @@ int mstdnt_account_action(mastodont_t* data, return mastodont_request(data, &req_args); } - /* These are all the same */ MSTDNT_ACCOUNT_ACTION_DECL(follow) MSTDNT_ACCOUNT_ACTION_FUNC_URL("follow") diff --git a/src/status.c b/src/status.c index d67e908..082fb1c 100644 --- a/src/status.c +++ b/src/status.c @@ -485,6 +485,74 @@ int mastodont_status_reblogged_by(mastodont_t* data, return mastodont_request(data, &req_args); } + +int mastodont_get_bookmarks(mastodont_t* data, + struct mstdnt_bookmarks_args* args, + struct mstdnt_storage* storage, + struct mstdnt_status* statuses[], + size_t* size) +{ + struct _mstdnt_statuses_cb_args cb_args = { statuses, size }; + + union param_value u_max_id, u_since_id, u_min_id, u_limit; + u_max_id.s = args->max_id; + u_since_id.s = args->since_id; + u_min_id.s = args->min_id; + u_limit.i = args->limit; + + struct _mstdnt_query_param params[] = { + { _MSTDNT_QUERY_STRING, "max_id", u_max_id }, + { _MSTDNT_QUERY_STRING, "since_id", u_since_id }, + { _MSTDNT_QUERY_STRING, "min_id", u_min_id }, + { _MSTDNT_QUERY_INT, "limit", u_limit }, + }; + + struct mastodont_request_args req_args = { + storage, + "api/v1/bookmarks", + params, _mstdnt_arr_len(params), + NULL, 0, + CURLOPT_HTTPGET, + &cb_args, + _mstdnt_statuses_result_callback, + }; + + return mastodont_request(data, &req_args); +} + +int mastodont_get_favourites(mastodont_t* data, + struct mstdnt_favourites_args* args, + struct mstdnt_storage* storage, + struct mstdnt_status* statuses[], + size_t* size) +{ + struct _mstdnt_statuses_cb_args cb_args = { statuses, size }; + + union param_value u_max_id, u_min_id, u_limit; + u_max_id.s = args->max_id; + u_min_id.s = args->min_id; + u_limit.i = args->limit; + + struct _mstdnt_query_param params[] = { + { _MSTDNT_QUERY_STRING, "max_id", u_max_id }, + { _MSTDNT_QUERY_STRING, "min_id", u_min_id }, + { _MSTDNT_QUERY_INT, "limit", u_limit }, + }; + + struct mastodont_request_args req_args = { + storage, + "api/v1/favourites", + params, _mstdnt_arr_len(params), + NULL, 0, + CURLOPT_HTTPGET, + &cb_args, + _mstdnt_statuses_result_callback, + }; + + return mastodont_request(data, &req_args); +} + + void mstdnt_cleanup_status(struct mstdnt_status* status) { cleanup_attachments(status->media_attachments);