diff --git a/src/controller/outbox.c b/src/controller/outbox.c index c248115..83a9e4c 100644 --- a/src/controller/outbox.c +++ b/src/controller/outbox.c @@ -20,6 +20,47 @@ #include #include #include +#include + +static bool blacklisted( struct outbox_envelope* env ) +{ + FILE* f = NULL; + bool result = false; + char* line = NULL; + size_t len = 0; + + if( !env->shared_inbox ) { goto return_false; } + + f = fopen( "data/host_blacklist.txt", "r" ); + if( !f ) { goto return_false; } + + while( -1 != getline( &line, &len, f ) ) { + len = strlen(line); + char* item = line; + while( isspace( item[len-1] ) ) { item[len-1] = '\0'; len -= 1; } + while( isspace( *item ) ) { ++item; len -= 1; } + + if( !*item ) { continue; } + + printf( "Blackisting item: '%s'\n", item ); + if( 0 == strncmp( env->shared_inbox, item, len ) ) { goto return_true; } + } + + goto return_false; + +return_true: + result = true; + goto cleanup; +return_false: + result = false; + goto cleanup; + +cleanup: + if( f ) { fclose(f); } + free(line); + + return result; +} static bool process_envelope( struct outbox_envelope* env ) { @@ -35,9 +76,16 @@ static bool process_envelope( struct outbox_envelope* env ) if( env->account_id == 0 ) { goto discard; } printf( "Processing outbox/%d.json\n", env->id ); + printf( "shared_inbox=%s\b", env->shared_inbox ); printf( "account_id=%d\n", env->account_id ); printf( "activity_id=%d\n", env->activity_id ); + // Check blacklist if at least one attempt to deliver has been made + if( ( env->retries > 0 ) && blacklisted( env ) ) { + printf( "Matched host blacklist\n" ); + goto discard; + } + // Get outbox URL to_account = account_from_id( env->account_id ); diff --git a/src/json b/src/json index ca1695c..2d81ba6 160000 --- a/src/json +++ b/src/json @@ -1 +1 @@ -Subproject commit ca1695c79ebd587bb5c2ba56ac9ebc0b07bb3d20 +Subproject commit 2d81ba6575bfade5b2fbd723d2ec0e900fd4042f diff --git a/src/model/status.c b/src/model/status.c index 72cc190..aa1f5b2 100644 --- a/src/model/status.c +++ b/src/model/status.c @@ -746,6 +746,13 @@ void status_get_context( struct status* s, void* ancestors_ptr, void* replies_pt void status_add_react( struct status* s, const char* react, struct account* a ) { + if( s->repost_id ) { + struct status* reposted_status = status_from_id( s->repost_id ); + status_add_react(reposted_status,react,a); + status_free(reposted_status); + return; + } + // generate outbox element if( a->id == owner_account_id ) { if( s->account_id == owner_account_id ) { @@ -798,6 +805,13 @@ done: } void status_remove_react( struct status* s, const char* react, struct account* a ) { + if( s->repost_id ) { + struct status* reposted_status = status_from_id( s->repost_id ); + status_remove_react(reposted_status,react,a); + status_free(reposted_status); + return; + } + // TODO: generate outbox element printf( "TODO: generate outbox activity for removing reaction '%s' to status #%d by account #%d\n", react, s->id, a->id ); /// Find react activity we need to Undo @@ -838,6 +852,13 @@ update_entry: } void status_add_like( struct status* s, struct account* a ) { + if( s->repost_id ) { + struct status* reposted_status = status_from_id( s->repost_id ); + status_add_like(reposted_status,a); + status_free(reposted_status); + return; + } + for( int i = 0; i < s->likes.count; ++i ) { if( s->likes.items[i] == a->id ) { return; @@ -870,6 +891,13 @@ void status_add_like( struct status* s, struct account* a ) } void status_remove_like( struct status* s, struct account* a ) { + if( s->repost_id ) { + struct status* reposted_status = status_from_id( s->repost_id ); + status_remove_like(reposted_status,a); + status_free(reposted_status); + return; + } + for( int i = 0; i < s->likes.count; ++i ) { if( s->likes.items[i] == a->id ) { // Swap with last element