|
|
|
@ -7,18 +7,8 @@
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
|
|
|
|
|
static struct json_enum ap_signature_type_enum[] = {
|
|
|
|
|
{ "RsaSignature2017", 1 },
|
|
|
|
|
{ NULL, 0 },
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static struct json_object_field ap_signature_layout[] = {
|
|
|
|
|
{ "type", offsetof( struct ap_signature, type ), true, &json_field_enum, ap_signature_type_enum },
|
|
|
|
|
{ "creator", offsetof( struct ap_signature, creator ), true, &json_field_string },
|
|
|
|
|
{ "created", offsetof( struct ap_signature, created ), true, &json_field_date_time },
|
|
|
|
|
{ "signatureValue", offsetof( struct ap_signature, value ), true, &json_field_string },
|
|
|
|
|
{ NULL },
|
|
|
|
|
};
|
|
|
|
|
extern struct json_object_field ap_signature_layout[];
|
|
|
|
|
extern struct json_field_type ap_activity_source_type;
|
|
|
|
|
|
|
|
|
|
// https://www.w3.org/TR/activitystreams-vocabulary/#h-activity-types
|
|
|
|
|
struct json_enum ap_activity_type_enum[] = {
|
|
|
|
@ -56,16 +46,14 @@ struct json_enum ap_activity_type_enum[] = {
|
|
|
|
|
|
|
|
|
|
struct json_object_field activity_ref_types[] = {
|
|
|
|
|
{ (char*)apaot_ref, offsetof( struct ap_activity, object.ref ), false, &json_field_string },
|
|
|
|
|
{ (char*)apaot_activity, offsetof( struct ap_activity, object.ptr ), false, &json_field_object_pointer, ap_activity_layout },
|
|
|
|
|
{ NULL },
|
|
|
|
|
{ (char*)apaot_activity, offsetof( struct ap_activity, object.ptr ), false, &ap_activity_type },
|
|
|
|
|
JSON_FIELD_END,
|
|
|
|
|
};
|
|
|
|
|
struct json_object_field signature_types[] = {
|
|
|
|
|
{ (char*)1, offsetof( struct ap_activity, signature ), false, &json_field_object_composite, ap_signature_layout },
|
|
|
|
|
{ NULL },
|
|
|
|
|
JSON_FIELD_END
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define OBJ_TYPE struct ap_activity
|
|
|
|
|
struct json_object_field ap_activity_layout[] = {
|
|
|
|
|
{
|
|
|
|
@ -81,9 +69,9 @@ struct json_object_field ap_activity_layout[] = {
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
.key = "content",
|
|
|
|
|
.offset = offsetof( struct ap_activity, content.value ),
|
|
|
|
|
.offset = offsetof( struct ap_activity, content ),
|
|
|
|
|
.required = false,
|
|
|
|
|
.type = &json_field_string
|
|
|
|
|
.type = &ap_activity_source_type
|
|
|
|
|
},
|
|
|
|
|
JSON_FIELD_STRING(conversation,false),
|
|
|
|
|
JSON_FIELD_DATETIME(published,false),
|
|
|
|
@ -95,9 +83,9 @@ struct json_object_field ap_activity_layout[] = {
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
.key = "source",
|
|
|
|
|
.offset = offsetof( struct ap_activity, source.value ),
|
|
|
|
|
.offset = offsetof( struct ap_activity, source ),
|
|
|
|
|
.required = false,
|
|
|
|
|
.type = &json_field_string
|
|
|
|
|
.type = &ap_activity_source_type
|
|
|
|
|
},
|
|
|
|
|
JSON_FIELD_STRING(summary,false),
|
|
|
|
|
|
|
|
|
@ -117,9 +105,14 @@ struct json_object_field ap_activity_layout[] = {
|
|
|
|
|
.type = &json_field_string,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
{ "directMessage", offsetof( struct ap_activity, direct_message ), false, &json_field_bool },
|
|
|
|
|
{
|
|
|
|
|
.key = "directMessage",
|
|
|
|
|
.offset = offsetof( struct ap_activity, direct_message ),
|
|
|
|
|
.required = false,
|
|
|
|
|
.type = &json_field_bool
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
{ "attachment", offsetof( struct ap_activity, attachments ), false, &json_field_array_of, &json_field_string },
|
|
|
|
|
{ "attachment", offsetof( struct ap_activity, attachments ), false, &json_field_array_of, &ap_attachement_type },
|
|
|
|
|
|
|
|
|
|
JSON_FIELD_ARRAY_OF_STRINGS(to,true),
|
|
|
|
|
JSON_FIELD_ARRAY_OF_STRINGS(cc,false),
|
|
|
|
@ -129,30 +122,13 @@ struct json_object_field ap_activity_layout[] = {
|
|
|
|
|
|
|
|
|
|
{ "signature", offsetof( struct ap_activity, has_signature ), false, &json_field_tagged_union, &signature_types },
|
|
|
|
|
|
|
|
|
|
{ "type", offsetof( struct ap_activity, type ), true, &json_field_enum, ap_activity_type_enum },
|
|
|
|
|
JSON_FIELD_ENUM( type, ap_activity_type_enum, true ),
|
|
|
|
|
|
|
|
|
|
{ NULL, 0, true, NULL, &ap_activity_type },
|
|
|
|
|
JSON_FIELD_END,
|
|
|
|
|
};
|
|
|
|
|
#undef OBJ_TYPE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void ap_activity_free_shim( void* ptr )
|
|
|
|
|
{
|
|
|
|
|
ap_activity_free(ptr);
|
|
|
|
|
}
|
|
|
|
|
static void* ap_activity_alloc()
|
|
|
|
|
{
|
|
|
|
|
return (void*)ap_activity_new();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct json_field_type ap_activity_type = {
|
|
|
|
|
.reader = json_field_object_type_reader,
|
|
|
|
|
.writer = json_field_object_type_writer,
|
|
|
|
|
.size = sizeof(struct ap_activity),
|
|
|
|
|
.layout = ap_activity_layout,
|
|
|
|
|
.alloc = ap_activity_alloc,
|
|
|
|
|
.free = ap_activity_free_shim,
|
|
|
|
|
};
|
|
|
|
|
JSON_FIELD_TYPE_OBJECT_LAYOUT_WITH_DEFAULTS( ap_activity );
|
|
|
|
|
|
|
|
|
|
struct ap_activity* ap_activity_from_FILE( FILE* f )
|
|
|
|
|
{
|
|
|
|
|