Update object layout to include missing fields

master
teknomunk 1 year ago
parent 60eb914d8b
commit eb512d0d70

@ -236,7 +236,7 @@ struct ap_object
struct ap_public_key* public_key;
char* context;
int context_id;
int context_id; // WARNING! Not in layout
bool direct_message;
@ -254,8 +254,10 @@ struct ap_object
int count;
} collection_items;
// Other
char* state;
// Signature
int has_signature;
struct ap_signature signature;

@ -120,17 +120,97 @@ struct json_object_field ap_object_layout[] = {
.required = false,
.type = &ap_activity_context_type
},
JSON_FIELD_ENUM( type, ap_object_type_enum, true ),
JSON_FIELD_STRING(id,false),
JSON_FIELD_ENUM( type, ap_object_type_enum, true ),
// Object Fields
// TODO: rearrange things
JSON_FIELD_STRING(actor,false),
{
.key = "attachment",
.offset = offsetof( OBJ_TYPE, attachments ),
.required = false,
.allow_drop_empty = true,
.type = &json_field_array_of,
.array_item_type = &ap_object_type
},
{
.key = "attributedTo",
.required = false,
.offset = offsetof(OBJ_TYPE,attributed_to),
.type = &json_field_string,
},
{
.key = "content",
.offset = offsetof( OBJ_TYPE, content ),
.required = false,
.type = &ap_activity_source_type
},
JSON_FIELD_STRING(name,false),
JSON_FIELD_STRING(state,false),
{
.key = "inReplyTo",
.offset = offsetof( OBJ_TYPE, in_reply_to ),
.required = false,
.type = &json_field_string
},
{
.key = "published",
.offset = offsetof( OBJ_TYPE, published ),
.required = false,
.allow_drop_empty = true,
.type = &json_field_date_time,
},
JSON_FIELD_STRING(summary,false),
{
.key = "tag",
.offset = offsetof( OBJ_TYPE, tags ),
.required = false,
.type = &json_field_array_of,
.allow_drop_empty = true,
.array_item_type = &ap_activity_tag_type
},
JSON_FIELD_STRING(url,false),
{
.key = "to",
.offset = offsetof( OBJ_TYPE, to ),
.required = false,
.allow_drop_empty = true,
.type = &json_field_single_or_array_of,
.array_item_type = &json_field_string,
},
{
.key = "cc",
.offset = offsetof( OBJ_TYPE, cc ),
.required = false,
.allow_drop_empty = true,
.type = &json_field_single_or_array_of,
.array_item_type = &json_field_string,
},
{
.key = "bcc",
.offset = offsetof( OBJ_TYPE, bcc ),
.required = false,
.allow_drop_empty = true,
.type = &json_field_single_or_array_of,
.array_item_type = &json_field_string,
},
JSON_FIELD_STRING( mediaType, false ),
// PropertyValue-specific fields
JSON_FIELD_STRING( value, false ),
// Link-specific fields
JSON_FIELD_STRING(href,false),
// Activity-specific fields
JSON_FIELD_STRING(actor,false),
{
.key = "object",
.offset = offsetof( OBJ_TYPE, object ),
.required = false,
.type = &ap_object_ptr_or_ref_type,
},
JSON_FIELD_STRING( target, false ),
// Actor-specific fields
JSON_FIELD_STRING(inbox,false),
JSON_FIELD_STRING(outbox,false),
{
@ -139,7 +219,6 @@ struct json_object_field ap_object_layout[] = {
.required = false,
.type = &json_field_string,
},
JSON_FIELD_STRING(url,false),
{
.key = "endpoints",
.offset = 0,
@ -147,8 +226,14 @@ struct json_object_field ap_object_layout[] = {
.type = &endpoints_type,
},
JSON_FIELD_STRING( featured, false ),
JSON_FIELD_STRING( following, false ),
JSON_FIELD_STRING( followers, false ),
JSON_FIELD_STRING( following, false ),
{
.key = "capabilities",
.offset = 0,
.required = false,
.type = &capabilities_type,
},
{
.key = "icon",
.offset = offsetof( OBJ_TYPE, avatar ),
@ -161,12 +246,6 @@ struct json_object_field ap_object_layout[] = {
.required = false,
.type = &image_type,
},
{
.key = "capabilities",
.offset = 0,
.required = false,
.type = &capabilities_type,
},
JSON_FIELD_BOOL( discoverable, false ),
{
.key = "manuallyApprovesFollowers",
@ -180,48 +259,25 @@ struct json_object_field ap_object_layout[] = {
.required = false,
.type = &ap_public_key_type,
},
JSON_FIELD_STRING(context,false),
{
.key = "content",
.offset = offsetof( OBJ_TYPE, content ),
.key = "directMessage",
.offset = offsetof( OBJ_TYPE, direct_message ),
.required = false,
.type = &ap_activity_source_type
.type = &json_field_bool
},
JSON_FIELD_STRING(conversation,false),
{
.key = "published",
.offset = offsetof( OBJ_TYPE, published ),
.required = false,
.allow_drop_empty = true,
.type = &json_field_date_time,
},
{
.key = "sensitive",
.offset = offsetof( OBJ_TYPE, sensitive ),
.required = false,
.type = &json_field_bool_or_null
},
{
.key = "source",
.offset = offsetof( OBJ_TYPE, source ),
.required = false,
.type = &ap_activity_source_type
},
JSON_FIELD_STRING(summary,false),
{
.key = "inReplyTo",
.offset = offsetof( OBJ_TYPE, in_reply_to ),
.required = false,
.type = &json_field_string
},
{
.key = "tag",
.offset = offsetof( OBJ_TYPE, tags ),
.key = "sensitive",
.offset = offsetof( OBJ_TYPE, sensitive ),
.required = false,
.type = &json_field_array_of,
.allow_drop_empty = true,
.array_item_type = &ap_activity_tag_type
.type = &json_field_bool_or_null
},
{
.key = "alsoKnownAs",
@ -232,71 +288,7 @@ struct json_object_field ap_object_layout[] = {
.array_item_type = &json_field_string,
},
JSON_FIELD_STRING(context,false),
{
.key = "attributedTo",
.required = false,
.offset = offsetof(OBJ_TYPE,attributed_to),
.type = &json_field_string,
},
JSON_FIELD_STRING( target, false ),
{
.key = "directMessage",
.offset = offsetof( OBJ_TYPE, direct_message ),
.required = false,
.type = &json_field_bool
},
{
.key = "attachment",
.offset = offsetof( OBJ_TYPE, attachments ),
.required = false,
.allow_drop_empty = true,
.type = &json_field_array_of,
.array_item_type = &ap_object_type
},
{
.key = "to",
.offset = offsetof( OBJ_TYPE, to ),
.required = false,
.allow_drop_empty = true,
.type = &json_field_single_or_array_of,
.array_item_type = &json_field_string,
},
{
.key = "cc",
.offset = offsetof( OBJ_TYPE, cc ),
.required = false,
.allow_drop_empty = true,
.type = &json_field_single_or_array_of,
.array_item_type = &json_field_string,
},
{
.key = "bcc",
.offset = offsetof( OBJ_TYPE, bcc ),
.required = false,
.allow_drop_empty = true,
.type = &json_field_single_or_array_of,
.array_item_type = &json_field_string,
},
{
.key = "object",
.offset = offsetof( OBJ_TYPE, object ),
.required = false,
.type = &ap_object_ptr_or_ref_type,
},
{
.key = "signature",
.offset = offsetof( OBJ_TYPE, has_signature ),
.required = false,
.type = &json_field_tagged_union,
.tagged_item_types = signature_types
},
// Collection fields
{
.key = "first",
.offset = offsetof( OBJ_TYPE, first ),
@ -324,6 +316,20 @@ struct json_object_field ap_object_layout[] = {
.type = &json_field_array_of,
.array_item_type = &ap_object_ptr_or_ref_type,
},
// Other
JSON_FIELD_STRING(state,false),
// Signature
{
.key = "signature",
.offset = offsetof( OBJ_TYPE, has_signature ),
.required = false,
.type = &json_field_tagged_union,
.tagged_item_types = signature_types
},
// Extra field storage
{
.key = "*",
.offset = offsetof( OBJ_TYPE, extra ),

Loading…
Cancel
Save