Notification args
FossilOrigin-Name: e27bedab647bd3113e2641810c0e2e61ba63c99389bb04e526ad57a852492bd6
This commit is contained in:
parent
07e86dfd82
commit
98e9359e64
5 changed files with 51 additions and 45 deletions
|
@ -18,6 +18,7 @@
|
|||
#include <stdint.h>
|
||||
|
||||
/* uint16 */
|
||||
#define MSTDNT_NOTIFICATION_NOP 0
|
||||
#define MSTDNT_NOTIFICATION_FOLLOW (1<<0)
|
||||
#define MSTDNT_NOTIFICATION_FOLLOW_REQUEST (1<<1)
|
||||
#define MSTDNT_NOTIFICATION_MENTION (1<<2)
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
#include "mastodont_account.h"
|
||||
#include "mastodont_status.h"
|
||||
#include "mastodont_args.h"
|
||||
#include "mastodont_notif_types.h"
|
||||
#include "mastodont_visibility_types.h"
|
||||
#include <cjson/cJSON.h>
|
||||
|
||||
struct mstdnt_notification
|
||||
|
@ -27,11 +29,28 @@ struct mstdnt_notification
|
|||
char* created_at;
|
||||
struct mstdnt_account* account;
|
||||
struct mstdnt_status* status;
|
||||
enum mstdnt_notification_type type;
|
||||
mstdnt_notification_t type;
|
||||
};
|
||||
|
||||
struct mstdnt_get_notifications_args
|
||||
{
|
||||
/* Bitmask */
|
||||
mstdnt_notification_t exclude_types;
|
||||
char* account_id;
|
||||
/* Bitmask */
|
||||
mstdnt_visibility_t exclude_visibilities;
|
||||
/* Bitmask */
|
||||
mstdnt_visibility_t include_types;
|
||||
mstdnt_bool with_muted;
|
||||
char* max_id;
|
||||
char* min_id;
|
||||
char* since_id;
|
||||
int offset;
|
||||
int limit;
|
||||
};
|
||||
|
||||
int mastodont_get_notifications(mastodont_t* data,
|
||||
struct mstdnt_args* args,
|
||||
struct mstdnt_get_notifications_args* args,
|
||||
struct mstdnt_storage* storage,
|
||||
struct mstdnt_notification** notifs,
|
||||
size_t* size);
|
||||
|
|
|
@ -28,18 +28,9 @@
|
|||
#include "mastodont_tag.h"
|
||||
#include "mastodont_account.h"
|
||||
#include "mastodont_pleroma.h"
|
||||
#include "mastodont_visibility_types.h"
|
||||
/* Status: Complete, not implemented */
|
||||
|
||||
enum mstdnt_status_visibility
|
||||
{
|
||||
MSTDNT_VISIBILITY_PUBLIC,
|
||||
MSTDNT_VISIBILITY_UNLISTED,
|
||||
MSTDNT_VISIBILITY_PRIVATE,
|
||||
MSTDNT_VISIBILITY_DIRECT,
|
||||
MSTDNT_VISIBILITY_LIST,
|
||||
MSTDNT_VISIBILITY_LOCAL
|
||||
};
|
||||
|
||||
struct mstdnt_status
|
||||
{
|
||||
char* id;
|
||||
|
@ -47,7 +38,7 @@ struct mstdnt_status
|
|||
char* created_at;
|
||||
struct mstdnt_account account;
|
||||
char* content;
|
||||
enum mstdnt_status_visibility visibility;
|
||||
mstdnt_visibility_t visibility;
|
||||
mstdnt_bool sensitive;
|
||||
char* spoiler_text;
|
||||
struct mstdnt_attachment* media_attachments;
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#define MASTODONT_VISIBILITY_TYPES_H
|
||||
#include <stdint.h>
|
||||
|
||||
#define MSTDNT_VISIBILITY_NOOP 0
|
||||
#define MSTDNT_VISIBILITY_PUBLIC (1<<0)
|
||||
#define MSTDNT_VISIBILITY_UNLISTED (1<<1)
|
||||
#define MSTDNT_VISIBILITY_PRIVATE (1<<2)
|
||||
|
|
|
@ -18,26 +18,31 @@
|
|||
#include <mastodont_fetch.h>
|
||||
#include <mastodont_json_helper.h>
|
||||
#include <mastodont_query.h>
|
||||
#if 0
|
||||
|
||||
int mstdnt_notification_from_json(struct mstdnt_notification* notif, cJSON* js)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int mastodont_get_notifications(mastodont_t* data,
|
||||
struct mstdnt_get_notifications_args* args,
|
||||
struct mstdnt_storage* storage,
|
||||
struct mstdnt_notification** notifs,
|
||||
size_t* size)
|
||||
{
|
||||
int res = 0;
|
||||
struct mstdnt_fetch_results results = { 0 };
|
||||
struct _mstdnt_statuses_cb_args cb_args = { statuses, size };
|
||||
|
||||
/* Default args */
|
||||
storage->needs_cleanup = 0;
|
||||
|
||||
union param_value u_account_id, u_with_muted, u_max_id,
|
||||
u_min_id, u_since_id, u_offset, u_limit;
|
||||
union param_value u_exclude_types, u_account_id, u_exclude_visibilities,
|
||||
u_include_types, u_with_muted, u_max_id, u_min_id,
|
||||
u_since_id, u_offset, u_limit;
|
||||
/* TODO Arrays of excludes, includes */
|
||||
u_account_id.s = args->account_id;
|
||||
u_with_muted.i = args->with_muted;
|
||||
u_max_id.s = args->max_id;
|
||||
u_min_id.s = args->min_id;
|
||||
u_since_id.s = args->since_id;
|
||||
u_min_id.s = args->min_id;
|
||||
u_offset.i = args->offset;
|
||||
u_limit.i = args->limit;
|
||||
|
||||
|
@ -45,32 +50,21 @@ int mastodont_get_notifications(mastodont_t* data,
|
|||
{ _MSTDNT_QUERY_STRING, "account_id", u_account_id },
|
||||
{ _MSTDNT_QUERY_INT, "with_muted", u_with_muted },
|
||||
{ _MSTDNT_QUERY_STRING, "max_id", u_max_id },
|
||||
{ _MSTDNT_QUERY_STRING, "min_id", u_min_id },
|
||||
{ _MSTDNT_QUERY_STRING, "since_id", u_since_id },
|
||||
{ _MSTDNT_QUERY_STRING, "min_id", u_min_id },
|
||||
{ _MSTDNT_QUERY_INT, "offset", u_offset },
|
||||
{ _MSTDNT_QUERY_INT, "limit", u_limit },
|
||||
};
|
||||
|
||||
char* post = _mstdnt_query_string(data, NULL, params, _mstdnt_arr_len(params));
|
||||
|
||||
curl_easy_setopt(data->curl, CURLOPT_POSTFIELDS, post);
|
||||
|
||||
if (mastodont_fetch_curl(data, "api/v1/apps", &results, CURLOPT_POST) != CURLE_OK)
|
||||
{
|
||||
res = 1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* res = mstdnt_read_app_result(storage, &results, app);*/
|
||||
|
||||
cleanup_fetch:
|
||||
mastodont_fetch_results_cleanup(&results);
|
||||
cleanup:
|
||||
free(post);
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
int mstdnt_load_notification_from_json(struct mstdnt_notification* notif, cJSON* js)
|
||||
{
|
||||
|
||||
struct mastodont_request_args req_args = {
|
||||
storage,
|
||||
"api/v1/notifications",
|
||||
params, _mstdnt_arr_len(params),
|
||||
NULL, 0,
|
||||
CURLOPT_HTTPGET,
|
||||
&cb_args,
|
||||
_mstdnt_statuses_result_callback,
|
||||
};
|
||||
|
||||
return mastodont_request(data, &req_args);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue