|
|
|
@ -4,6 +4,7 @@
|
|
|
|
|
#include "json/layout.h"
|
|
|
|
|
#include "format.h"
|
|
|
|
|
|
|
|
|
|
#include "model/server.h"
|
|
|
|
|
#include "model/status.h"
|
|
|
|
|
#include "model/status/react.h"
|
|
|
|
|
#include "model/account.h"
|
|
|
|
@ -35,7 +36,7 @@ static bool write_in_reply_to( struct json_writer* jw, const char* field_name, v
|
|
|
|
|
|
|
|
|
|
json_write_indention(jw);
|
|
|
|
|
json_write_field_name(jw,"in_reply_to_id");
|
|
|
|
|
fprintf( jw->f, "%d", in_reply_to->id );
|
|
|
|
|
fprintf( jw->f, "\"%d\"", in_reply_to->id );
|
|
|
|
|
} else {
|
|
|
|
|
json_write_field_name(jw,"in_reply_to_account_id");
|
|
|
|
|
fprintf( jw->f, "null" );
|
|
|
|
@ -225,6 +226,32 @@ bool render_source_callback( void* field_data, bool is_read, char** res )
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool in_reply_to_account_acct_callback( void* field_data, bool is_read, char** res )
|
|
|
|
|
{
|
|
|
|
|
struct status* s = field_data;
|
|
|
|
|
if( s->mentions.count > 0 ) {
|
|
|
|
|
struct account* a = account_from_id( s->mentions.items[0] );
|
|
|
|
|
*res = aformat( "%s@%s", a->handle, a->server );
|
|
|
|
|
account_free(a);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
*res = strdup("");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
bool context_url_callback( void* field_data, bool is_read, char** res )
|
|
|
|
|
{
|
|
|
|
|
struct status* s = field_data;
|
|
|
|
|
if( !is_read ) {
|
|
|
|
|
*res = aformat( "https://%s/contexts/%d", g_server_name, s->root_status_id );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
bool is_local_callback( void* field_data, bool is_read, bool* val )
|
|
|
|
|
{
|
|
|
|
|
struct status* s = field_data;
|
|
|
|
|
*val = false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define OBJ_TYPE struct status
|
|
|
|
|
static struct json_object_field content_layout[] = {
|
|
|
|
|
{
|
|
|
|
@ -242,6 +269,13 @@ static struct json_object_field pleroma_layout[] = {
|
|
|
|
|
.type = &json_field_object_composite,
|
|
|
|
|
.composite_layout = content_layout,
|
|
|
|
|
},
|
|
|
|
|
JSON_FIELD_FIXED_NULL( content_type ),
|
|
|
|
|
{
|
|
|
|
|
.key = "context",
|
|
|
|
|
.offset = 0,
|
|
|
|
|
.type = &json_field_callback_string,
|
|
|
|
|
.string_callback = context_url_callback,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
.key = "conversation_id",
|
|
|
|
|
.offset = offsetof( OBJ_TYPE, root_status_id ),
|
|
|
|
@ -255,19 +289,25 @@ static struct json_object_field pleroma_layout[] = {
|
|
|
|
|
.type = &json_field_array_of,
|
|
|
|
|
.array_item_type = &EmojiReact_type,
|
|
|
|
|
},
|
|
|
|
|
JSON_FIELD_FIXED_NULL( event ),
|
|
|
|
|
JSON_FIELD_FIXED_NULL( expires_at ),
|
|
|
|
|
/*%(
|
|
|
|
|
if( in_reply_to_account ) { )
|
|
|
|
|
"in_reply_to_account_acct": "%s{in_reply_to_account->handle}@%s{in_reply_to_account->server}",
|
|
|
|
|
"local": %s{ s->remote ? "false" : "true" },
|
|
|
|
|
"parent_visible": true,%(
|
|
|
|
|
} else { )
|
|
|
|
|
"in_reply_to_account_acct": null,
|
|
|
|
|
"local": %s{ s->remote ? "false" : "true" },
|
|
|
|
|
"parent_visible": false,%(
|
|
|
|
|
} )
|
|
|
|
|
*/
|
|
|
|
|
{
|
|
|
|
|
.key = "in_reply_to_account_acct",
|
|
|
|
|
.offset = 0,
|
|
|
|
|
.type = &json_field_callback_string,
|
|
|
|
|
.string_callback = in_reply_to_account_acct_callback,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
.key = "local",
|
|
|
|
|
.offset = 0,
|
|
|
|
|
.type = &json_field_bool_callback,
|
|
|
|
|
.bool_callback = is_local_callback,
|
|
|
|
|
},
|
|
|
|
|
JSON_FIELD_FIXED_BOOL( parent_visible, true ),
|
|
|
|
|
JSON_FIELD_FIXED_NULL( pinned_at ),
|
|
|
|
|
JSON_FIELD_FIXED_NULL( quote ),
|
|
|
|
|
JSON_FIELD_FIXED_NULL( quote_url ),
|
|
|
|
|
JSON_FIELD_FIXED_BOOL( quote_visible, false ),
|
|
|
|
|
/*
|
|
|
|
|
"spoiler_text": {
|
|
|
|
|
"text/plain": ""
|
|
|
|
|