diff --git a/include/mastodont_account.h b/include/mastodont_account.h index 8078d01..d11b515 100644 --- a/include/mastodont_account.h +++ b/include/mastodont_account.h @@ -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 */ diff --git a/include/mastodont_pleroma.h b/include/mastodont_pleroma.h index 7c95445..1eeeaf9 100644 --- a/include/mastodont_pleroma.h +++ b/include/mastodont_pleroma.h @@ -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 */ diff --git a/include/mastodont_status.h b/include/mastodont_status.h index 2218660..cabd8e6 100644 --- a/include/mastodont_status.h +++ b/include/mastodont_status.h @@ -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[], diff --git a/src/account.c b/src/account.c index 8c90df2..0b8380a 100644 --- a/src/account.c +++ b/src/account.c @@ -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, diff --git a/src/notification.c b/src/notification.c index 555cdd2..f764993 100644 --- a/src/notification.c +++ b/src/notification.c @@ -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 }, }; diff --git a/src/pleroma.c b/src/pleroma.c index ed2e4d7..a2229fd 100644 --- a/src/pleroma.c +++ b/src/pleroma.c @@ -16,7 +16,7 @@ #include #include -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) diff --git a/src/status.c b/src/status.c index 2ace134..8aaf07d 100644 --- a/src/status.c +++ b/src/status.c @@ -22,6 +22,13 @@ #include #include +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;