From 4afd4e7a874aba04971c0a61791610e61012af19 Mon Sep 17 00:00:00 2001 From: "me@ow.nekobit.net" Date: Tue, 19 Apr 2022 17:42:47 +0000 Subject: [PATCH] Timeline home FossilOrigin-Name: b066a24d006bb6cff2db7ef88817c813edc647479ce88e2f7823123de11160b3 --- include/mastodont_timeline.h | 21 ++++++++++++++++-- src/timeline.c | 42 ++++++++++++++++++++++++++++++++++-- 2 files changed, 59 insertions(+), 4 deletions(-) diff --git a/include/mastodont_timeline.h b/include/mastodont_timeline.h index 30cede0..fe16144 100644 --- a/include/mastodont_timeline.h +++ b/include/mastodont_timeline.h @@ -18,15 +18,32 @@ #include #include +struct mstdnt_timeline_args +{ + int only_media; + int remote; + char* max_id; + char* since_id; + char* min_id; + int limit; + int local; +}; + +int mastodont_timeline_home(mastodont_t* data, + struct mstdnt_timeline_args* args, + struct mstdnt_storage* storage, + struct mstdnt_status* statuses[], + size_t* size); + int mastodont_timeline_list(mastodont_t* data, char* list_id, - struct mstdnt_args* args, + struct mstdnt_timeline_args* args, struct mstdnt_storage* storage, struct mstdnt_status* statuses[], size_t* size); int mastodont_timeline_public(mastodont_t* data, - struct mstdnt_args* args, + struct mstdnt_timeline_args* args, struct mstdnt_storage* storage, struct mstdnt_status* statuses[], size_t* statuses_size); diff --git a/src/timeline.c b/src/timeline.c index 79a79ec..d6af497 100644 --- a/src/timeline.c +++ b/src/timeline.c @@ -22,7 +22,7 @@ int mastodont_timeline_list(mastodont_t* data, char* list_id, - struct mstdnt_args* args, + struct mstdnt_timeline_args* args, struct mstdnt_storage* storage, struct mstdnt_status* statuses[], size_t* size) @@ -59,7 +59,7 @@ int mastodont_timeline_list(mastodont_t* data, } int mastodont_timeline_public(mastodont_t* data, - struct mstdnt_args* args, + struct mstdnt_timeline_args* args, struct mstdnt_storage* storage, struct mstdnt_status* statuses[], size_t* size) @@ -98,3 +98,41 @@ int mastodont_timeline_public(mastodont_t* data, return mastodont_request(data, &req_args); } + + +int mastodont_timeline_home(mastodont_t* data, + struct mstdnt_timeline_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_local; + 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; + u_local.i = args->local; + + 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 }, + { _MSTDNT_QUERY_INT, "local", u_local }, + }; + + struct mastodont_request_args req_args = { + storage, + "api/v1/timelines/home", + params, _mstdnt_arr_len(params), + NULL, 0, + CURLOPT_HTTPGET, + &cb_args, + _mstdnt_statuses_result_callback, + }; + + return mastodont_request(data, &req_args); +}