teknomunk 3 months ago
commit fa96756d01

@ -170,14 +170,38 @@ static bool handle_relationships( struct http_request* req )
return true;
}
// Route: /api/v1/accounts/update_credentials
bool route_api_account_update_credentials( struct http_request* req )
{
if( !http_request_route_method( req, "PATCH" ) ) {
return false;
}
FILE* f = http_request_get_request_data( req );
printf( "Request body:\n" );
int c;
while( (c=fgetc(f)) != EOF ) {
fputc(c,stdout);
}
printf( "\nEnd of body (last=%d)\n", c );
struct account* owner = account_from_id(owner_account_id);
bool res = handle_mastodon_api_show_account( req, owner );
account_free(owner);
return res;
}
// Route: /api/v1/accounts/
bool route_api_account( struct http_request* req )
{
if( http_request_route_term( req, "verify_credentials" ) || http_request_route_term( req, "update_credentials" ) ) {
struct account* owner = account_from_id(0);
if( http_request_route_term( req, "verify_credentials" ) ) {
struct account* owner = account_from_id(owner_account_id);
bool res = handle_mastodon_api_show_account( req, owner );
account_free(owner);
return res;
} else if( http_request_route_term( req, "update_credentials" ) ) {
return route_api_account_update_credentials(req);
} else if( http_request_route( req, "relationships?" ) ) {
return handle_relationships(req);
} else if( http_request_route( req, "statuses" ) ) {
@ -191,16 +215,17 @@ bool route_api_account( struct http_request* req )
return res;
}
// Route: /api/v1/accounts/%d{id}
int id = 0;
if( !get_local_account_id( req, &id ) ) {
return false;
}
// Make sure the account exists before allowing anything to be done with it
struct account* a = account_from_id( id );
if( !a ) { return false; }
// Route: /api/v1/accounts/%d{id}
// Account-specific routes
if( http_request_route( req, "statuses" ) ) {
bool res = handle_timeline( req, id );
account_free(a);

@ -378,6 +378,8 @@ struct account* account_from_uri_or_fetch( const char* uri )
}
void account_index_webfinger( struct account* a )
{
mkdir( "data/accounts/webfinger", 0750 );
char webfinger_name[512];
snprintf( webfinger_name, 512, "%s@%s", a->handle, a->server );
hash_index_set( "data/accounts/webfinger", webfinger_name, a->id );
@ -750,14 +752,16 @@ void account_remove_follower( struct account* a, struct account* follower )
follower->following_count = ffdb_trie_count(filename);
// create a notification for unfollow
struct notification* note = notification_new();
note->debug = 5;
note->type = nt_unfollow;
note->account_id = -1;
note->ref_account_id = follower->id;
note->created_at = time(NULL);
notification_save( note );
notification_free( note );
if( a->id == owner_account_id ) {
struct notification* note = notification_new();
note->debug = 5;
note->type = nt_unfollow;
note->account_id = -1;
note->ref_account_id = follower->id;
note->created_at = time(NULL);
notification_save( note );
notification_free( note );
}
}
struct int_array {

Loading…
Cancel
Save