Add command to pull follower/following lists for all followed accounts

master
teknomunk 1 year ago
parent 22bae76274
commit 8dfd92e738

@ -219,6 +219,16 @@ bool handle_command_update( struct cli_request* req )
account_free(owner);
return true;
}
bool handle_command_pull( struct cli_request* req )
{
int res = cli_route_command( req, "pull", 0, "pull" );
if( res != 1 ) { return !!res; }
struct account* owner = account_from_id( owner_account_id );
account_pull_friends_of_friends(owner);
account_free(owner);
return true;
}
bool handle_command_account( struct cli_request* req )
{
@ -260,6 +270,7 @@ bool handle_command( char** argv, int argc )
|| handle_command_test(&req)
|| handle_command_update(&req)
|| handle_command_gc(&req)
|| handle_command_pull(&req)
) { return true; }
return false;

@ -106,6 +106,7 @@ bool account_sync_from_activity( struct account* a, struct ap_object* act );
struct ap_object* account_get_activity_pub_data( struct account* a );
void account_sync_following_list( struct account* a );
void account_sync_followers_list( struct account* a );
void account_pull_friends_of_friends( struct account* a );
// Data requests
struct crypto_keys* account_get_public_key( struct account* a, const char* key_name );
@ -114,7 +115,6 @@ void account_list_followers( struct account* a, int offset, int limit, void* id_
void account_list_following( struct account* a, int offset, int limit, void* id_array );
// Activity pub data
//struct ap_object* account_activity_pub( struct account* a );
struct ap_object* account_ap_actor( struct account* a );
struct ap_object* account_ap_outbox( struct account* a );
struct ap_object* account_ap_outbox_page( struct account* a, int page );

@ -204,7 +204,7 @@ void account_sync_following_list( struct account* a )
account_add_follower( following, a );
}
account_free(following);a
account_free(following);
}
}
@ -264,4 +264,21 @@ void account_sync_followers_list( struct account* a )
cleanup:
ap_object_free(followers);
}
void account_pull_friends_of_friends( struct account* a )
{
struct {
int* items;
int count;
} following;
account_list_following( a, 0, INT_MAX, &following );
for( int i = 0; i < following.count; ++i ) {
struct account* friend = account_from_id( following.items[i] );
account_sync_following_list( friend );
account_sync_followers_list( friend );
account_free(friend);
}
free( following.items );
}

@ -320,6 +320,7 @@ bool quote_url_callback( void* field_data, bool is_read, char** val )
if( s->quote_id == 0 ) { return false; }
struct status* quoted_post = status_from_id(s->quote_id);
if( !quoted_post ) { return false; }
*val = strdup(quoted_post->url );
status_free(quoted_post);
return true;

Loading…
Cancel
Save