|
|
|
@ -170,14 +170,38 @@ static bool handle_relationships( struct http_request* req )
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Route: /api/v1/accounts/update_credentials
|
|
|
|
|
bool route_api_account_update_credentials( struct http_request* req )
|
|
|
|
|
{
|
|
|
|
|
if( !http_request_route_method( req, "PATCH" ) ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FILE* f = http_request_get_request_data( req );
|
|
|
|
|
|
|
|
|
|
printf( "Request body:\n" );
|
|
|
|
|
int c;
|
|
|
|
|
while( (c=fgetc(f)) != EOF ) {
|
|
|
|
|
fputc(c,stdout);
|
|
|
|
|
}
|
|
|
|
|
printf( "\nEnd of body (last=%d)\n", c );
|
|
|
|
|
|
|
|
|
|
struct account* owner = account_from_id(owner_account_id);
|
|
|
|
|
bool res = handle_mastodon_api_show_account( req, owner );
|
|
|
|
|
account_free(owner);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Route: /api/v1/accounts/
|
|
|
|
|
bool route_api_account( struct http_request* req )
|
|
|
|
|
{
|
|
|
|
|
if( http_request_route_term( req, "verify_credentials" ) || http_request_route_term( req, "update_credentials" ) ) {
|
|
|
|
|
struct account* owner = account_from_id(0);
|
|
|
|
|
if( http_request_route_term( req, "verify_credentials" ) ) {
|
|
|
|
|
struct account* owner = account_from_id(owner_account_id);
|
|
|
|
|
bool res = handle_mastodon_api_show_account( req, owner );
|
|
|
|
|
account_free(owner);
|
|
|
|
|
return res;
|
|
|
|
|
} else if( http_request_route_term( req, "update_credentials" ) ) {
|
|
|
|
|
return route_api_account_update_credentials(req);
|
|
|
|
|
} else if( http_request_route( req, "relationships?" ) ) {
|
|
|
|
|
return handle_relationships(req);
|
|
|
|
|
} else if( http_request_route( req, "statuses" ) ) {
|
|
|
|
@ -191,16 +215,17 @@ bool route_api_account( struct http_request* req )
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Route: /api/v1/accounts/%d{id}
|
|
|
|
|
int id = 0;
|
|
|
|
|
if( !get_local_account_id( req, &id ) ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Make sure the account exists before allowing anything to be done with it
|
|
|
|
|
struct account* a = account_from_id( id );
|
|
|
|
|
if( !a ) { return false; }
|
|
|
|
|
|
|
|
|
|
// Route: /api/v1/accounts/%d{id}
|
|
|
|
|
|
|
|
|
|
// Account-specific routes
|
|
|
|
|
if( http_request_route( req, "statuses" ) ) {
|
|
|
|
|
bool res = handle_timeline( req, id );
|
|
|
|
|
account_free(a);
|
|
|
|
|