get_account_statuses params

FossilOrigin-Name: 70b9cd55ab7402d0cddb79e2b8078f5b434cf21805940df58f75010820413ede
This commit is contained in:
me@ow.nekobit.net 2022-04-27 19:16:15 +00:00
parent 71a358001c
commit 40da84d46d
7 changed files with 57 additions and 7 deletions

View file

@ -1,5 +1,5 @@
CC ?= cc
CFLAGS = -g -ansi -Wall -Werror=implicit-function-declaration -I ./include/ `pkg-config --cflags libcjson`
CFLAGS = -g -ansi -Wall -Werror=implicit-function-declaration -Wno-unused-variable -I ./include/ `pkg-config --cflags libcjson`
SRC = $(wildcard src/*.c)
OBJ = $(patsubst %.c,%.o,$(SRC))
TARGET = libmastodont.a # shared

View file

@ -21,4 +21,4 @@
int mstdnt_check_error(struct mstdnt_fetch_results* result,
struct mstdnt_storage* storage);
#endif // MASTODONT_ERROR_H
#endif /* MASTODONT_ERROR_H */

View file

@ -75,6 +75,21 @@ struct mstdnt_status
mstdnt_bool pinned;
};
struct mstdnt_account_statuses_args
{
mstdnt_bool pinned;
mstdnt_bool only_media;
mstdnt_bool with_muted;
mstdnt_bool exclude_reblogs;
mstdnt_bool exclude_replies;
char* tagged;
char* max_id;
char* min_id;
char* since_id;
int offset;
int limit;
};
void mstdnt_cleanup_statuses(struct mstdnt_status* statuses, size_t s);
void mstdnt_cleanup_status(struct mstdnt_status* status);
@ -109,7 +124,7 @@ int mstdnt_status_context_from_json(struct mstdnt_fetch_results* results,
int mastodont_get_account_statuses(mastodont_t* data,
char* id,
struct mstdnt_args* args,
struct mstdnt_account_statuses_args* args,
struct mstdnt_storage* storage,
struct mstdnt_status* statuses[],
size_t* size);

View file

@ -91,7 +91,7 @@ static int mstdnt_token_result_callback(struct mstdnt_fetch_results* results,
struct mstdnt_storage* storage,
void* args)
{
mstdnt_token_result(results, storage, args);
return mstdnt_token_result(results, storage, args);
}
int mastodont_register_app(mastodont_t* data,

View file

@ -43,6 +43,8 @@ int mstdnt_status_pleroma_from_json(struct mstdnt_status_pleroma* pleroma, cJSON
{
_mstdnt_key_val_ref(v, refs, _mstdnt_arr_len(refs));
}
return 0;
}
void _mstdnt_val_status_pleroma_call(cJSON* v, void* _type)

View file

@ -103,6 +103,8 @@ int mstdnt_relationships_result(struct mstdnt_fetch_results* results,
{
mstdnt_relationship_json((*relationships) + i++, rel_j_list->child);
}
return 0;
}
int mstdnt_relationship_result(struct mstdnt_fetch_results* results,

View file

@ -156,10 +156,9 @@ int _mstdnt_statuses_result_callback(struct mstdnt_fetch_results* results,
return mstdnt_statuses_from_result(storage, results, args->statuses, args->size);
}
/* TODO Still need to handle get params */
int mastodont_get_account_statuses(mastodont_t* data,
char* id,
struct mstdnt_args* args,
struct mstdnt_account_statuses_args* args,
struct mstdnt_storage* storage,
struct mstdnt_status* statuses[],
size_t* size)
@ -168,11 +167,41 @@ int mastodont_get_account_statuses(mastodont_t* data,
struct _mstdnt_statuses_cb_args cb_args = { statuses, size };
snprintf(url, MSTDNT_URLSIZE, "api/v1/accounts/%s/statuses", id);
union param_value u_pinned, u_tagged, u_only_media,
u_with_muted, u_exclude_reblogs, u_exclude_replies,
u_exclude_visibilities, u_max_id, u_min_id,
u_since_id, u_offset, u_limit;
u_pinned.i = args->pinned;
u_only_media.i = args->only_media;
u_with_muted.i = args->with_muted;
u_exclude_reblogs.i = args->exclude_reblogs;
u_exclude_replies.i = args->exclude_replies;
u_tagged.s = args->tagged;
u_max_id.s = args->max_id;
u_min_id.s = args->min_id;
u_since_id.s = args->since_id;
u_offset.i = args->offset;
u_limit.i = args->limit;
struct _mstdnt_query_param params[] = {
{ _MSTDNT_QUERY_INT, "pinned", u_pinned },
{ _MSTDNT_QUERY_STRING, "tagged", u_tagged },
{ _MSTDNT_QUERY_INT, "only_media", u_only_media },
{ _MSTDNT_QUERY_INT, "with_muted", u_with_muted },
{ _MSTDNT_QUERY_INT, "exclude_reblogs", u_exclude_reblogs },
{ _MSTDNT_QUERY_INT, "exclude_replies", u_exclude_replies },
{ _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 = {
storage,
url,
NULL, 0,
NULL, 0, /* TODO */
params, _mstdnt_arr_len(params),
CURLOPT_HTTPGET,
&cb_args,
_mstdnt_statuses_result_callback
@ -388,6 +417,8 @@ int mstdnt_status_context_from_json(struct mstdnt_fetch_results* results,
}
}
}
return 0;
}
int _mstdnt_status_context_from_result_callback(struct mstdnt_fetch_results* results,