Lists, some emoji structs

FossilOrigin-Name: 7fdec025775f8dbc5b4952cb8257e39d4a6a7f12cf8c2950aa15f6737c49c18d
This commit is contained in:
me@ow.nekobit.net 2022-02-28 17:25:53 +00:00
parent eebf29d7bf
commit 7680cfa4be
6 changed files with 107 additions and 3 deletions

View file

@ -29,5 +29,12 @@ struct mstdnt_emoji
char* category;
};
struct mstdnt_emoji_react
{
char* name;
size_t count;
mstdnt_bool me;
/* TODO Accounts */
};
#endif /* MASTODONT_EMOJI */

View file

@ -22,7 +22,7 @@ struct _mstdnt_val_ref
{
const char* key;
void* val;
void (*handle)(cJSON*, void*;)
void (*handle)(cJSON*, void*);
};
int _mstdnt_json_init(cJSON** root,

View file

@ -0,0 +1,28 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifdef MASTODONT_PLEROMA
#define MASTODONT_PLEROMA
#include <mastodont_types.h>
#include <mastodont_emojis.h>
struct mstdnt_pleroma
{
/* content */
int conversation_id;
int direct_conversation_id;
};
#endif /* MASTODONT_PLEROMA */

View file

@ -28,6 +28,20 @@ struct mstdnt_timeline_public_args {
int limit;
};
struct mstdnt_timeline_list_args {
char* max_id;
char* since_id;
char* min_id;
int limit;
};
int mastodont_timeline_list(mastodont_t* data,
char* list_id,
struct mstdnt_timeline_list_args* args,
struct mstdnt_storage* storage,
struct mstdnt_status* statuses[],
size_t* size);
int mastodont_timeline_public(mastodont_t* data,
struct mstdnt_timeline_public_args* args,
struct mstdnt_storage* storage,

View file

@ -44,8 +44,8 @@ void _mstdnt_val_attachments_call(cJSON* v, void* _type)
cJSON* v_array = v->child;
cJSON* att = NULL;
size_t size = cJSON_GetArraySize(v_array);
args->size = size;
size_t size = cJSON_GetArraySize(v);
*(args->size) = size;
/* No attachments, ignore */
if (size == 0)
{

View file

@ -19,6 +19,61 @@
#include "mastodont_timeline.h"
#include "mastodont_query.h"
int mastodont_timeline_list(mastodont_t* data,
char* list_id,
struct mstdnt_timeline_list_args* args,
struct mstdnt_storage* storage,
struct mstdnt_status* statuses[],
size_t* size)
{
char url[MSTDNT_URLSIZE];
int res;
struct mstdnt_fetch_results results = { 0 };
snprintf(url, MSTDNT_URLSIZE, "api/v1/timelines/list/%s", list_id);
/* Default args */
struct mstdnt_timeline_list_args _args;
if (args == NULL)
{
_args.max_id = NULL;
_args.since_id = NULL;
_args.min_id = NULL;
_args.limit = 20;
args = &_args;
}
storage->needs_cleanup = 0;
union param_value u_local, u_remote, u_only_media,
u_max_id, u_since_id, u_min_id, u_limit;
u_max_id.s = args->max_id;
u_since_id.s = args->since_id;
u_min_id.s = args->min_id;
u_limit.i = args->limit;
struct _mstdnt_query_param params[] = {
{ _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 },
};
char* url_query = _mstdnt_query_string(url, params, _mstdnt_arr_len(params));
if (mastodont_fetch_curl(data, url_query, &results, CURLOPT_HTTPGET) != CURLE_OK)
{
res = 1;
goto cleanup;
}
res = mstdnt_load_statuses_from_result(statuses, storage, &results, size);
mastodont_fetch_results_cleanup(&results);
cleanup:
free(url_query);
return res;
}
int mastodont_timeline_public(mastodont_t* data,
struct mstdnt_timeline_public_args* args,
struct mstdnt_storage* storage,