diff --git a/include/mastodont_timeline.h b/include/mastodont_timeline.h index fe16144..d2cd3a6 100644 --- a/include/mastodont_timeline.h +++ b/include/mastodont_timeline.h @@ -26,7 +26,9 @@ struct mstdnt_timeline_args char* since_id; char* min_id; int limit; + int offset; int local; + int with_muted; }; int mastodont_timeline_home(mastodont_t* data, @@ -48,4 +50,11 @@ int mastodont_timeline_public(mastodont_t* data, struct mstdnt_status* statuses[], size_t* statuses_size); +int mastodont_timeline_direct(mastodont_t* data, + struct mstdnt_timeline_args* args, + struct mstdnt_storage* storage, + struct mstdnt_status* statuses[], + size_t* statuses_size); + + #endif /* MASTODONT_TIMELINE_H */ diff --git a/src/timeline.c b/src/timeline.c index d6af497..e7e02bb 100644 --- a/src/timeline.c +++ b/src/timeline.c @@ -100,7 +100,7 @@ int mastodont_timeline_public(mastodont_t* data, } -int mastodont_timeline_home(mastodont_t* data, +int mastodont_timeline_direct(mastodont_t* data, struct mstdnt_timeline_args* args, struct mstdnt_storage* storage, struct mstdnt_status* statuses[], @@ -109,19 +109,62 @@ int mastodont_timeline_home(mastodont_t* data, 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_limit, u_local, u_offset, u_with_muted; 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_offset.i = args->offset; u_local.i = args->local; + u_with_muted.i = args->with_muted; 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, "offset", u_offset }, { _MSTDNT_QUERY_INT, "local", u_local }, + { _MSTDNT_QUERY_INT, "with_muted", u_with_muted }, + }; + + struct mastodont_request_args req_args = { + storage, + "api/v1/timelines/direct", + params, _mstdnt_arr_len(params), + NULL, 0, + CURLOPT_HTTPGET, + &cb_args, + _mstdnt_statuses_result_callback, + }; + + 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_offset; + 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; + u_offset.i = args->offset; + + 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, "offset", u_offset }, }; struct mastodont_request_args req_args = { @@ -136,3 +179,4 @@ int mastodont_timeline_home(mastodont_t* data, return mastodont_request(data, &req_args); } +