|
|
|
@ -12,41 +12,77 @@ static struct json_enum ap_account_type_enum[] = {
|
|
|
|
|
{ NULL, 0 },
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define OBJ_TYPE struct ap_crypto_key
|
|
|
|
|
static struct json_object_field public_key_layout[] = {
|
|
|
|
|
{ "id", offsetof(struct ap_crypto_key,id), true, &json_field_string },
|
|
|
|
|
{ "owner", offsetof(struct ap_crypto_key,owner), true, &json_field_string },
|
|
|
|
|
{ "publicKeyPem", offsetof(struct ap_crypto_key,pem), true, &json_field_string },
|
|
|
|
|
{ NULL, 0 },
|
|
|
|
|
JSON_FIELD_STRING( id, true ),
|
|
|
|
|
JSON_FIELD_STRING( owner, true ),
|
|
|
|
|
{
|
|
|
|
|
.key = "publicKeyPem",
|
|
|
|
|
.offset = offsetof(struct ap_crypto_key,pem),
|
|
|
|
|
.required = true,
|
|
|
|
|
.type = &json_field_string
|
|
|
|
|
},
|
|
|
|
|
JSON_FIELD_END,
|
|
|
|
|
};
|
|
|
|
|
#undef OBJ_TYPE
|
|
|
|
|
|
|
|
|
|
static struct json_object_field icon_layout[] = {
|
|
|
|
|
{ "url", offsetof(struct ap_account,avatar), true, &json_field_string },
|
|
|
|
|
{ NULL },
|
|
|
|
|
{
|
|
|
|
|
.key = "url",
|
|
|
|
|
.offset = offsetof(struct ap_account,avatar),
|
|
|
|
|
.required = true,
|
|
|
|
|
.type = &json_field_string
|
|
|
|
|
},
|
|
|
|
|
JSON_FIELD_END,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static struct json_object_field image_layout[] = {
|
|
|
|
|
{ "url", offsetof(struct ap_account,banner), true, &json_field_string },
|
|
|
|
|
{ NULL },
|
|
|
|
|
{
|
|
|
|
|
.key = "url",
|
|
|
|
|
.offset = offsetof(struct ap_account,banner),
|
|
|
|
|
.required = true,
|
|
|
|
|
.type = &json_field_string
|
|
|
|
|
},
|
|
|
|
|
JSON_FIELD_END,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define OBJ_TYPE struct ap_account
|
|
|
|
|
static struct json_object_field ap_account_layout[] = {
|
|
|
|
|
{ "id", offsetof(struct ap_account,id), true, &json_field_string },
|
|
|
|
|
{ "type", offsetof(struct ap_account,type), true, &json_field_enum, ap_account_type_enum },
|
|
|
|
|
{ "url", offsetof(struct ap_account,url), true, &json_field_string },
|
|
|
|
|
{ "name", offsetof(struct ap_account,name), true, &json_field_string },
|
|
|
|
|
{ "preferredUsername", offsetof(struct ap_account,preferredUsername), true, &json_field_string },
|
|
|
|
|
{ "inbox", offsetof(struct ap_account,inbox), true, &json_field_string },
|
|
|
|
|
{ "summary", offsetof(struct ap_account,summary), true, &json_field_string },
|
|
|
|
|
{ "featured", offsetof(struct ap_account,featured), false, &json_field_string },
|
|
|
|
|
{ "followers", offsetof(struct ap_account,followers), false, &json_field_string },
|
|
|
|
|
{ "following", offsetof(struct ap_account,following), false, &json_field_string },
|
|
|
|
|
{ "publicKey", offsetof(struct ap_account,public_key), false, &json_field_object_composite, public_key_layout },
|
|
|
|
|
{ "discoverable", offsetof(struct ap_account,discoverable), false, &json_field_bool },
|
|
|
|
|
{ "icon", 0, false, &json_field_object_composite, icon_layout },
|
|
|
|
|
{ "image", 0, false, &json_field_object_composite, image_layout },
|
|
|
|
|
|
|
|
|
|
{ NULL },
|
|
|
|
|
JSON_FIELD_STRING( id, true ),
|
|
|
|
|
JSON_FIELD_ENUM( type, ap_account_type_enum, true ),
|
|
|
|
|
JSON_FIELD_STRING( url, true ),
|
|
|
|
|
JSON_FIELD_STRING( name, true ),
|
|
|
|
|
JSON_FIELD_STRING( preferredUsername, true ),
|
|
|
|
|
JSON_FIELD_STRING( inbox, true ),
|
|
|
|
|
JSON_FIELD_STRING( summary, true ),
|
|
|
|
|
JSON_FIELD_STRING( featured, false ),
|
|
|
|
|
JSON_FIELD_STRING( followers, false ),
|
|
|
|
|
JSON_FIELD_STRING( following, false ),
|
|
|
|
|
{
|
|
|
|
|
.key = "publicKey",
|
|
|
|
|
.offset = offsetof(struct ap_account,public_key),
|
|
|
|
|
.required = false,
|
|
|
|
|
.type = &json_field_object_composite,
|
|
|
|
|
.composite_layout = public_key_layout
|
|
|
|
|
},
|
|
|
|
|
JSON_FIELD_BOOL( discoverable, false ),
|
|
|
|
|
{
|
|
|
|
|
.key = "icon",
|
|
|
|
|
.offset = 0,
|
|
|
|
|
.required = false,
|
|
|
|
|
.type = &json_field_object_composite,
|
|
|
|
|
.composite_layout = icon_layout
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
.key = "image",
|
|
|
|
|
.offset = 0,
|
|
|
|
|
.required = false,
|
|
|
|
|
.type = &json_field_object_composite,
|
|
|
|
|
.composite_layout = image_layout
|
|
|
|
|
},
|
|
|
|
|
JSON_FIELD_END,
|
|
|
|
|
};
|
|
|
|
|
#undef OBJ_TYPE
|
|
|
|
|
|
|
|
|
|
struct ap_account* ap_account_from_file( const char* filename )
|
|
|
|
|
{
|
|
|
|
|