|
|
|
@ -16,16 +16,22 @@
|
|
|
|
|
#include "api/status.h"
|
|
|
|
|
#include "api/notice.h"
|
|
|
|
|
|
|
|
|
|
bool handle_timeline( struct http_request* req, const char* which )
|
|
|
|
|
enum timeline_ids {
|
|
|
|
|
tli_owner = 0,
|
|
|
|
|
tli_public = 1,
|
|
|
|
|
tli_home = 2,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
bool handle_timeline( struct http_request* req, int timeline_id )
|
|
|
|
|
{
|
|
|
|
|
// "GET /api/v1/timelines/home?with_muted=true&limit=31"
|
|
|
|
|
bool with_muted = false;
|
|
|
|
|
unsigned int limit = 100;
|
|
|
|
|
|
|
|
|
|
struct timeline* tl = timeline_from_id( 0 );
|
|
|
|
|
struct timeline* tl = timeline_from_id( timeline_id );
|
|
|
|
|
|
|
|
|
|
struct status* ss[32];
|
|
|
|
|
int count = timeline_load_statuses( tl, 0, 32, ss );
|
|
|
|
|
printf( "count=%d\n", count );
|
|
|
|
|
show_statuses( req, ss, count );
|
|
|
|
|
|
|
|
|
|
for( int i = 0; i < count; ++i ) {
|
|
|
|
@ -68,8 +74,7 @@ bool route_mastodon_api( struct http_request* req )
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( http_request_route( req, "timelines/public" ) ) {
|
|
|
|
|
show_statuses( req, NULL, 0 );
|
|
|
|
|
return true;
|
|
|
|
|
return handle_timeline( req, tli_public );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//*
|
|
|
|
@ -106,28 +111,27 @@ bool route_mastodon_api( struct http_request* req )
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( http_request_route( req, "timelines/home" ) ) {
|
|
|
|
|
return handle_timeline( req, "home" );
|
|
|
|
|
if( http_request_route( req, "timelines/" ) ) {
|
|
|
|
|
if( http_request_route( req, "home" ) ) {
|
|
|
|
|
return handle_timeline( req, tli_home );
|
|
|
|
|
} else if( http_request_route( req, "public" ) ) {
|
|
|
|
|
return handle_timeline( req, tli_public );
|
|
|
|
|
}
|
|
|
|
|
} else if( http_request_route( req, "accounts/" ) ) {
|
|
|
|
|
|
|
|
|
|
if( http_request_route( req, "verify_credentials" ) ) {
|
|
|
|
|
return true;
|
|
|
|
|
} else if( http_request_route( req, "statuses" ) ) {
|
|
|
|
|
show_statuses( req, NULL, 0 );
|
|
|
|
|
return true;
|
|
|
|
|
return handle_timeline( req, tli_owner );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char* id_str = http_request_route_get_dir_or_file(req);
|
|
|
|
|
int id = 0;
|
|
|
|
|
|
|
|
|
|
if( http_request_route_id( req, &id ) ) {
|
|
|
|
|
struct account* a = account_from_id( id );
|
|
|
|
|
if( !a ) { return false; }
|
|
|
|
|
|
|
|
|
|
if( http_request_route( req, "statuses" ) ) {
|
|
|
|
|
printf( "TODO: statuses\n" );
|
|
|
|
|
show_statuses( req, NULL, 0 );
|
|
|
|
|
return true;
|
|
|
|
|
return handle_timeline( req, id );
|
|
|
|
|
} else {
|
|
|
|
|
return handle_mastodon_api_show_account( req, a );
|
|
|
|
|
}
|
|
|
|
|