|
|
|
@ -14,7 +14,7 @@
|
|
|
|
|
#include "api/status.h"
|
|
|
|
|
#include "api/notice.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <limits.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
@ -27,8 +27,33 @@ enum timeline_ids {
|
|
|
|
|
|
|
|
|
|
bool handle_timeline( struct http_request* req, int timeline_id )
|
|
|
|
|
{
|
|
|
|
|
bool with_muted = false;
|
|
|
|
|
unsigned int limit = 100;
|
|
|
|
|
bool hide_muted = true;
|
|
|
|
|
unsigned int limit = 32;
|
|
|
|
|
int max_id = INT_MAX;
|
|
|
|
|
int since_id = 0;
|
|
|
|
|
|
|
|
|
|
// handle query parameters
|
|
|
|
|
if( http_request_route( req, "?" ) ) {
|
|
|
|
|
const char* key;
|
|
|
|
|
while( key = http_request_route_query_key(req) ) {
|
|
|
|
|
const char* value = http_request_route_query_value(req);
|
|
|
|
|
//printf( "%s = %s\n", key, value );
|
|
|
|
|
if( 0 == strcmp(key,"limit") ) {
|
|
|
|
|
int new_limit;
|
|
|
|
|
sscanf(value,"%d",&new_limit);
|
|
|
|
|
if( new_limit < limit ) {
|
|
|
|
|
limit = new_limit;
|
|
|
|
|
}
|
|
|
|
|
} else if( 0 == strcmp(key,"with_muted") ) {
|
|
|
|
|
hide_muted = false;
|
|
|
|
|
} else if( 0 == strcmp(key,"since_id") ) {
|
|
|
|
|
sscanf(value,"%d",&since_id);
|
|
|
|
|
} else if( 0 == strcmp(key,"max_id") ) {
|
|
|
|
|
sscanf(value,"%d",&max_id);
|
|
|
|
|
}
|
|
|
|
|
//printf( "Filter: limit=%d, max_id=%d, since_id=%d\n", limit, max_id, since_id );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct timeline* tl = timeline_from_id( timeline_id );
|
|
|
|
|
if( !tl ) {
|
|
|
|
@ -38,10 +63,24 @@ bool handle_timeline( struct http_request* req, int timeline_id )
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct status* ss[32];
|
|
|
|
|
int count = timeline_load_statuses( tl, 0, 32, ss );
|
|
|
|
|
printf( "count=%d\n", count );
|
|
|
|
|
show_statuses( req, ss, count );
|
|
|
|
|
struct status* ss[limit];
|
|
|
|
|
int count = timeline_load_statuses( tl, 0, limit, ss );
|
|
|
|
|
|
|
|
|
|
for( int i = 0; i < count; ++i ) {
|
|
|
|
|
if( ss[i]->id <= since_id ) {
|
|
|
|
|
count = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
int base = 0;
|
|
|
|
|
for( int i = 0; i < count; ++i ) {
|
|
|
|
|
if( ss[i]->id >= max_id ) {
|
|
|
|
|
base = i + 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//printf( "limit=%d, since_id=%d, base=%d\n", limit, since_id, base );
|
|
|
|
|
//printf( "count=%d\n", count - base );
|
|
|
|
|
show_statuses( req, &ss[base], count - base );
|
|
|
|
|
|
|
|
|
|
for( int i = 0; i < count; ++i ) {
|
|
|
|
|
status_free( ss[i] );
|
|
|
|
@ -91,7 +130,7 @@ bool route_mastodon_api( struct http_request* req )
|
|
|
|
|
|
|
|
|
|
//*
|
|
|
|
|
if( !check_bearer_token(req) ) { return false; }
|
|
|
|
|
printf( "authorization still valid\n" );
|
|
|
|
|
//printf( "authorization still valid\n" );
|
|
|
|
|
//*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|