|
|
|
@ -214,6 +214,44 @@ bool http_request_route_id( struct http_request* req, int* id )
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Route: /api/v1/statuses/%d{id}/
|
|
|
|
|
bool route_statuses_1f( struct http_request* req )
|
|
|
|
|
{
|
|
|
|
|
bool result = false;
|
|
|
|
|
struct status* s = NULL;
|
|
|
|
|
|
|
|
|
|
if( http_request_route( req, "" ) && http_request_route_method( req, "POST" ) ) {
|
|
|
|
|
struct account* owner = account_from_id(0);
|
|
|
|
|
bool res = handle_post(req, owner);
|
|
|
|
|
account_free(owner);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( !http_request_route( req, "/" ) ) { return false; }
|
|
|
|
|
|
|
|
|
|
int id = -1;
|
|
|
|
|
|
|
|
|
|
if( !http_request_route_id( req, &id ) ) { goto failed; }
|
|
|
|
|
s = status_from_id(id);
|
|
|
|
|
if( !s ) { goto failed; }
|
|
|
|
|
|
|
|
|
|
if( http_request_route( req, "context" ) ) {
|
|
|
|
|
show_status_context( req, s );
|
|
|
|
|
goto success;
|
|
|
|
|
} else if( http_request_route( req, "" ) ) {
|
|
|
|
|
show_status( req, s );
|
|
|
|
|
goto success;
|
|
|
|
|
}
|
|
|
|
|
failed:
|
|
|
|
|
result = false;
|
|
|
|
|
cleanup:
|
|
|
|
|
status_free(s);
|
|
|
|
|
return result;
|
|
|
|
|
success:
|
|
|
|
|
result = true;
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool route_mastodon_api( struct http_request* req )
|
|
|
|
|
{
|
|
|
|
|
if( http_request_route_term( req, "apps" ) ) {
|
|
|
|
@ -243,30 +281,7 @@ bool route_mastodon_api( struct http_request* req )
|
|
|
|
|
fprintf( f, "[]" );
|
|
|
|
|
return true;
|
|
|
|
|
} else if( http_request_route( req, "statuses" ) ) {
|
|
|
|
|
printf( "route: statuses\n" );
|
|
|
|
|
if( http_request_route( req, "/" ) ) {
|
|
|
|
|
int id = -1;
|
|
|
|
|
|
|
|
|
|
if( http_request_route_id( req, &id ) ) {
|
|
|
|
|
struct status* s = status_from_id(id);
|
|
|
|
|
if( !s ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( http_request_route( req, "context" ) ) {
|
|
|
|
|
show_status_context( req, s );
|
|
|
|
|
} else {
|
|
|
|
|
show_status( req, s );
|
|
|
|
|
}
|
|
|
|
|
status_free(s);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
} else if( http_request_route_method( req, "POST" ) ) {
|
|
|
|
|
struct account* owner = account_from_id(0);
|
|
|
|
|
bool res = handle_post(req, owner);
|
|
|
|
|
account_free(owner);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
return route_statuses_1f(req);
|
|
|
|
|
} else if( http_request_route( req, "timelines/" ) ) {
|
|
|
|
|
if( http_request_route( req, "home" ) ) {
|
|
|
|
|
return handle_timeline( req, tli_home );
|
|
|
|
|