|
|
|
@ -280,7 +280,6 @@ struct ap_object* account_ap_outbox_page( struct account* a, int page )
|
|
|
|
|
} values;
|
|
|
|
|
memset( &values, 0, sizeof(values) );
|
|
|
|
|
ffdb_trie_list( buffer, page * items_per_page, items_per_page, NULL, &values );
|
|
|
|
|
printf( "items: %d\n", values.count );
|
|
|
|
|
for( int i = 0; i < values.count; ++i ) {
|
|
|
|
|
int id;
|
|
|
|
|
int activity_id = 0;
|
|
|
|
@ -322,7 +321,9 @@ struct ap_object* account_ap_outbox_page( struct account* a, int page )
|
|
|
|
|
|
|
|
|
|
array_append( &outbox->collection_items, sizeof(r), &r );
|
|
|
|
|
}
|
|
|
|
|
free( values.items[i] );
|
|
|
|
|
}
|
|
|
|
|
free( values.items );
|
|
|
|
|
|
|
|
|
|
outbox->type = apot_ordered_collection_page;
|
|
|
|
|
outbox->published = time(NULL);
|
|
|
|
@ -338,6 +339,75 @@ struct ap_object* account_ap_outbox_page( struct account* a, int page )
|
|
|
|
|
return outbox;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct ap_object* account_ap_followers( struct account* a )
|
|
|
|
|
{
|
|
|
|
|
if( a->id != 0 ) { return NULL; }
|
|
|
|
|
|
|
|
|
|
struct ap_object* o;
|
|
|
|
|
o = malloc(sizeof(*o));
|
|
|
|
|
memset(o,0,sizeof(*o));
|
|
|
|
|
|
|
|
|
|
o->type = apot_ordered_collection;
|
|
|
|
|
o->published = time(NULL);
|
|
|
|
|
o->id = aformat( "https://%s/owner/followers", g_server_name );
|
|
|
|
|
o->first.tag = apaot_object;
|
|
|
|
|
o->first.ptr = account_ap_followers_page( a, 0 );
|
|
|
|
|
char buffer[512];
|
|
|
|
|
o->total_items = ffdb_trie_count( format( buffer, 512, "data/accounts/%d/followers", a->id ) );
|
|
|
|
|
|
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
struct ap_object* account_ap_followers_page( struct account* a, int page )
|
|
|
|
|
{
|
|
|
|
|
if( a->id != 0 ) { return NULL; }
|
|
|
|
|
|
|
|
|
|
enum { items_per_page = 10 };
|
|
|
|
|
char buffer[512];
|
|
|
|
|
int total_items = ffdb_trie_count( format( buffer, 512, "data/accounts/%d/followers", a->id ) );
|
|
|
|
|
int page_count = ( total_items + items_per_page - 1 ) / items_per_page;
|
|
|
|
|
|
|
|
|
|
if( page >= page_count ) { return NULL; }
|
|
|
|
|
|
|
|
|
|
struct ap_object* o;
|
|
|
|
|
o = malloc(sizeof(*o));
|
|
|
|
|
memset(o,0,sizeof(*o));
|
|
|
|
|
|
|
|
|
|
struct {
|
|
|
|
|
char** items;
|
|
|
|
|
int count;
|
|
|
|
|
} values;
|
|
|
|
|
memset( &values, 0, sizeof(values) );
|
|
|
|
|
ffdb_trie_list( buffer, page * items_per_page, items_per_page, &values, NULL );
|
|
|
|
|
for( int i = 0; i < values.count; ++i ) {
|
|
|
|
|
int id;
|
|
|
|
|
if( 1 != sscanf( values.items[i], "%d", &id ) ) { continue; }
|
|
|
|
|
free( values.items[i] );
|
|
|
|
|
|
|
|
|
|
struct account* follower = account_from_id(id);
|
|
|
|
|
if( !follower ) { continue; }
|
|
|
|
|
|
|
|
|
|
struct ap_object_ptr_or_ref r;
|
|
|
|
|
r.tag = apaot_ref;
|
|
|
|
|
r.ref = strdup( follower->account_url );
|
|
|
|
|
array_append( &o->collection_items, sizeof(r), &r );
|
|
|
|
|
account_free(follower);
|
|
|
|
|
}
|
|
|
|
|
free( values.items );
|
|
|
|
|
|
|
|
|
|
o->type = apot_ordered_collection_page;
|
|
|
|
|
o->published = time(NULL);
|
|
|
|
|
o->part_of = aformat( "https://%s/owner/followers", g_server_name );
|
|
|
|
|
o->id = aformat( "https://%s/owner/followers/page-%d", g_server_name, page );
|
|
|
|
|
if( page > 0 ) {
|
|
|
|
|
o->prev = aformat( "https://%s/owner/followers/page-%d", g_server_name, page - 1 );
|
|
|
|
|
}
|
|
|
|
|
if( page < page_count - 1 ) {
|
|
|
|
|
o->next = aformat( "https://%s/owner/followers/page-%d", g_server_name, page + 1 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct ap_object* account_activity_pub( struct account* a )
|
|
|
|
|
{
|
|
|
|
|
return account_ap_actor(a);
|
|
|
|
|