Add cli command to force account resync to fix issue with first account added, fix typo, force statuses created by owner to be remote=false, add field for follow_activity (unused)

master
teknomunk 1 year ago
parent a52a9b8c89
commit e4513a4fc8

@ -7,6 +7,7 @@
#include "format.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
@ -20,6 +21,7 @@ struct cli_request
static int cli_route_command( struct cli_request* req, const char* cmd, int count, const char* usage_args )
{
if( 0 != strcmp(req->argv[0], cmd ) ) {
printf( "No match for %s==%s\n", req->argv[0], cmd );
return 0;
}
req->argv += 1;
@ -159,6 +161,41 @@ static bool handle_command_test( struct cli_request* req )
account_free(owner_account);
}
bool handle_command_account_sync( struct cli_request* req, struct account* a )
{
printf( "sync cmd = %s\n", req->argv[0] );
int res = cli_route_command( req, "sync", 0, "" );
if( res != 1 ) { return !!res; }
printf( "Syncing account %d (%s)\n", a->id, a->account_url );
account_sync_from_activity_pub( a->id );
return true;
}
bool handle_command_account( struct cli_request* req )
{
printf( "cmd = %s\n", req->argv[0] );
int res = cli_route_command( req, "account", 1, "account (id)" );
if( res != 1 ) { return !!res; }
bool result = false;
struct account* a = account_from_id( atoi(req->argv[0]) );
req->argv += 1;
req->argc -= 1;
if( handle_command_account_sync(req,a) ) { goto done; }
result = false;
cleanup:
account_free(a);
return result;
done:
result = true;
goto cleanup;
}
void handle_command( char** argv, int argc )
{
struct cli_request req = {
@ -167,12 +204,15 @@ void handle_command( char** argv, int argc )
.binary_name = argv[0]
};
false
if( false
|| handle_command_follow(&req)
|| handle_command_unfollow(&req)
|| handle_command_activity(&req)
|| handle_command_status(&req)
|| handle_command_account(&req)
|| handle_command_reindex(&req)
|| handle_command_test(&req)
;
) { return; }
printf( "Unknown command %s\n", argv[1] );
}

@ -1 +1 @@
Subproject commit 9a64b30b973aa8148855edb16bdd3d806366ff76
Subproject commit 1a630944a79aa31d95be7ee1b37a37f8556cd1c5

@ -82,6 +82,7 @@ static struct json_object_field account_layout[] = {
.required = false,
.type = &json_field_integer
},
JSON_FIELD_INTEGER( follow_activity, false ),
JSON_FIELD_STRING( account_url, true ),
JSON_FIELD_END,
};
@ -227,7 +228,7 @@ bool account_sync_from_activity( struct account* a, struct ap_activity* act )
return true;
}
bool account_sync_from_acitvity_pub( unsigned int account_id )
bool account_sync_from_activity_pub( unsigned int account_id )
{
char filename[512];
struct ap_account* ap = ap_account_from_file(
@ -357,7 +358,7 @@ struct account* account_fetch_from_uri( const char* uri )
}
// Fail if we can't sync
if( !account_sync_from_acitvity_pub( account_id ) ) {
if( !account_sync_from_activity_pub( account_id ) ) {
return NULL;
}

@ -45,6 +45,7 @@ struct account
int followers_count;
int following_count;
int status_count;
int follow_activity;
char* note;
@ -65,7 +66,7 @@ struct account* account_new();
void account_free( struct account* a );
void account_save( struct account* a );
bool account_sync_from_acitvity_pub( unsigned int id );
bool account_sync_from_activity_pub( unsigned int id );
bool account_sync_from_activity( struct account* a, struct ap_activity* act );
struct ap_account;

@ -83,6 +83,9 @@ struct status* status_from_id( unsigned int id )
if( !s->remote && !s->url ) {
s->url = aformat( "https://%s/note/%d", g_server_name, s->id );
}
if( s->account_id == owner_account_id ) {
s->remote =false;
}
return s;
}

Loading…
Cancel
Save