Get follow button to show up in both Husky and Soapbox

master
teknomunk 1 year ago
parent 56a48fce78
commit 016936eae8

@ -131,6 +131,14 @@ static bool handle_command_status( struct cli_request* req )
return true;
}
static bool handle_command_reindex( struct cli_request* req )
{
int res = cli_route_command( req, "reindex", 0, "" );
if( res != 1 ) { return !!res; }
account_reindex();
}
void handle_command( char** argv, int argc )
{
struct cli_request req = {
@ -144,5 +152,6 @@ void handle_command( char** argv, int argc )
|| handle_command_unfollow(&req)
|| handle_command_activity(&req)
|| handle_command_status(&req)
|| handle_command_reindex(&req)
;
}

@ -186,8 +186,14 @@ static bool handle_relationships( struct http_request* req )
FILE* f = http_request_get_response_body( req );
fprintf( f, "[" );
bool first = true;
const char* key;
while( (key=http_request_route_query_key(req)) && (0 == strcmp(key,"id[]") ) ) {
for(;;) {
const char* key = http_request_route_query_key(req); if( !key ) { break; }
if( 0 == strcmp(key,"id[]" ) ) {
} else if( 0 == strcmp(key,"id%5B%5D") ) {
} else {
break;
}
int id = atoi( http_request_route_query_value(req) );
if( id > 0 ) {
struct account* a = account_from_id(id);
@ -214,6 +220,34 @@ bool http_request_route_id( struct http_request* req, int* id )
return true;
}
bool get_local_account_id( struct http_request* req, int* id )
{
bool result = false;
char* id_str = http_request_route_get_dir_or_file(req);
if( !id_str || !*id_str ) { goto failed; }
*id = -1;
sscanf( id_str, "%d", id );
if( *id == -1 ) {
struct account* a = account_from_webfinger(id_str);
if( a ) {
*id = a->id;
account_free(a);
goto success;
}
goto failed;
}
success:
result = true;
cleanup:
free(id_str);
return true;
failed:
result = false;
goto cleanup;
}
// Route: /api/v1/statuses/%d{id}/
bool route_statuses_1f( struct http_request* req )
@ -320,7 +354,7 @@ bool route_mastodon_api( struct http_request* req )
}
int id = 0;
if( !http_request_route_id( req, &id ) ) {
if( !get_local_account_id( req, &id ) ) {
return false;
}

@ -111,9 +111,7 @@ void account_reindex()
index_uri_to_account_id( a->account_url, a->id );
}
char webfinger_name[512];
snprintf( webfinger_name, 512, "%s@%s", a->handle, a->server );
hash_index_set( "data/accounts/webfinger", webfinger_name, a->id );
account_index_webfinger( a );
account_free(a);
}
@ -184,6 +182,12 @@ struct account* account_from_uri_or_fetch( const char* uri )
return account_fetch_from_uri( uri );
}
void account_index_webfinger( struct account* a )
{
char webfinger_name[512];
snprintf( webfinger_name, 512, "%s@%s", a->handle, a->server );
hash_index_set( "data/accounts/webfinger", webfinger_name, a->id );
}
struct account* account_from_webfinger( const char* handle )
{
//printf( "account_from_webfinger( %s )\n", handle );
@ -248,6 +252,7 @@ bool account_sync_from_acitvity_pub( unsigned int account_id )
fclose(key_pem);
account_save(a);
account_index_webfinger(a);
ap_account_free(ap);
account_free(a);

@ -48,6 +48,7 @@ struct account
};
void account_reindex();
void account_index_webfinger( struct account* a );
struct account* account_from_id( int id );
struct account* account_from_uri( const char* uri );

@ -30,7 +30,21 @@
"is_admin":%s{ a->id == owner_account_id ? "true" : "false" },
"is_confirmed":true,
"is_moderator":false,
"relationship":{},
"relationship":{
"id": "%d{a->id}",
"following": false,
"showing_reblogs": true,
"notifying": false,
"followed_by": false,
"blocking": false,
"blocked_by": false,
"muting": false,
"muting_notifications": false,
"requested": false,
"domain_blocking": false,
"endorsed": false,
"note": ""
},
"skip_thread_containment":false,
"tags":[]
},

@ -1,6 +1,6 @@
{
"id": "%d{ a->id }",
"following": false
"following": false,
"showing_reblogs": false,
"notifying": false,
"followed_by": false,

Loading…
Cancel
Save