|
|
|
@ -339,31 +339,11 @@ struct ap_object* account_ap_outbox_page( struct account* a, int page )
|
|
|
|
|
return outbox;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct ap_object* account_ap_followers( struct account* a )
|
|
|
|
|
static struct ap_object* account_list_page( int page, char* part_of, const char* page_format, const char* trie_filename )
|
|
|
|
|
{
|
|
|
|
|
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 total_items = ffdb_trie_count( trie_filename );
|
|
|
|
|
int page_count = ( total_items + items_per_page - 1 ) / items_per_page;
|
|
|
|
|
|
|
|
|
|
if( page >= page_count ) { return NULL; }
|
|
|
|
@ -396,18 +376,84 @@ struct ap_object* account_ap_followers_page( struct account* a, int page )
|
|
|
|
|
|
|
|
|
|
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 );
|
|
|
|
|
o->part_of = part_of;
|
|
|
|
|
o->id = aformat( page_format, page );
|
|
|
|
|
if( page > 0 ) {
|
|
|
|
|
o->prev = aformat( "https://%s/owner/followers/page-%d", g_server_name, page - 1 );
|
|
|
|
|
o->prev = aformat( page_format, page - 1 );
|
|
|
|
|
}
|
|
|
|
|
if( page < page_count - 1 ) {
|
|
|
|
|
o->next = aformat( "https://%s/owner/followers/page-%d", g_server_name, page + 1 );
|
|
|
|
|
o->next = aformat( page_format, page + 1 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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; }
|
|
|
|
|
|
|
|
|
|
char* part_of = aformat( "https://%s/owner/followers", g_server_name );
|
|
|
|
|
char page_format[512];
|
|
|
|
|
snprintf( page_format, 512, "https://%s/owner/followers/page-%%d", g_server_name );
|
|
|
|
|
|
|
|
|
|
char trie_filename[512];
|
|
|
|
|
snprintf( trie_filename, 512, "data/accounts/%d/followers", a->id );
|
|
|
|
|
|
|
|
|
|
return account_list_page( page, part_of, page_format, trie_filename );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct ap_object* account_ap_following( 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/following", g_server_name );
|
|
|
|
|
o->first.tag = apaot_object;
|
|
|
|
|
o->first.ptr = account_ap_following_page( a, 0 );
|
|
|
|
|
char buffer[512];
|
|
|
|
|
o->total_items = ffdb_trie_count( format( buffer, 512, "data/accounts/%d/following", a->id ) );
|
|
|
|
|
|
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct ap_object* account_ap_following_page( struct account* a, int page )
|
|
|
|
|
{
|
|
|
|
|
if( a->id != 0 ) { return NULL; }
|
|
|
|
|
|
|
|
|
|
char* part_of = aformat( "https://%s/owner/following", g_server_name );
|
|
|
|
|
char page_format[512];
|
|
|
|
|
snprintf( page_format, 512, "https://%s/owner/following/page-%%d", g_server_name );
|
|
|
|
|
|
|
|
|
|
char trie_filename[512];
|
|
|
|
|
snprintf( trie_filename, 512, "data/accounts/%d/following", a->id );
|
|
|
|
|
|
|
|
|
|
return account_list_page( page, part_of, page_format, trie_filename );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct ap_object* account_activity_pub( struct account* a )
|
|
|
|
|
{
|
|
|
|
|
return account_ap_actor(a);
|
|
|
|
|