@ -84,6 +84,17 @@ failed:
goto cleanup ;
}
static bool route_undo_Announce ( struct ap_activity * act )
{
struct status * s = NULL ;
s = status_from_uri ( act - > object . ptr - > id ) ;
if ( ! s ) { return true ; } // Status not local, discard
status_free ( s ) ;
return false ;
}
static bool route_undo_activity ( struct ap_activity * act )
{
if ( act - > object . tag ! = apaot_activity ) {
@ -96,7 +107,8 @@ static bool route_undo_activity( struct ap_activity* act )
}
switch ( act - > object . ptr - > type ) {
case apat_follow : return route_undo_follow ( act ) ;
case apat_follow : return route_undo_follow ( act ) ;
case apat_announce : return route_undo_Announce ( act ) ;
default :
printf ( " Unhandled object activity type %d in undo \n " , act - > object . ptr - > type ) ;
return false ;
@ -214,7 +226,7 @@ static bool route_update( struct ap_activity* act )
if ( act - > object . tag = = apaot_activity ) {
if ( act - > object . ptr - > type = = apat_note ) {
s = status_from_uri ( act - > object . ptr - > id ) ;
if ( ! s ) { return false; }
if ( ! s ) { return true; } // Status not available locally, discard
} else if ( act - > object . ptr - > type = = apat_person ) {
return route_update_Person ( act ) ;
} else {
@ -222,7 +234,7 @@ static bool route_update( struct ap_activity* act )
}
} else if ( act - > object . tag = = apaot_ref ) {
s = status_from_uri ( act - > object . ref ) ;
if ( ! s ) { return false; }
if ( ! s ) { return true; } // Status not available locally, discard
}
status_sync_from_uri ( s , s - > url ) ;
@ -239,9 +251,6 @@ static bool route_move( struct ap_activity* act )
if ( act - > object . tag ! = apaot_ref ) { goto discard ; }
// TODO: make this work
printf ( " TODO: move %s to %s \n " , act - > object . ref , act - > target ) ;
// Make sure this belongs to a local account
a = account_from_uri ( act - > object . ref ) ;
if ( ! a ) { goto discard ; }
@ -272,10 +281,14 @@ static bool route_create( struct ap_activity* act )
{
struct status * s = NULL ;
bool result = false ;
struct account * actor_account = NULL ;
struct account * owner_account = NULL ;
// Requires an object
// TODO: if there is a ref here, fetch the object
if ( act - > object . tag ! = apaot_activity ) { return false ; }
if ( act - > object . tag ! = apaot_activity ) {
printf ( " TODO: fetch activity from %s \n " , act - > object . ref ) ;
return false ;
}
struct ap_activity * obj = act - > object . ptr ;
bool mentions_me = false ;
@ -299,18 +312,20 @@ static bool route_create( struct ap_activity* act )
check_is_follower :
// Get actor account
struct account * actor_account = account_from_uri_or_fetch ( obj - > actor ) ;
actor_account = account_from_uri_or_fetch ( obj - > actor ) ;
if ( ! actor_account ) {
printf ( " ! Unable to fetch %s \n " , obj - > actor ) ;
goto failed ;
}
owner_account = account_from_id ( owner_account_id ) ;
if ( account_does_follow ( actor_account, owner_account_ id ) ) {
if ( account_does_follow ( owner_account, actor_account - > id ) ) {
follows_me = true ;
}
if ( ! follows_me & & ! mentions_me ) {
// Discard without action
printf ( " Discarding create. follows_me=%c, mentions_me=%c \n " , follows_me ? ' T ' : ' F ' , mentions_me ? ' T ' : ' F ' ) ;
result = true ;
goto cleanup ;
}
@ -351,6 +366,7 @@ check_is_follower:
result = true ;
cleanup :
account_free ( actor_account ) ;
account_free ( owner_account ) ;
status_free ( s ) ;
return result ;
failed :
@ -402,6 +418,7 @@ static bool process_one()
printf ( " Inbox has %d items pending processing... \n " , ( head_pos - tail_pos ) ) ;
int id = tail_pos + 1 ;
printf ( " Next item is #%d \n " , id ) ;
env = ap_envelope_from_id ( id ) ;
bool step_tail = false ;