@ -89,51 +89,54 @@ void account_create( struct account* a, struct status* s )
status_add_to_timeline ( s , home_timeline_id ) ;
//status_add_post_to_timeline( s, federated_timeline_id );
struct outbox_envelope_list oel ;
memset ( & oel , 0 , sizeof ( oel ) ) ;
account_deliver_activity_to_followers ( a , create , & oel ) ;
printf ( " Delivering to %d inboxes \n " , oel . count ) ;
outbox_envelope_list_save ( & oel ) ;
outbox_envelope_list_free_composite ( & oel ) ;
//account_deliver_activity_to_followers( a, create, &oel );
activity_deliver ( create ) ;
ap_object_free ( create ) ;
ap_object_free ( note ) ;
}
void account_announce ( struct account * a , struct status * original_post , struct status * local_repost )
struct status * account_announce ( struct account * a , struct status * original_post , struct status * local_repost , struct ap_object * act )
{
struct ap_object * act = ap_object_new ( ) ;
activity_allocate_local_id ( act ) ;
act - > id = aformat ( " https://%s/activity/%d " , g_server - > domain , act - > local_id ) ;
act - > published = time ( NULL ) ;
act - > type = ap_Announce ;
act - > actor = strdup ( a - > account_url ) ;
act - > object . tag = apaot_ref ;
act - > object . ref = strdup ( original_post - > url ) ;
// Create To: list
char * str = strdup ( " https://www.w3.org/ns/activitystreams#Public " ) ;
array_append ( & act - > to , sizeof ( str ) , & str ) ;
str = aformat ( " https://%s/owner/followers " , g_server - > domain ) ;
array_append ( & act - > to , sizeof ( str ) , & str ) ;
struct account * origin_post_account = account_from_id ( original_post - > account_id ) ;
str = strdup ( origin_post_account - > account_url ) ;
array_append ( & act - > to , sizeof ( str ) , & str ) ;
if ( ! local_repost ) {
local_repost = status_new_repost ( original_post , a ) ;
struct outbox_envelope_list oel ;
memset ( & oel , 0 , sizeof ( oel ) ) ;
// Flag the status as reposted
original_post - > reposted_status_id = local_repost - > id ;
status_save ( original_post ) ;
account_deliver_activity_to_followers ( a , act , & oel ) ;
account_deliver_activity ( origin_post_account , act , & oel ) ;
// Add repost to timelines
status_add_to_timeline ( local_repost , a - > id ) ;
if ( a - > id = = owner_account_id ) {
status_add_to_timeline ( local_repost , home_timeline_id ) ;
}
status_add_to_timeline ( local_repost , public_timeline_id ) ;
}
printf ( " Delivering to %d inboxes \n " , oel . count ) ;
outbox_envelope_list_save ( & oel ) ;
outbox_envelope_list_free_composite ( & oel ) ;
if ( ! act ) {
act = ap_object_new ( ) ;
activity_allocate_local_id ( act ) ;
act - > id = aformat ( " https://%s/activity/%d " , g_server - > domain , act - > local_id ) ;
act - > published = time ( NULL ) ;
act - > type = ap_Announce ;
act - > object . tag = apaot_ref ;
act - > object . ref = strdup ( original_post - > url ) ;
act - > actor = strdup ( a - > account_url ) ;
// Create To: list
char * str = strdup ( " https://www.w3.org/ns/activitystreams#Public " ) ;
array_append ( & act - > to , sizeof ( str ) , & str ) ;
str = aformat ( " https://%s/owner/followers " , g_server - > domain ) ;
array_append ( & act - > to , sizeof ( str ) , & str ) ;
struct account * origin_post_account = account_from_id ( original_post - > account_id ) ;
str = strdup ( origin_post_account - > account_url ) ;
array_append ( & act - > to , sizeof ( str ) , & str ) ;
account_free ( origin_post_account ) ;
}
activity_save ( act ) ;
ap_object_write_to_FILE ( act , stdout ) ;
activity_deliver ( act ) ;
// Link status to activity
local_repost - > activity_id = act - > local_id ;
@ -143,8 +146,9 @@ void account_announce( struct account* a, struct status* original_post, struct s
status_save ( original_post ) ;
cleanup :
account_free ( origin_post_account ) ;
ap_object_free ( act ) ;
return local_repost ;
}
void account_follow ( struct account * a , struct account * to_follow )
@ -216,14 +220,7 @@ void account_update( struct account* a )
char * str = aformat ( " https://%s/owner/followers " , g_server - > domain ) ;
array_append ( & act - > to , sizeof ( str ) , & str ) ;
struct outbox_envelope_list oel ;
memset ( & oel , 0 , sizeof ( oel ) ) ;
account_deliver_activity_to_followers ( a , act , & oel ) ;
printf ( " Delivering to %d inboxes \n " , oel . count ) ;
outbox_envelope_list_save ( & oel ) ;
outbox_envelope_list_free_composite ( & oel ) ;
activity_deliver ( act ) ;
activity_save ( act ) ;
ap_object_free ( act ) ;