From 38ecda1414d299bc389ce2c54ea0ddea6954e005 Mon Sep 17 00:00:00 2001 From: "me@ow.nekobit.net" Date: Thu, 5 May 2022 03:24:06 +0000 Subject: [PATCH] Accounts search FossilOrigin-Name: 1df3d2557d8822dc537f749fed0d46f25e36e7804210c179fbd4f43b65b1c669 --- include/mastodont_account.h | 4 ++++ src/account.c | 5 ++++- src/search.c | 4 ++++ src/status.c | 2 +- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/mastodont_account.h b/include/mastodont_account.h index eedc073..c89923c 100644 --- a/include/mastodont_account.h +++ b/include/mastodont_account.h @@ -68,6 +68,10 @@ int mstdnt_account_action(mastodont_t* data, struct mstdnt_relationship* rel, char* url_str); +int mstdnt_accounts_json(struct mstdnt_account* accounts[], + size_t* size, + cJSON* js); + #define MSTDNT_ACCOUNT_ACTION_DECL(type) int mastodont_##type##_account(mastodont_t* data, char* id, struct mstdnt_storage* storage, struct mstdnt_relationship* relationship) #define MSTDNT_ACCOUNT_ACTION_FUNC_URL(action) { \ return mstdnt_account_action(data, id, storage, relationship, "api/v1/accounts/%s/" action); \ diff --git a/src/account.c b/src/account.c index 502b6bb..f3010d9 100644 --- a/src/account.c +++ b/src/account.c @@ -19,7 +19,7 @@ #include #include #include - +#include void _mstdnt_val_account_call(cJSON* v, void* _type) { struct mstdnt_account* type = _type; @@ -57,6 +57,9 @@ int mstdnt_account_from_result(struct mstdnt_fetch_results* results, return 0; } +// GENERATE mstdnt_statuses_json +GENERATE_JSON_ARRAY_FUNC(mstdnt_accounts_json, struct mstdnt_account, mstdnt_account_from_json) + int mstdnt_accounts_result(struct mstdnt_fetch_results* results, struct mstdnt_storage* storage, struct mstdnt_account* accts[], diff --git a/src/search.c b/src/search.c index 7917098..92301fc 100644 --- a/src/search.c +++ b/src/search.c @@ -49,6 +49,10 @@ int mstdnt_search_from_result(struct mstdnt_storage* storage, mstdnt_statuses_json(&(search_results->statuses), &(search_results->statuses_len), statuses); + + mstdnt_accounts_json(&(search_results->accts), + &(search_results->accts_len), + accounts); return 0; } diff --git a/src/status.c b/src/status.c index 9631779..bfa9ad2 100644 --- a/src/status.c +++ b/src/status.c @@ -131,7 +131,7 @@ int mstdnt_statuses_from_result(struct mstdnt_storage* storage, return mstdnt_statuses_json(statuses, size, root); } -// GENERATE mstdnt_statuses_from_json +// GENERATE mstdnt_statuses_json GENERATE_JSON_ARRAY_FUNC(mstdnt_statuses_json, struct mstdnt_status, mstdnt_status_from_json) int _mstdnt_statuses_result_callback(struct mstdnt_fetch_results* results,