Get muted, blocks, followers, following
FossilOrigin-Name: 7cfafc700ed0ff149885a3cea84fd49ef3891926a0d93244db51a65fdbe26e40
This commit is contained in:
parent
ce31718042
commit
a264bfafb3
4 changed files with 118 additions and 5 deletions
|
@ -24,7 +24,7 @@
|
|||
#define MSTDNT_LOOKUP_ACCT 0
|
||||
#define MSTDNT_LOOKUP_ID 1
|
||||
|
||||
struct mstdnt_account_args
|
||||
struct _mstdnt_accounts_args
|
||||
{
|
||||
struct mstdnt_account** acct;
|
||||
size_t* size;
|
||||
|
@ -66,6 +66,16 @@ struct mstdnt_account
|
|||
char* mute_expires_at;
|
||||
};
|
||||
|
||||
struct mstdnt_account_args
|
||||
{
|
||||
char* max_id;
|
||||
char* min_id;
|
||||
char* since_id;
|
||||
int offset;
|
||||
int limit;
|
||||
int with_relationships; // mastodont_get_mutes
|
||||
};
|
||||
|
||||
int mstdnt_account_action(mastodont_t* data,
|
||||
char* id,
|
||||
struct mstdnt_storage* storage,
|
||||
|
@ -99,6 +109,32 @@ int mastodont_get_account(mastodont_t* data,
|
|||
struct mstdnt_account* acct,
|
||||
struct mstdnt_storage* storage);
|
||||
|
||||
int mastodont_get_blocks(mastodont_t* data,
|
||||
struct mstdnt_account_args* args,
|
||||
struct mstdnt_storage* storage,
|
||||
struct mstdnt_account* accts[],
|
||||
size_t* accts_len);
|
||||
|
||||
int mastodont_get_mutes(mastodont_t* data,
|
||||
struct mstdnt_account_args* args,
|
||||
struct mstdnt_storage* storage,
|
||||
struct mstdnt_account* accts[],
|
||||
size_t* accts_len);
|
||||
|
||||
int mastodont_get_followers(mastodont_t* data,
|
||||
char* id,
|
||||
struct mstdnt_account_args* args,
|
||||
struct mstdnt_storage* storage,
|
||||
struct mstdnt_account* accts[],
|
||||
size_t* accts_len);
|
||||
|
||||
int mastodont_get_following(mastodont_t* data,
|
||||
char* id,
|
||||
struct mstdnt_account_args* args,
|
||||
struct mstdnt_storage* storage,
|
||||
struct mstdnt_account* accts[],
|
||||
size_t* accts_len);
|
||||
|
||||
int mstdnt_account_json(struct mstdnt_account* acct, cJSON* js);
|
||||
int mstdnt_account_json_callback(cJSON* json, void* _args);
|
||||
int mstdnt_accounts_json_callback(cJSON* json, void* _args);
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
enum mstdnt_reply_visibility
|
||||
{
|
||||
MSTDNT_REPLY_VIS_NONE,
|
||||
MSTDNT_REPLY_VIS_NONE = 0,
|
||||
MSTDNT_REPLY_VIS_SELF,
|
||||
MSTDNT_REPLY_VIS_FOLLOWING,
|
||||
};
|
||||
|
|
|
@ -49,10 +49,87 @@ int mstdnt_account_json_callback(cJSON* json, void* _args)
|
|||
|
||||
int mstdnt_accounts_json_callback(cJSON* json, void* _args)
|
||||
{
|
||||
struct mstdnt_account_args* args = _args;
|
||||
struct _mstdnt_accounts_args* args = _args;
|
||||
return mstdnt_accounts_json(args->acct, args->size, json);
|
||||
}
|
||||
|
||||
static int mastodont_get_accounts_query(char* url,
|
||||
mastodont_t* data,
|
||||
struct mstdnt_account_args* args,
|
||||
struct mstdnt_storage* storage,
|
||||
struct mstdnt_account* accts[],
|
||||
size_t* accts_len)
|
||||
{
|
||||
struct _mstdnt_accounts_args _args = {
|
||||
accts,
|
||||
accts_len,
|
||||
};
|
||||
|
||||
struct _mstdnt_query_param params[] = {
|
||||
{ _MSTDNT_QUERY_STRING, "max_id", { .s = args->max_id } },
|
||||
{ _MSTDNT_QUERY_STRING, "min_id", { .s = args->min_id } },
|
||||
{ _MSTDNT_QUERY_STRING, "since_id", { .s = args->since_id } },
|
||||
{ _MSTDNT_QUERY_INT, "offset", { .i = args->offset } },
|
||||
{ _MSTDNT_QUERY_INT, "limit", { .i = args->limit } },
|
||||
{ _MSTDNT_QUERY_INT, "with_relationships", { .i = args->with_relationships } },
|
||||
};
|
||||
|
||||
struct mastodont_request_args req_args = {
|
||||
storage,
|
||||
url,
|
||||
NULL, 0,
|
||||
NULL, 0,
|
||||
CURLOPT_HTTPGET,
|
||||
NULL,
|
||||
&_args,
|
||||
mstdnt_accounts_json_callback,
|
||||
};
|
||||
|
||||
return mastodont_request(data, &req_args);
|
||||
}
|
||||
|
||||
int mastodont_get_followers(mastodont_t* data,
|
||||
char* id,
|
||||
struct mstdnt_account_args* args,
|
||||
struct mstdnt_storage* storage,
|
||||
struct mstdnt_account* accts[],
|
||||
size_t* accts_len)
|
||||
{
|
||||
char url[MSTDNT_URLSIZE];
|
||||
snprintf(url, MSTDNT_URLSIZE, "api/v1/accounts/%s/followers", id);
|
||||
return mastodont_get_accounts_query(url, data, args, storage, accts, accts_len);
|
||||
}
|
||||
|
||||
int mastodont_get_following(mastodont_t* data,
|
||||
char* id,
|
||||
struct mstdnt_account_args* args,
|
||||
struct mstdnt_storage* storage,
|
||||
struct mstdnt_account* accts[],
|
||||
size_t* accts_len)
|
||||
{
|
||||
char url[MSTDNT_URLSIZE];
|
||||
snprintf(url, MSTDNT_URLSIZE, "api/v1/accounts/%s/following", id);
|
||||
return mastodont_get_accounts_query(url, data, args, storage, accts, accts_len);
|
||||
}
|
||||
|
||||
int mastodont_get_blocks(mastodont_t* data,
|
||||
struct mstdnt_account_args* args,
|
||||
struct mstdnt_storage* storage,
|
||||
struct mstdnt_account* accts[],
|
||||
size_t* accts_len)
|
||||
{
|
||||
return mastodont_get_accounts_query("api/v1/blocks", data, args, storage, accts, accts_len);
|
||||
}
|
||||
|
||||
int mastodont_get_mutes(mastodont_t* data,
|
||||
struct mstdnt_account_args* args,
|
||||
struct mstdnt_storage* storage,
|
||||
struct mstdnt_account* accts[],
|
||||
size_t* accts_len)
|
||||
{
|
||||
return mastodont_get_accounts_query("api/v1/mutes", data, args, storage, accts, accts_len);
|
||||
}
|
||||
|
||||
int mastodont_get_account(mastodont_t* data,
|
||||
int lookup, /* TODO move into separate function for consistancy */
|
||||
char* id,
|
||||
|
|
|
@ -389,7 +389,7 @@ int mastodont_status_favourited_by(mastodont_t* data,
|
|||
struct mstdnt_account* accounts[],
|
||||
size_t* accts_len)
|
||||
{
|
||||
struct mstdnt_account_args args = {
|
||||
struct _mstdnt_accounts_args args = {
|
||||
accounts,
|
||||
accts_len,
|
||||
};
|
||||
|
@ -416,7 +416,7 @@ int mastodont_status_reblogged_by(mastodont_t* data,
|
|||
struct mstdnt_account* accounts[],
|
||||
size_t* accts_len)
|
||||
{
|
||||
struct mstdnt_account_args args = {
|
||||
struct _mstdnt_accounts_args args = {
|
||||
accounts,
|
||||
accts_len,
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue