diff --git a/include/mastodont_json_helper.h b/include/mastodont_json_helper.h
index b2123bb..ce353b4 100644
--- a/include/mastodont_json_helper.h
+++ b/include/mastodont_json_helper.h
@@ -35,6 +35,7 @@ int _mstdnt_key_val_ref(cJSON* v, struct _mstdnt_val_ref* refs,
void _mstdnt_val_string_call(cJSON* v, void* _type);
void _mstdnt_val_bool_call(cJSON* v, void* _type);
void _mstdnt_val_uint_call(cJSON* v, void* _type);
+void _mstdnt_val_sint_call(cJSON* v, void* _type);
/* DEPRECATED */
struct _mstdnt_str_val
diff --git a/include/mastodont_pleroma.h b/include/mastodont_pleroma.h
index 3e08746..668effe 100644
--- a/include/mastodont_pleroma.h
+++ b/include/mastodont_pleroma.h
@@ -13,16 +13,26 @@
* along with this program. If not, see .
*/
-#ifdef MASTODONT_PLEROMA
+#ifndef MASTODONT_PLEROMA
#define MASTODONT_PLEROMA
#include
-#include
+#include
struct mstdnt_pleroma
{
/* content */
int conversation_id;
int direct_conversation_id;
+ char* expires_at;
+ char* in_reply_to_account_acct;
+ mstdnt_bool local;
+ mstdnt_bool parent_visible;
+ char* pinned_at;
+ /* spoiler text */
+ int thread_muted;
};
+int mstdnt_load_pleroma_from_json(struct mstdnt_pleroma* pleroma, cJSON* js);
+void _mstdnt_val_pleroma_call(cJSON* v, void* _type);
+
#endif /* MASTODONT_PLEROMA */
diff --git a/include/mastodont_status.h b/include/mastodont_status.h
index 119e775..09b4071 100644
--- a/include/mastodont_status.h
+++ b/include/mastodont_status.h
@@ -16,6 +16,7 @@
#ifndef MASTODONT_STATUS
#define MASTODONT_STATUS
#include
+#include "mastodont_pleroma.h"
#include "mastodont_types.h"
#include "mastodont_fetch.h"
#include "mastodont_attachment.h"
@@ -25,7 +26,7 @@
#include "mastodont_emoji.h"
#include "mastodont_tag.h"
#include "mastodont_account.h"
-
+#include "mastodont_pleroma.h"
/* Status: Complete, not implemented */
enum mstdnt_status_visibility
@@ -51,6 +52,7 @@ struct mstdnt_status
struct mstdnt_attachment* media_attachments;
size_t media_attachments_len;
struct mstdnt_application application;
+ struct mstdnt_pleroma pleroma;
/* Rendering attributes */
struct mstdnt_mention* mentions;
diff --git a/src/json_helper.c b/src/json_helper.c
index c4d0dc7..50882fe 100644
--- a/src/json_helper.c
+++ b/src/json_helper.c
@@ -75,6 +75,18 @@ void _mstdnt_val_uint_call(cJSON* v, void* _type)
*type = v->valueint;
}
+
+void _mstdnt_val_sint_call(cJSON* v, void* _type)
+{
+ int* type = _type;
+ if (!cJSON_IsNumber(v))
+ {
+ *type = 0;
+ return;
+ }
+ *type = v->valueint;
+}
+
int _mstdnt_key_val_iter(cJSON* v,
struct _mstdnt_str_val* str,
size_t str_len,
diff --git a/src/pleroma.c b/src/pleroma.c
new file mode 100644
index 0000000..43ae674
--- /dev/null
+++ b/src/pleroma.c
@@ -0,0 +1,42 @@
+/*
+ * 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 .
+ */
+
+#include
+#include
+
+int mstdnt_load_pleroma_from_json(struct mstdnt_pleroma* pleroma, cJSON* js)
+{
+ cJSON* v;
+ struct _mstdnt_val_ref refs[] = {
+ { "conversation_id", &(pleroma->conversation_id), _mstdnt_val_sint_call },
+ { "direct_conversation_id", &(pleroma->direct_conversation_id), _mstdnt_val_sint_call },
+ { "expires_at", &(pleroma->expires_at), _mstdnt_val_string_call },
+ { "in_reply_to_account_acct", &(pleroma->in_reply_to_account_acct), _mstdnt_val_string_call },
+ { "pinned_at", &(pleroma->pinned_at), _mstdnt_val_string_call },
+ { "thread_muted", &(pleroma->thread_muted), _mstdnt_val_sint_call },
+ };
+
+ for (v = js; v; v = v->next)
+ {
+ _mstdnt_key_val_ref(v, refs, _mstdnt_arr_len(refs));
+ }
+}
+
+void _mstdnt_val_pleroma_call(cJSON* v, void* _type)
+{
+ struct mstdnt_pleroma* type = _type;
+
+ mstdnt_load_pleroma_from_json(type, v->child);
+}
diff --git a/src/status.c b/src/status.c
index 9e75c11..72e9d1f 100644
--- a/src/status.c
+++ b/src/status.c
@@ -19,6 +19,7 @@
#include
#include
#include
+#include
int mstdnt_load_status_from_json(struct mstdnt_status* status, cJSON* js)
{
@@ -28,7 +29,7 @@ int mstdnt_load_status_from_json(struct mstdnt_status* status, cJSON* js)
&(status->media_attachments),
&(status->media_attachments_len),
};
-
+
struct _mstdnt_val_ref vals[] = {
{ "id", &(status->id), _mstdnt_val_string_call },
{ "uri", &(status->uri), _mstdnt_val_string_call },
@@ -50,6 +51,7 @@ int mstdnt_load_status_from_json(struct mstdnt_status* status, cJSON* js)
{ "favourites_count", &(status->favourites_count), _mstdnt_val_uint_call },
{ "replies_count", &(status->replies_count), _mstdnt_val_uint_call },
{ "media_attachments", &att_args, _mstdnt_val_attachments_call },
+ { "pleroma", &(status->pleroma), _mstdnt_val_pleroma_call }
};
for (v = js; v; v = v->next)