_mstdnt_val_account,status callbacks
FossilOrigin-Name: e0c46acb91e7368377bedf0c33748c1e8554677ae39d4c8fee9084fabe89ecfa
This commit is contained in:
parent
8afe52017c
commit
84e9f16c48
7 changed files with 27 additions and 9 deletions
|
@ -69,5 +69,6 @@ int mastodont_get_account(mastodont_t* data,
|
|||
|
||||
int mstdnt_account_from_json(struct mstdnt_account* status, cJSON* js);
|
||||
|
||||
void _mstdnt_val_account_call(cJSON* v, void* _type);
|
||||
|
||||
#endif /* MASTODONT_ACCOUNT */
|
||||
|
|
|
@ -35,7 +35,7 @@ struct mstdnt_status_pleroma
|
|||
};
|
||||
|
||||
void cleanup_status_pleroma(struct mstdnt_status_pleroma* pleroma);
|
||||
int mstdnt_load_status_pleroma_from_json(struct mstdnt_status_pleroma* pleroma, cJSON* js);
|
||||
int mstdnt_status_pleroma_from_json(struct mstdnt_status_pleroma* pleroma, cJSON* js);
|
||||
void _mstdnt_val_status_pleroma_call(cJSON* v, void* _type);
|
||||
|
||||
#endif /* MASTODONT_PLEROMA */
|
||||
|
|
|
@ -88,6 +88,8 @@ int mstdnt_status_from_result(struct mstdnt_fetch_results* results,
|
|||
|
||||
int mstdnt_status_from_json(struct mstdnt_status* status, cJSON* js);
|
||||
|
||||
void _mstdnt_val_status_call(cJSON* v, void* _type);
|
||||
|
||||
int mstdnt_status_context_from_result(struct mstdnt_fetch_results* results,
|
||||
struct mstdnt_storage* storage,
|
||||
struct mstdnt_status* statuses_before[],
|
||||
|
|
|
@ -24,6 +24,13 @@ struct mstdnt_account_args
|
|||
size_t* size;
|
||||
};
|
||||
|
||||
void _mstdnt_val_account_call(cJSON* v, void* _type)
|
||||
{
|
||||
struct mstdnt_account* type = _type;
|
||||
|
||||
mstdnt_account_from_json(type, v->child);
|
||||
}
|
||||
|
||||
int mstdnt_account_from_result(struct mstdnt_fetch_results* results,
|
||||
struct mstdnt_storage* storage,
|
||||
struct mstdnt_account* acct,
|
||||
|
|
|
@ -32,14 +32,15 @@ static void _mstdnt_val_notif_type_call(cJSON* v, void* _type)
|
|||
return;
|
||||
}
|
||||
|
||||
if (strcmp(v->valuestring, "follow") == 0) *type = MSTDNT_NOTIFICATION_FOLLOW;
|
||||
else if (strcmp(v->valuestring, "follow_request") == 0) *type = MSTDNT_NOTIFICATION_FOLLOW;
|
||||
/* Sorted by most common notification type :^) */
|
||||
if (strcmp(v->valuestring, "favourite") == 0) *type = MSTDNT_NOTIFICATION_FAVOURITE;
|
||||
else if (strcmp(v->valuestring, "mention") == 0) *type = MSTDNT_NOTIFICATION_MENTION;
|
||||
else if (strcmp(v->valuestring, "reblog") == 0) *type = MSTDNT_NOTIFICATION_REBLOG;
|
||||
else if (strcmp(v->valuestring, "favourite") == 0) *type = MSTDNT_NOTIFICATION_FAVOURITE;
|
||||
else if (strcmp(v->valuestring, "pleroma:emoji_reaction") == 0) *type = MSTDNT_NOTIFICATION_EMOJI_REACT;
|
||||
else if (strcmp(v->valuestring, "follow") == 0) *type = MSTDNT_NOTIFICATION_FOLLOW;
|
||||
else if (strcmp(v->valuestring, "follow_request") == 0) *type = MSTDNT_NOTIFICATION_FOLLOW;
|
||||
else if (strcmp(v->valuestring, "poll") == 0) *type = MSTDNT_NOTIFICATION_POLL;
|
||||
else if (strcmp(v->valuestring, "status") == 0) *type = MSTDNT_NOTIFICATION_STATUS;
|
||||
else if (strcmp(v->valuestring, "pleroma:emoji_reaction") == 0) *type = MSTDNT_NOTIFICATION_EMOJI_REACT;
|
||||
else if (strcmp(v->valuestring, "pleroma:chat_mention") == 0) *type = MSTDNT_NOTIFICATION_CHAT_MENTION;
|
||||
else if (strcmp(v->valuestring, "pleroma:report") == 0) *type = MSTDNT_NOTIFICATION_REPORT;
|
||||
}
|
||||
|
@ -49,10 +50,10 @@ int mstdnt_notification_from_json(struct mstdnt_notification* notif, cJSON* js)
|
|||
cJSON* v;
|
||||
|
||||
struct _mstdnt_val_ref vals[] = {
|
||||
/* { "account", &(notif->account), _mstdnt_val_account_call }, */
|
||||
{ "account", &(notif->account), _mstdnt_val_account_call },
|
||||
{ "created_at", &(notif->created_at), _mstdnt_val_string_call },
|
||||
{ "id", &(notif->id), _mstdnt_val_string_call },
|
||||
/* { "status", &(notif->status), _mstdnt_val_status_call }, */
|
||||
{ "status", &(notif->status), _mstdnt_val_status_call },
|
||||
/* { "pleroma", &(notif->pleroma), _mstdnt_val_notif_pleroma_call }, */
|
||||
{ "type", &(notif->type), _mstdnt_val_notif_type_call },
|
||||
};
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <mastodont_json_helper.h>
|
||||
#include <mastodont_pleroma.h>
|
||||
|
||||
int mstdnt_load_status_pleroma_from_json(struct mstdnt_status_pleroma* pleroma, cJSON* js)
|
||||
int mstdnt_status_pleroma_from_json(struct mstdnt_status_pleroma* pleroma, cJSON* js)
|
||||
{
|
||||
cJSON* v;
|
||||
|
||||
|
@ -45,7 +45,7 @@ void _mstdnt_val_status_pleroma_call(cJSON* v, void* _type)
|
|||
{
|
||||
struct mstdnt_status_pleroma* type = _type;
|
||||
|
||||
mstdnt_load_status_pleroma_from_json(type, v->child);
|
||||
mstdnt_status_pleroma_from_json(type, v->child);
|
||||
}
|
||||
|
||||
void cleanup_status_pleroma(struct mstdnt_status_pleroma* pleroma)
|
||||
|
|
|
@ -22,6 +22,13 @@
|
|||
#include <mastodont_pleroma.h>
|
||||
#include <mastodont_request.h>
|
||||
|
||||
void _mstdnt_val_status_call(cJSON* v, void* _type)
|
||||
{
|
||||
struct mstdnt_status* type = _type;
|
||||
|
||||
mstdnt_status_from_json(type, v->child);
|
||||
}
|
||||
|
||||
int mstdnt_status_from_json(struct mstdnt_status* status, cJSON* js)
|
||||
{
|
||||
cJSON* v;
|
||||
|
|
Loading…
Reference in a new issue