parent
016936eae8
commit
c9b8d653f8
@ -0,0 +1,48 @@
|
||||
#include "Relationship.h"
|
||||
|
||||
#include "json/layout.h"
|
||||
|
||||
#include "model/account.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#define OBJ_TYPE struct Relationship
|
||||
static struct json_object_field Relationship_layout[] = {
|
||||
JSON_FIELD_INTEGER( id, true ),
|
||||
JSON_FIELD_BOOL( following, true ),
|
||||
JSON_FIELD_BOOL( showing_reblogs, true ),
|
||||
JSON_FIELD_BOOL( notifying, true ),
|
||||
JSON_FIELD_BOOL( followed_by, true ),
|
||||
JSON_FIELD_BOOL( blocking, true ),
|
||||
JSON_FIELD_BOOL( blocked_by, true ),
|
||||
JSON_FIELD_BOOL( muting, true ),
|
||||
JSON_FIELD_BOOL( muting_notifications, true ),
|
||||
JSON_FIELD_BOOL( requested, true ),
|
||||
JSON_FIELD_BOOL( domain_blocking, true ),
|
||||
JSON_FIELD_BOOL( endorsed, true ),
|
||||
JSON_FIELD_END,
|
||||
};
|
||||
#undef OBJ_TYPE
|
||||
|
||||
void api_Relationship_init( struct Relationship* r, struct account* a, struct account* rel )
|
||||
{
|
||||
memset( r, 0, sizeof(r) );
|
||||
r->id = rel->id;
|
||||
r->followed_by = account_does_follow( rel, a->id );
|
||||
r->following = account_does_follow( a, rel->id );
|
||||
}
|
||||
void api_Relationship_write( struct account* a, struct account* rel, FILE* f, int indent )
|
||||
{
|
||||
struct Relationship r;
|
||||
api_Relationship_init( &r, a, rel );
|
||||
|
||||
struct json_writer jw = {
|
||||
.f = f,
|
||||
.indentation = "\t",
|
||||
.indent = indent,
|
||||
};
|
||||
|
||||
json_write_pretty_object_layout( &jw, Relationship_layout, &r );
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
struct account;
|
||||
|
||||
struct Relationship
|
||||
{
|
||||
int id;
|
||||
bool following;
|
||||
bool showing_reblogs;
|
||||
bool notifying;
|
||||
bool followed_by;
|
||||
bool blocking;
|
||||
bool blocked_by;
|
||||
bool muting;
|
||||
bool muting_notifications;
|
||||
bool requested;
|
||||
bool domain_blocking;
|
||||
bool endorsed;
|
||||
};
|
||||
|
||||
void api_Relationship_init( struct Relationship* r, struct account* a, struct account* rel );
|
||||
void api_Relationship_write( struct account* a, struct account* rel, FILE* f, int indent );
|
||||
|
@ -1,14 +0,0 @@
|
||||
{
|
||||
"id": "%d{ a->id }",
|
||||
"following": false,
|
||||
"showing_reblogs": false,
|
||||
"notifying": false,
|
||||
"followed_by": false,
|
||||
"blocking": false,
|
||||
"blocked_by": false,
|
||||
"muting": false,
|
||||
"muting_notifications": false,
|
||||
"requested": false,
|
||||
"domain_blocking": false,
|
||||
"endorsed": false
|
||||
}
|
Loading…
Reference in new issue