|
|
|
@ -39,45 +39,25 @@ bool handle_timeline( struct http_request* req, int timeline_id )
|
|
|
|
|
} params = {
|
|
|
|
|
.since_id = 0,
|
|
|
|
|
.limit = 32,
|
|
|
|
|
.max_id = INT_MAX,
|
|
|
|
|
.max_id = 2147483647,
|
|
|
|
|
.hide_muted = true,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define OBJ_TYPE struct params_t
|
|
|
|
|
static struct http_query_fields fields[] = {
|
|
|
|
|
{ "since_id", offsetof(struct params_t,since_id), qf_string },
|
|
|
|
|
{ "limit", offsetof(struct params_t,limit), qf_integer },
|
|
|
|
|
{ "max_id", offsetof(struct params_t,max_id), qf_integer },
|
|
|
|
|
{ "hide_muted", offsetof(struct params_t,hide_muted), qf_bool },
|
|
|
|
|
{ NULL },
|
|
|
|
|
HTTP_QUERY_FIELD_INT( since_id )
|
|
|
|
|
HTTP_QUERY_FIELD_INT( limit )
|
|
|
|
|
HTTP_QUERY_FIELD_INT( max_id )
|
|
|
|
|
HTTP_QUERY_FIELD_BOOL( hide_muted )
|
|
|
|
|
HTTP_QUERY_FIELD_END
|
|
|
|
|
};
|
|
|
|
|
#undef OBJ_TYPE
|
|
|
|
|
|
|
|
|
|
// handle query parameters
|
|
|
|
|
// TODO: split this off into a generic filter handling
|
|
|
|
|
if( http_request_route( req, "?" ) ) {
|
|
|
|
|
http_query_parse( req, fields, ¶ms );
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
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( !value ) {
|
|
|
|
|
} else 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 );
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
if( params.limit > 32 ) { params.limit = 32; }
|
|
|
|
|
|
|
|
|
@ -105,11 +85,15 @@ bool handle_timeline( struct http_request* req, int timeline_id )
|
|
|
|
|
// Filter
|
|
|
|
|
for( int i = 0; i < count; ++i ) {
|
|
|
|
|
struct status* s = ss[i];
|
|
|
|
|
if( s->id <= params.since_id ) { continue; }
|
|
|
|
|
if( s->id >= params.max_id ) { continue; };
|
|
|
|
|
if( s->id <= params.since_id ) { goto filtered; }
|
|
|
|
|
if( s->id >= params.max_id ) { goto filtered; }
|
|
|
|
|
|
|
|
|
|
show.items[show.count] = s;
|
|
|
|
|
show.count += 1;
|
|
|
|
|
if( 0 ) {
|
|
|
|
|
filtered:
|
|
|
|
|
//printf( "Filtered out %d\n", s->id );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
show_statuses( req, show.items, show.count );
|
|
|
|
|