Continue s/ap_activity/ap_object/, remove ap_account and use ap_object instead, move actor/attribtuedTo fixup code to controller/inbox.c
parent
1a18b603f5
commit
1c1df8270c
@ -1 +1 @@
|
||||
Subproject commit d1ca725373342a37aecaa56f88c463057807e613
|
||||
Subproject commit 36c3fb214952ab71a0f3ee7c235a78c19c2ac5a8
|
@ -1,150 +0,0 @@
|
||||
#include "account.h"
|
||||
|
||||
#include "json/json.h"
|
||||
#include "json/layout.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
static struct json_enum ap_account_type_enum[] = {
|
||||
{ "Person", apacct_Person },
|
||||
{ NULL, 0 },
|
||||
};
|
||||
|
||||
#define OBJ_TYPE struct ap_crypto_key
|
||||
static struct json_object_field public_key_layout[] = {
|
||||
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[] = {
|
||||
{
|
||||
.key = "url",
|
||||
.offset = offsetof(struct ap_account,avatar),
|
||||
.required = true,
|
||||
.type = &json_field_string
|
||||
},
|
||||
JSON_FIELD_END,
|
||||
};
|
||||
|
||||
static struct json_object_field image_layout[] = {
|
||||
{
|
||||
.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 endpoints_layout[] = {
|
||||
{
|
||||
.key = "sharedInbox",
|
||||
.offset = offsetof(OBJ_TYPE,shared_inbox),
|
||||
.required = false,
|
||||
.type = &json_field_string,
|
||||
},
|
||||
JSON_FIELD_END,
|
||||
};
|
||||
static struct json_object_field ap_account_layout[] = {
|
||||
JSON_FIELD_STRING( id, true ),
|
||||
JSON_FIELD_ENUM( type, ap_account_type_enum, true ),
|
||||
JSON_FIELD_STRING( url, true ),
|
||||
JSON_FIELD_STRING( name, false ),
|
||||
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
|
||||
},
|
||||
{
|
||||
.key = "endpoints",
|
||||
.offset = 0,
|
||||
.required = false,
|
||||
.type = &json_field_object_composite,
|
||||
.composite_layout = endpoints_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 )
|
||||
{
|
||||
struct ap_account* acc = malloc(sizeof(struct ap_account));
|
||||
memset(acc,0,sizeof(struct ap_account));
|
||||
|
||||
if( !json_read_object_layout_from_file( filename, ap_account_layout, acc ) ) {
|
||||
ap_account_free(acc);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return acc;
|
||||
}
|
||||
|
||||
void ap_account_free( struct ap_account* acc )
|
||||
{
|
||||
if( !acc ) { return; }
|
||||
|
||||
free(acc->id);
|
||||
free(acc->url);
|
||||
|
||||
free(acc->name);
|
||||
free(acc->preferredUsername);
|
||||
free(acc->inbox);
|
||||
free(acc->shared_inbox);
|
||||
free(acc->outbox);
|
||||
|
||||
free(acc->featured);
|
||||
free(acc->followers);
|
||||
free(acc->following);
|
||||
|
||||
free(acc->avatar);
|
||||
free(acc->banner);
|
||||
|
||||
free(acc->summary);
|
||||
|
||||
free(acc->public_key.id);
|
||||
free(acc->public_key.owner);
|
||||
free(acc->public_key.pem);
|
||||
|
||||
free(acc);
|
||||
}
|
||||
void ap_account_debug_dump( struct ap_account* acc )
|
||||
{
|
||||
json_write_object_layout_to_FILE( stdout, "\t", ap_account_layout, acc );
|
||||
//FILE* f = stdout;
|
||||
//#include "src/model/ap/account.debug_dump.txt.inc"
|
||||
}
|
||||
|
@ -1,27 +0,0 @@
|
||||
%p{acc} = {
|
||||
.id = %s{acc->id},
|
||||
.type = %d{acc->type},
|
||||
.url = %s{acc->url},
|
||||
|
||||
.name = %s{acc->name},
|
||||
.preferredUsername = %s{acc->preferredUsername},
|
||||
.inbox = %s{acc->inbox},
|
||||
.outbox = %s{acc->outbox},
|
||||
|
||||
.featured = %s{acc->featured},
|
||||
.followers = %s{acc->followers},
|
||||
.following = %s{acc->following},
|
||||
|
||||
.avatar = %s{acc->avatar},
|
||||
.banner = %s{acc->banner},
|
||||
|
||||
.summary = %s{acc->summary},
|
||||
|
||||
.discoverable = %c{ acc->discoverable ? 'T' : 'F' },
|
||||
|
||||
.public_key = {
|
||||
.id = %s{acc->public_key.id},
|
||||
.owner = %s{acc->public_key.owner},
|
||||
.pem = %s{acc->public_key.pem}
|
||||
}
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
enum ap_account_type
|
||||
{
|
||||
apacct_Person = 1,
|
||||
};
|
||||
|
||||
struct ap_crypto_key
|
||||
{
|
||||
char* id;
|
||||
char* owner;
|
||||
char* pem;
|
||||
};
|
||||
|
||||
struct ap_account
|
||||
{
|
||||
char* id;
|
||||
int type;
|
||||
char* url;
|
||||
|
||||
char* name;
|
||||
char* preferredUsername;
|
||||
char* inbox;
|
||||
char* shared_inbox;
|
||||
char* outbox;
|
||||
|
||||
char* featured;
|
||||
char* followers;
|
||||
char* following;
|
||||
|
||||
char* avatar;
|
||||
char* banner;
|
||||
|
||||
char* summary;
|
||||
|
||||
bool discoverable;
|
||||
|
||||
struct ap_crypto_key public_key;
|
||||
};
|
||||
|
||||
struct ap_account* ap_account_from_file( const char* filename );
|
||||
void ap_account_free( struct ap_account* acc );
|
||||
|
||||
void ap_account_debug_dump( struct ap_account* acc );
|
||||
|
Loading…
Reference in new issue