|
|
|
@ -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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|