|
|
|
@ -69,6 +69,7 @@ static struct json_object_field account_layout[] = {
|
|
|
|
|
JSON_FIELD_ARRAY_OF_STRINGS( aliases, false ),
|
|
|
|
|
JSON_FIELD_ENUM( account_type, account_types_enum, true ),
|
|
|
|
|
JSON_FIELD_STRING( inbox, false ),
|
|
|
|
|
JSON_FIELD_STRING( shared_inbox, false ),
|
|
|
|
|
JSON_FIELD_STRING( note, false ),
|
|
|
|
|
{
|
|
|
|
|
.key = "followers",
|
|
|
|
@ -257,6 +258,9 @@ bool account_sync_from_activity_pub( unsigned int account_id )
|
|
|
|
|
a->account_type = at_remote_activity_pub;
|
|
|
|
|
a->account_url = strdup(ap->url);
|
|
|
|
|
a->inbox = strdup(ap->inbox);
|
|
|
|
|
if( ap->shared_inbox ) {
|
|
|
|
|
a->shared_inbox = strdup(ap->shared_inbox);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( 0 == strncmp( ap->id, "https://", 8 ) ) {
|
|
|
|
|
char* server_name = strdup(&ap->id[8]);
|
|
|
|
@ -381,6 +385,7 @@ void account_free( struct account* a )
|
|
|
|
|
free(a->handle);
|
|
|
|
|
free(a->server);
|
|
|
|
|
free(a->inbox);
|
|
|
|
|
free(a->shared_inbox);
|
|
|
|
|
free(a->display_name);
|
|
|
|
|
free(a->account_url);
|
|
|
|
|
free(a->avatar.url);
|
|
|
|
@ -506,8 +511,15 @@ void account_announce( struct account* a, struct status* s )
|
|
|
|
|
str = strdup(origin_post_account->account_url);
|
|
|
|
|
array_append( &act->to, sizeof(str), &str );
|
|
|
|
|
|
|
|
|
|
account_deliver_activity_to_followers( a, act );
|
|
|
|
|
account_deliver_activity( origin_post_account, act );
|
|
|
|
|
struct outbox_envelope_list oel;
|
|
|
|
|
memset(&oel,0,sizeof(oel));
|
|
|
|
|
|
|
|
|
|
account_deliver_activity_to_followers( a, act, &oel );
|
|
|
|
|
account_deliver_activity( origin_post_account, act, &oel );
|
|
|
|
|
|
|
|
|
|
printf( "Delivering to %s inboxes\n", oel.count );
|
|
|
|
|
outbox_envelope_list_save(&oel);
|
|
|
|
|
outbox_envelope_list_free_composite(&oel);
|
|
|
|
|
|
|
|
|
|
ap_activity_save(act);
|
|
|
|
|
ap_activity_write_to_FILE( act, stdout );
|
|
|
|
@ -517,17 +529,31 @@ cleanup:
|
|
|
|
|
ap_activity_free(act);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void account_deliver_activity( struct account* a, struct ap_activity* act )
|
|
|
|
|
void account_deliver_activity( struct account* a, struct ap_activity* act, struct outbox_envelope_list* oel )
|
|
|
|
|
{
|
|
|
|
|
printf( "Delivering activity %s to account %s\n", act->id, a->account_url );
|
|
|
|
|
|
|
|
|
|
if( a->shared_inbox ) {
|
|
|
|
|
// Check if the sh
|
|
|
|
|
for( int i = 0; i < oel->count; ++i ) {
|
|
|
|
|
struct outbox_envelope* e = oel->items[i];
|
|
|
|
|
if( e->shared_inbox && 0 == strcmp(e->shared_inbox,a->shared_inbox) ) {
|
|
|
|
|
printf( "\tUsing shared inbox %s already in delivery list\n", a->shared_inbox );
|
|
|
|
|
// This account will get the message delivered thru the shared inbox
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct outbox_envelope* env = outbox_envelope_new();
|
|
|
|
|
env->activity_id = act->local_id;
|
|
|
|
|
if( a->shared_inbox ) {
|
|
|
|
|
env->shared_inbox = strdup(a->shared_inbox);
|
|
|
|
|
}
|
|
|
|
|
env->account_id = a->id;
|
|
|
|
|
outbox_envelope_save(env);
|
|
|
|
|
outbox_envelope_free(env);
|
|
|
|
|
array_append( oel, sizeof(env), &env );
|
|
|
|
|
}
|
|
|
|
|
void account_deliver_activity_to_followers( struct account* a, struct ap_activity* act )
|
|
|
|
|
void account_deliver_activity_to_followers( struct account* a, struct ap_activity* act, struct outbox_envelope_list* oel )
|
|
|
|
|
{
|
|
|
|
|
printf( "Delivering activity %s to followers of account %s\n", act->id, a->account_url );
|
|
|
|
|
struct {
|
|
|
|
@ -550,7 +576,7 @@ void account_deliver_activity_to_followers( struct account* a, struct ap_activit
|
|
|
|
|
int account_id = atoi(keys.items[j]);
|
|
|
|
|
printf( "account_id = %d\n", account_id );
|
|
|
|
|
struct account* follower_account = account_from_id(account_id);
|
|
|
|
|
account_deliver_activity( follower_account, act );
|
|
|
|
|
account_deliver_activity( follower_account, act, oel );
|
|
|
|
|
account_free(follower_account);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|