Search accounts progress

FossilOrigin-Name: ce0ecdec72d0d86affd0367a0283d6176602f720822c37e90dfda1ef7cf3b9b8
This commit is contained in:
me@ow.nekobit.net 2022-05-05 03:51:32 +00:00
parent 486e8d1623
commit 5e0d1949a5
2 changed files with 46 additions and 1 deletions

View file

@ -23,6 +23,10 @@
#include "session.h"
#include "l10n.h"
#define ACCOUNT_NOP 0
#define ACCOUNT_ACTION_BTNS (1<<0)
#define ACCOUNT_SUMMARY (1<<1)
enum account_tab
{
ACCT_TAB_STATUSES,
@ -49,6 +53,16 @@ struct account_page
struct mstdnt_relationship* relationship;
};
char* construct_account(mastodont_t* api,
struct mstdnt_account* account,
int* size,
uint8_t flags);
char* construct_accounts(mastodont_t* api,
struct mstdnt_account* accounts,
size_t size,
uint8_t flags,
size_t* ret_size);
size_t construct_account_page(char** result, struct account_page* page, char* content);
char* load_account_page(mastodont_t* api,

View file

@ -100,7 +100,38 @@ void content_search_statuses(struct session* ssn, mastodont_t* api, char** data)
void content_search_accounts(struct session* ssn, mastodont_t* api, char** data)
{
search_page(ssn, api, SEARCH_ACCOUNTS, "accounts");
char* accounts_html;
struct mstdnt_storage storage = { 0 };
struct mstdnt_search_args args = {
.account_id = NULL,
.type = MSTDNT_SEARCH_STATUSES,
.resolve = 0,
.following = 0,
.with_relationships = 0,
.max_id = NULL,
.min_id = NULL,
.since_id = NULL,
.offset = 0,
.limit = 20,
};
struct mstdnt_search_results results = { 0 };
if (mastodont_search(api,
ssn->query.query,
&storage,
&args,
&results) == 0)
{
accounts_html = construct_accounts(api, results.accts, results.accts_len, 0, NULL);
if (!accounts_html)
accounts_html = construct_error("No accounts", E_ERROR, 1, NULL);
}
else
accounts_html = construct_error("An error occured.", E_ERROR, 1, NULL);
search_page(ssn, api, SEARCH_ACCOUNTS, STR_NULL_EMPTY(accounts_html));
if (accounts_html) free(accounts_html);
}
void content_search_hashtags(struct session* ssn, mastodont_t* api, char** data)