Fix several bugs, get reposted indicator showing correctly in Husky, starting work on moving owner/actor from text template to using ap_activity so it can be included in an Update

master
teknomunk 1 year ago
parent 61694bb0bb
commit 498391c779

@ -1,6 +1,7 @@
#include "cli.h"
#include "format.h"
#include "json/json.h"
#include "model/account.h"
#include "model/status.h"
@ -147,6 +148,9 @@ static bool handle_command_reindex( struct cli_request* req )
}
static bool handle_command_test( struct cli_request* req )
{
int res = cli_route_command( req, "test", 0, "" );
if( res != 1 ) { return !!res; }
for( int i = 0; i < 10; ++i ) {
struct notification* n = notification_from_id( 320 - i );
api_Notification_write( n, stdout, 0 );
@ -155,9 +159,6 @@ static bool handle_command_test( struct cli_request* req )
}
/*
int res = cli_route_command( req, "test", 0, "" );
if( res != 1 ) { return !!res; }
struct account* owner_account = account_from_id( owner_account_id );
struct status* s = status_from_id( 1164 );

@ -1 +1 @@
Subproject commit 1b512cba1f12a9a441282eff0b83b267d6cfd4f7
Subproject commit 4c171f6f63f37156b830cb71f8001ad803411f68

@ -1 +1 @@
Subproject commit f8ad4a8a7396432c800a03925d85d329cbacbfc8
Subproject commit 51831f744cba7ebc198e2e201689bcf9b3239c54

@ -1 +1 @@
Subproject commit 3d46d0b8d1ab859e24a21c0194875aff3352bf9c
Subproject commit 352e288093a597f394d447cba2ed843f9424e8f0

@ -99,6 +99,7 @@ static struct account* new_system_account()
a->handle = strdup("system");
a->display_name = strdup("Apogee System");
a->account_type = at_bot,
a->server = strdup(g_server_name);
a->bot = true;
asprintf( &a->avatar.url, "https://%s/system-account.png", g_server_name );
a->avatar.static_url = strdup(a->avatar.url);
@ -222,6 +223,14 @@ struct ap_account* account_activity_pub_data( struct account* a )
format( filename, 512, "data/accounts/%d/ap.json", a->id )
);
}
struct ap_activity* account_activity_pub( struct account* a )
{
struct ap_activity* act;
act = malloc(sizeof(*act));
memset(act,0,sizeof(*act));
return act;
}
bool account_sync_from_activity( struct account* a, struct ap_activity* act )
{
@ -690,6 +699,11 @@ void account_update( struct account* a )
act->type = apat_update;
act->actor = strdup(a->account_url);
act->object.tag = apaot_activity;
act->object.ptr = account_activity_pub(a);
ap_activity_write_to_FILE( act, stdout );
ap_activity_free(act);
}

@ -54,6 +54,7 @@ static struct json_object_field endpoints_layout[] = {
.required = false,
.type = &json_field_string,
},
JSON_FIELD_END,
};
static struct json_object_field ap_account_layout[] = {
JSON_FIELD_STRING( id, true ),

@ -114,12 +114,14 @@ struct json_object_field ap_activity_layout[] = {
.offset = offsetof( struct ap_activity, tags ),
.required = false,
.type = &json_field_array_of,
.allow_drop_empty_array = true,
.array_item_type = &ap_activity_tag_type
},
{
.key = "alsoKnownAs",
.offset = offsetof( struct ap_activity, also_known_as ),
.required = false,
.allow_drop_empty_array = true,
.type = &json_field_array_of,
.array_item_type = &json_field_string,
},
@ -144,14 +146,35 @@ struct json_object_field ap_activity_layout[] = {
.key = "attachment",
.offset = offsetof( struct ap_activity, attachments ),
.required = false,
.allow_drop_empty_array = true,
.type = &json_field_array_of,
.array_item_type = &ap_attachement_type
},
JSON_FIELD_ARRAY_OF_STRINGS(to,false),
JSON_FIELD_ARRAY_OF_STRINGS(cc,false),
JSON_FIELD_ARRAY_OF_STRINGS(bcc,false),
{
.key = "to",
.offset = offsetof( OBJ_TYPE, to ),
.required = false,
.allow_drop_empty_array = true,
.type = &json_field_array_of,
.array_item_type = &json_field_string,
},
{
.key = "cc",
.offset = offsetof( OBJ_TYPE, cc ),
.required = false,
.allow_drop_empty_array = true,
.type = &json_field_array_of,
.array_item_type = &json_field_string,
},
{
.key = "bcc",
.offset = offsetof( OBJ_TYPE, bcc ),
.required = false,
.allow_drop_empty_array = true,
.type = &json_field_array_of,
.array_item_type = &json_field_string,
},
{
.key = "object",
.offset = offsetof( struct ap_activity, object.tag ),

@ -18,7 +18,7 @@ static struct json_enum type_enum[] = {
{ "mention", nt_unfollow },
{ "mention", nt_block },
{ "mention", nt_mention },
{ "pleroma:emoji_raction", nt_react },
{ "pleroma:emoji_reaction", nt_react },
{ NULL, 0 },
};

@ -13,12 +13,14 @@
#include <string.h>
bool int_to_string_callback( void* field_data, bool is_read, char** res );
bool int_non_zero( void* field_data, bool is_read, bool* val )
bool post_reposted( void* field_data, bool is_read, bool* val )
{
struct status* s = field_data;
if( !is_read ) {
*val = *(int*)field_data > 0;
return true;
*val = ( s->reposted_status_id != 0 );
}
return true;
}
extern struct json_object_field api_Status_layout[];
@ -249,6 +251,7 @@ static struct json_object_field pleroma_layout[] = {
{
.key = "emoji_reactions",
.offset = offsetof( OBJ_TYPE, reacts ),
.required = true,
.type = &json_field_array_of,
.array_item_type = &EmojiReact_type,
},
@ -352,9 +355,9 @@ struct json_object_field api_Status_layout[] = {
},
{
.key = "reblogged",
.offset = offsetof( OBJ_TYPE, reposts.count ),
.offset = 0,
.type = &json_field_bool_callback,
.bool_callback = int_non_zero,
.bool_callback = post_reposted,
},
{
.key = "reblogs_count",

@ -13,7 +13,7 @@
{
"name":"git repo",
"type":"PropertyValue",
"value":"<a href=\"https://git.polaris-1.work/\" rel=\"ugc\">https://git.polaris-1.work/</a>"
"value":"<a href=\"https://gitea.polaris-1.work/\" rel=\"ugc\">https://gitea.polaris-1.work/</a>"
}
],
"capabilities":{

Loading…
Cancel
Save