Fix filter in handle_timeline, add published time to locally-sourced statuses, make like point to ap_activity_like stub

master
teknomunk 1 year ago
parent 1bcb3af898
commit 9b0c820e52

3
.gitignore vendored

@ -8,3 +8,6 @@ release
data/
assets/soapbox/
backup/
vgcore.*
/*.log
/*.json

@ -70,6 +70,8 @@ bool handle_post( struct http_request* req, struct account* a )
s = malloc(sizeof(struct status));
memset(s,0,sizeof(*s));
s->published = time(NULL);
char* key;
while( key = json_pull_parser_read_object_key(jpp) ) {
if( 0 == strcmp(key,"media_ids") ) {

@ -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, &params );
}
/*
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 );

@ -1 +1 @@
Subproject commit f4b7a303cb6a3a87fd8f8089bf85688158522580
Subproject commit b792543d754290e2c3b1b83ffe0123f8dc90fdbd

@ -283,3 +283,13 @@ failed:
goto cleanup;
}
struct ap_activity* ap_activity_create_like( struct status* s )
{
}
int ap_activity_like( struct status* s )
{
printf( "TODO: like\n" );
return -1;
}

@ -138,3 +138,6 @@ void ap_activity_unfollow( struct account* follower, struct account* to_unfollow
struct ap_activity* ap_activity_create_undo( struct ap_activity* act );
void ap_activity_undo( struct ap_activity* act, int deliver_to_account_id );
struct ap_activity* ap_activity_create_like( struct status* s );
int ap_activity_like( struct status* s );

@ -197,7 +197,6 @@ void status_add_react( struct status* s, const char* react, struct account* a )
}
}
// TODO: generate notification
if( s->account_id == owner_account_id && a->id != owner_account_id ) {
// Create notification for liking the owner's post
struct notification* note = notification_new();
@ -279,14 +278,18 @@ void status_add_like( struct status* s, struct account* a )
}
}
if( s->account_id == owner_account_id && a->id != owner_account_id ) {
// Create notification for liking the owner's post
struct notification* note = notification_new();
note->type = nt_like;
note->account_id = a->id;
note->created_at = time(NULL);
notification_save( note );
notification_free( note );
if( s->account_id == owner_account_id ) {
if( a->id != owner_account_id ) {
// Create notification for liking the owner's post
struct notification* note = notification_new();
note->type = nt_like;
note->account_id = a->id;
note->created_at = time(NULL);
notification_save( note );
notification_free( note );
}
} else {
ap_activity_like( s );
}
status_save(s);

Loading…
Cancel
Save