Timeline updates
FossilOrigin-Name: a4cc696b0189b720b7c92323fcc3420d160420a16a843b91a0659e0093f475f3
This commit is contained in:
parent
c1c3dd59f6
commit
9c72241040
2 changed files with 113 additions and 122 deletions
|
@ -40,36 +40,41 @@ struct mstdnt_timeline_args
|
|||
int with_muted;
|
||||
};
|
||||
|
||||
int mstdnt_timeline_home(mastodont_t* data,
|
||||
struct mstdnt_args* m_args,
|
||||
mstdnt_request_cb_t cb_request,
|
||||
void* cb_args,
|
||||
struct mstdnt_timeline_args* args);
|
||||
int
|
||||
mstdnt_timeline_home(mastodont_t* data,
|
||||
struct mstdnt_args* m_args,
|
||||
mstdnt_request_cb_t cb_request,
|
||||
void* cb_args,
|
||||
struct mstdnt_timeline_args args);
|
||||
|
||||
int mstdnt_timeline_list(mastodont_t* data,
|
||||
struct mstdnt_args* m_args,
|
||||
mstdnt_request_cb_t cb_request,
|
||||
void* cb_args,
|
||||
char* list_id,
|
||||
struct mstdnt_timeline_args* args);
|
||||
int
|
||||
mstdnt_timeline_list(mastodont_t* data,
|
||||
struct mstdnt_args* m_args,
|
||||
mstdnt_request_cb_t cb_request,
|
||||
void* cb_args,
|
||||
char* list_id,
|
||||
struct mstdnt_timeline_args args);
|
||||
|
||||
int mstdnt_timeline_public(mastodont_t* data,
|
||||
struct mstdnt_args* m_args,
|
||||
mstdnt_request_cb_t cb_request,
|
||||
void* cb_args,
|
||||
struct mstdnt_timeline_args* args);
|
||||
int
|
||||
mstdnt_timeline_public(mastodont_t* data,
|
||||
struct mstdnt_args* m_args,
|
||||
mstdnt_request_cb_t cb_request,
|
||||
void* cb_args,
|
||||
struct mstdnt_timeline_args args);
|
||||
|
||||
int mstdnt_timeline_direct(mastodont_t* data,
|
||||
struct mstdnt_args* m_args,
|
||||
mstdnt_request_cb_t cb_request,
|
||||
void* cb_args,
|
||||
struct mstdnt_timeline_args* args);
|
||||
int
|
||||
mstdnt_timeline_direct(mastodont_t* data,
|
||||
struct mstdnt_args* m_args,
|
||||
mstdnt_request_cb_t cb_request,
|
||||
void* cb_args,
|
||||
struct mstdnt_timeline_args args);
|
||||
|
||||
int mstdnt_timeline_tag(mastodont_t* data,
|
||||
struct mstdnt_args* m_args,
|
||||
mstdnt_request_cb_t cb_request,
|
||||
void* cb_args,
|
||||
char* hashtag,
|
||||
struct mstdnt_timeline_args* args);
|
||||
int
|
||||
mstdnt_timeline_tag(mastodont_t* data,
|
||||
struct mstdnt_args* m_args,
|
||||
mstdnt_request_cb_t cb_request,
|
||||
void* cb_args,
|
||||
char* hashtag,
|
||||
struct mstdnt_timeline_args args);
|
||||
|
||||
#endif /* MASTODONT_TIMELINE_H */
|
||||
|
|
176
src/timeline.c
176
src/timeline.c
|
@ -20,86 +20,81 @@
|
|||
#include <mastodont_query.h>
|
||||
#include <mastodont_request.h>
|
||||
|
||||
int mstdnt_timeline_list(mastodont_t* data,
|
||||
struct mstdnt_args* m_args,
|
||||
mstdnt_request_cb_t cb_request,
|
||||
void* cb_args,
|
||||
char* list_id,
|
||||
struct mstdnt_timeline_args* args)
|
||||
int
|
||||
mstdnt_timeline_list(mastodont_t* data,
|
||||
struct mstdnt_args* m_args,
|
||||
mstdnt_request_cb_t cb_request,
|
||||
void* cb_args,
|
||||
char* list_id,
|
||||
struct mstdnt_timeline_args args)
|
||||
{
|
||||
char url[MSTDNT_URLSIZE];
|
||||
snprintf(url, MSTDNT_URLSIZE, "api/v1/timelines/list/%s", list_id);
|
||||
|
||||
struct _mstdnt_query_param params[] = {
|
||||
{ _MSTDNT_QUERY_BOOL, "local", { .b = args->local } },
|
||||
{ _MSTDNT_QUERY_BOOL, "remote", { .b = args->remote } },
|
||||
{ _MSTDNT_QUERY_BOOL, "only_media", { .b = args->only_media } },
|
||||
{ _MSTDNT_QUERY_BOOL, "with_muted", { .b = args->with_muted } },
|
||||
/* { _MSTDNT_QUERY_INT, "exclude_visibilities", { .i = args->only_media } }, */
|
||||
{ _MSTDNT_QUERY_STRING, "max_id", { .s = args->max_id } },
|
||||
{ _MSTDNT_QUERY_STRING, "since_id", { .s = args->since_id } },
|
||||
{ _MSTDNT_QUERY_STRING, "min_id", { .s = args->min_id } },
|
||||
{ _MSTDNT_QUERY_INT, "limit", { .i = args->limit } },
|
||||
{ _MSTDNT_QUERY_INT, "offset", { .i = args->offset } },
|
||||
{ _MSTDNT_QUERY_BOOL, "local", { .b = args.local } },
|
||||
{ _MSTDNT_QUERY_BOOL, "remote", { .b = args.remote } },
|
||||
{ _MSTDNT_QUERY_BOOL, "only_media", { .b = args.only_media } },
|
||||
{ _MSTDNT_QUERY_BOOL, "with_muted", { .b = args.with_muted } },
|
||||
/* { _MSTDNT_QUERY_INT, "exclude_visibilities", { .i = args.only_media } }, */
|
||||
{ _MSTDNT_QUERY_STRING, "max_id", { .s = args.max_id } },
|
||||
{ _MSTDNT_QUERY_STRING, "since_id", { .s = args.since_id } },
|
||||
{ _MSTDNT_QUERY_STRING, "min_id", { .s = args.min_id } },
|
||||
{ _MSTDNT_QUERY_INT, "limit", { .i = args.limit } },
|
||||
{ _MSTDNT_QUERY_INT, "offset", { .i = args.offset } },
|
||||
};
|
||||
|
||||
struct mstdnt_request_args req_args = {
|
||||
.url = url,
|
||||
.params_query = params,
|
||||
.params_query_len = _mstdnt_arr_len(params),
|
||||
.params_post = NULL,
|
||||
.params_post_len = 0,
|
||||
.request_type = CURLOPT_HTTPGET,
|
||||
.request_type_custom = NULL,
|
||||
.args = NULL,
|
||||
.callback = mstdnt_statuses_json_callback,
|
||||
};
|
||||
|
||||
return mstdnt_request(data, m_args, cb_request, cb_args, &req_args);
|
||||
}
|
||||
|
||||
int mstdnt_timeline_tag(mastodont_t* data,
|
||||
struct mstdnt_args* m_args,
|
||||
mstdnt_request_cb_t cb_request,
|
||||
void* cb_args,
|
||||
char* hashtag,
|
||||
struct mstdnt_timeline_args* args)
|
||||
int
|
||||
mstdnt_timeline_tag(mastodont_t* data,
|
||||
struct mstdnt_args* m_args,
|
||||
mstdnt_request_cb_t cb_request,
|
||||
void* cb_args,
|
||||
char* hashtag,
|
||||
struct mstdnt_timeline_args args)
|
||||
{
|
||||
char url[MSTDNT_URLSIZE];
|
||||
snprintf(url, MSTDNT_URLSIZE, "api/v1/timelines/tag/%s", hashtag);
|
||||
|
||||
struct _mstdnt_query_param params[] = {
|
||||
{ _MSTDNT_QUERY_STRING, "max_id", { .s = args->max_id } },
|
||||
{ _MSTDNT_QUERY_STRING, "since_id", { .s = args->since_id } },
|
||||
{ _MSTDNT_QUERY_STRING, "min_id", { .s = args->min_id } },
|
||||
{ _MSTDNT_QUERY_STRING, "max_id", { .s = args.max_id } },
|
||||
{ _MSTDNT_QUERY_STRING, "since_id", { .s = args.since_id } },
|
||||
{ _MSTDNT_QUERY_STRING, "min_id", { .s = args.min_id } },
|
||||
// TODO ANY
|
||||
// TODO ALL
|
||||
// TODO NONE
|
||||
// TODO exclude_visibilities
|
||||
{ _MSTDNT_QUERY_INT, "limit", { .i = args->limit } },
|
||||
{ _MSTDNT_QUERY_INT, "offset", { .i = args->offset } },
|
||||
{ _MSTDNT_QUERY_BOOL, "local", { .b = args->local } },
|
||||
{ _MSTDNT_QUERY_BOOL, "remote", { .b = args->remote } },
|
||||
{ _MSTDNT_QUERY_BOOL, "only_media", { .b = args->only_media } },
|
||||
{ _MSTDNT_QUERY_BOOL, "with_muted", { .b = args->with_muted } },
|
||||
{ _MSTDNT_QUERY_INT, "limit", { .i = args.limit } },
|
||||
{ _MSTDNT_QUERY_INT, "offset", { .i = args.offset } },
|
||||
{ _MSTDNT_QUERY_BOOL, "local", { .b = args.local } },
|
||||
{ _MSTDNT_QUERY_BOOL, "remote", { .b = args.remote } },
|
||||
{ _MSTDNT_QUERY_BOOL, "only_media", { .b = args.only_media } },
|
||||
{ _MSTDNT_QUERY_BOOL, "with_muted", { .b = args.with_muted } },
|
||||
};
|
||||
|
||||
struct mstdnt_request_args req_args = {
|
||||
.url = url,
|
||||
.params_query = params,
|
||||
.params_query_len = _mstdnt_arr_len(params),
|
||||
.params_post = NULL,
|
||||
.params_post_len = 0,
|
||||
.request_type = CURLOPT_HTTPGET,
|
||||
.request_type_custom = NULL,
|
||||
.args = NULL,
|
||||
.callback = mstdnt_statuses_json_callback,
|
||||
};
|
||||
|
||||
return mstdnt_request(data, m_args, cb_request, cb_args, &req_args);
|
||||
}
|
||||
|
||||
static const char* reply_visibility_str(enum mstdnt_reply_visibility vis)
|
||||
static const char*
|
||||
reply_visibility_str(enum mstdnt_reply_visibility vis)
|
||||
{
|
||||
switch (vis)
|
||||
{
|
||||
|
@ -113,35 +108,32 @@ static const char* reply_visibility_str(enum mstdnt_reply_visibility vis)
|
|||
}
|
||||
}
|
||||
|
||||
int mstdnt_timeline_public(mastodont_t* data,
|
||||
struct mstdnt_args* m_args,
|
||||
mstdnt_request_cb_t cb_request,
|
||||
void* cb_args,
|
||||
struct mstdnt_timeline_args* args)
|
||||
int
|
||||
mstdnt_timeline_public(mastodont_t* data,
|
||||
struct mstdnt_args* m_args,
|
||||
mstdnt_request_cb_t cb_request,
|
||||
void* cb_args,
|
||||
struct mstdnt_timeline_args args)
|
||||
{
|
||||
struct _mstdnt_query_param params[] = {
|
||||
{ _MSTDNT_QUERY_BOOL, "local", { .b = args->local } },
|
||||
{ _MSTDNT_QUERY_STRING, "instance", { .s = args->instance } },
|
||||
{ _MSTDNT_QUERY_BOOL, "with_muted", { .b = args->with_muted } },
|
||||
{ _MSTDNT_QUERY_STRING, "reply_visibility", { .s = (char*)reply_visibility_str(args->reply_visibility) } },
|
||||
{ _MSTDNT_QUERY_BOOL, "remote", { .b = args->remote } },
|
||||
{ _MSTDNT_QUERY_BOOL, "only_media", { .b = args->only_media } },
|
||||
{ _MSTDNT_QUERY_STRING, "max_id", { .s = args->max_id } },
|
||||
{ _MSTDNT_QUERY_STRING, "since_id", { .s = args->since_id } },
|
||||
{ _MSTDNT_QUERY_STRING, "min_id", { .s = args->min_id } },
|
||||
{ _MSTDNT_QUERY_INT, "offset", { .i = args->offset } },
|
||||
{ _MSTDNT_QUERY_INT, "limit", { .i = args->limit } },
|
||||
{ _MSTDNT_QUERY_BOOL, "local", { .b = args.local } },
|
||||
{ _MSTDNT_QUERY_STRING, "instance", { .s = args.instance } },
|
||||
{ _MSTDNT_QUERY_BOOL, "with_muted", { .b = args.with_muted } },
|
||||
{ _MSTDNT_QUERY_STRING, "reply_visibility", { .s = (char*)reply_visibility_str(args.reply_visibility) } },
|
||||
{ _MSTDNT_QUERY_BOOL, "remote", { .b = args.remote } },
|
||||
{ _MSTDNT_QUERY_BOOL, "only_media", { .b = args.only_media } },
|
||||
{ _MSTDNT_QUERY_STRING, "max_id", { .s = args.max_id } },
|
||||
{ _MSTDNT_QUERY_STRING, "since_id", { .s = args.since_id } },
|
||||
{ _MSTDNT_QUERY_STRING, "min_id", { .s = args.min_id } },
|
||||
{ _MSTDNT_QUERY_INT, "offset", { .i = args.offset } },
|
||||
{ _MSTDNT_QUERY_INT, "limit", { .i = args.limit } },
|
||||
};
|
||||
|
||||
struct mstdnt_request_args req_args = {
|
||||
.url = "api/v1/timelines/public",
|
||||
.params_query = params,
|
||||
.params_query_len = _mstdnt_arr_len(params),
|
||||
.params_post = NULL,
|
||||
.params_post_len = 0,
|
||||
.request_type = CURLOPT_HTTPGET,
|
||||
.request_type_custom = NULL,
|
||||
.args = NULL,
|
||||
.callback = mstdnt_statuses_json_callback,
|
||||
};
|
||||
|
||||
|
@ -149,30 +141,27 @@ int mstdnt_timeline_public(mastodont_t* data,
|
|||
}
|
||||
|
||||
|
||||
int mstdnt_timeline_direct(mastodont_t* data,
|
||||
struct mstdnt_args* m_args,
|
||||
mstdnt_request_cb_t cb_request,
|
||||
void* cb_args,
|
||||
struct mstdnt_timeline_args* args)
|
||||
int
|
||||
mstdnt_timeline_direct(mastodont_t* data,
|
||||
struct mstdnt_args* m_args,
|
||||
mstdnt_request_cb_t cb_request,
|
||||
void* cb_args,
|
||||
struct mstdnt_timeline_args args)
|
||||
{
|
||||
struct _mstdnt_query_param params[] = {
|
||||
{ _MSTDNT_QUERY_STRING, "max_id", { .s = args->max_id } },
|
||||
{ _MSTDNT_QUERY_STRING, "since_id", { .s = args->since_id } },
|
||||
{ _MSTDNT_QUERY_STRING, "min_id", { .s = args->min_id } },
|
||||
{ _MSTDNT_QUERY_INT, "limit", { .i = args->limit } },
|
||||
{ _MSTDNT_QUERY_INT, "offset", { .i = args->offset } },
|
||||
{ _MSTDNT_QUERY_BOOL, "with_muted", { .b = args->with_muted } },
|
||||
{ _MSTDNT_QUERY_STRING, "max_id", { .s = args.max_id } },
|
||||
{ _MSTDNT_QUERY_STRING, "since_id", { .s = args.since_id } },
|
||||
{ _MSTDNT_QUERY_STRING, "min_id", { .s = args.min_id } },
|
||||
{ _MSTDNT_QUERY_INT, "limit", { .i = args.limit } },
|
||||
{ _MSTDNT_QUERY_INT, "offset", { .i = args.offset } },
|
||||
{ _MSTDNT_QUERY_BOOL, "with_muted", { .b = args.with_muted } },
|
||||
};
|
||||
|
||||
struct mstdnt_request_args req_args = {
|
||||
.url = "api/v1/timelines/direct",
|
||||
.params_query = params,
|
||||
.params_query_len = _mstdnt_arr_len(params),
|
||||
.params_post = NULL,
|
||||
.params_post_len = 0,
|
||||
.request_type = CURLOPT_HTTPGET,
|
||||
.request_type_custom = NULL,
|
||||
.args = NULL,
|
||||
.callback = mstdnt_statuses_json_callback,
|
||||
};
|
||||
|
||||
|
@ -180,35 +169,32 @@ int mstdnt_timeline_direct(mastodont_t* data,
|
|||
}
|
||||
|
||||
|
||||
int mstdnt_timeline_home(mastodont_t* data,
|
||||
struct mstdnt_args* m_args,
|
||||
mstdnt_request_cb_t cb_request,
|
||||
void* cb_args,
|
||||
struct mstdnt_timeline_args* args)
|
||||
int
|
||||
mstdnt_timeline_home(mastodont_t* data,
|
||||
struct mstdnt_args* m_args,
|
||||
mstdnt_request_cb_t cb_request,
|
||||
void* cb_args,
|
||||
struct mstdnt_timeline_args args)
|
||||
{
|
||||
struct _mstdnt_query_param params[] = {
|
||||
{ _MSTDNT_QUERY_BOOL, "local", { .b = args->local } },
|
||||
{ _MSTDNT_QUERY_BOOL, "remote", { .b = args->remote } },
|
||||
{ _MSTDNT_QUERY_INT, "only_media", { .i = args->only_media } },
|
||||
{ _MSTDNT_QUERY_INT, "with_muted", { .i = args->with_muted } },
|
||||
/* { _MSTDNT_QUERY_INT, "exclude_visibilities", { .i = args->with_muted } }, */
|
||||
{ _MSTDNT_QUERY_STRING, "reply_visibility", { .s = (char*)reply_visibility_str(args->reply_visibility) } },
|
||||
{ _MSTDNT_QUERY_STRING, "max_id", { .s = args->max_id } },
|
||||
{ _MSTDNT_QUERY_STRING, "since_id", { .s = args->since_id } },
|
||||
{ _MSTDNT_QUERY_STRING, "min_id", { .s = args->min_id } },
|
||||
{ _MSTDNT_QUERY_INT, "limit", { .i = args->limit } },
|
||||
{ _MSTDNT_QUERY_INT, "offset", { .i = args->offset } },
|
||||
{ _MSTDNT_QUERY_BOOL, "local", { .b = args.local } },
|
||||
{ _MSTDNT_QUERY_BOOL, "remote", { .b = args.remote } },
|
||||
{ _MSTDNT_QUERY_INT, "only_media", { .i = args.only_media } },
|
||||
{ _MSTDNT_QUERY_INT, "with_muted", { .i = args.with_muted } },
|
||||
/* { _MSTDNT_QUERY_INT, "exclude_visibilities", { .i = args.with_muted } }, */
|
||||
{ _MSTDNT_QUERY_STRING, "reply_visibility", { .s = (char*)reply_visibility_str(args.reply_visibility) } },
|
||||
{ _MSTDNT_QUERY_STRING, "max_id", { .s = args.max_id } },
|
||||
{ _MSTDNT_QUERY_STRING, "since_id", { .s = args.since_id } },
|
||||
{ _MSTDNT_QUERY_STRING, "min_id", { .s = args.min_id } },
|
||||
{ _MSTDNT_QUERY_INT, "limit", { .i = args.limit } },
|
||||
{ _MSTDNT_QUERY_INT, "offset", { .i = args.offset } },
|
||||
};
|
||||
|
||||
struct mstdnt_request_args req_args = {
|
||||
.url = "api/v1/timelines/home",
|
||||
.params_query = params,
|
||||
.params_query_len = _mstdnt_arr_len(params),
|
||||
.params_post = NULL,
|
||||
.params_post_len = 0,
|
||||
.request_type = CURLOPT_HTTPGET,
|
||||
.request_type_custom = NULL,
|
||||
.args = NULL,
|
||||
.callback = mstdnt_statuses_json_callback,
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue