|
|
|
@ -510,19 +510,11 @@ bool route_polls( struct http_request* req )
|
|
|
|
|
{
|
|
|
|
|
bool result = false;
|
|
|
|
|
struct status* s = NULL;
|
|
|
|
|
//struct account* owner = NULL;
|
|
|
|
|
|
|
|
|
|
if( http_request_route_term( req, "" ) ) {
|
|
|
|
|
if( http_request_route_method( req, "POST" ) ) {
|
|
|
|
|
if( !check_authentication_header(req) ) { return false; }
|
|
|
|
|
|
|
|
|
|
if( !check_authentication_header(req) ) { return false; }
|
|
|
|
|
|
|
|
|
|
struct account* owner = account_from_id(owner_account_id);
|
|
|
|
|
bool res = handle_post(req, owner);
|
|
|
|
|
account_free(owner);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
//owner = account_from_id(owner_account_id);
|
|
|
|
|
|
|
|
|
|
if( !http_request_route( req, "/" ) ) { return false; }
|
|
|
|
|
|
|
|
|
@ -534,7 +526,15 @@ bool route_polls( struct http_request* req )
|
|
|
|
|
// Make sure the status has a poll
|
|
|
|
|
if( !s->poll ) { goto failed; }
|
|
|
|
|
|
|
|
|
|
if( http_request_route_term( req, "votes" ) ) {
|
|
|
|
|
if( http_request_route_term( req, "" ) ) {
|
|
|
|
|
status_sync(s);
|
|
|
|
|
|
|
|
|
|
http_request_send_headers( req, 200, "application/json", true );
|
|
|
|
|
FILE* f = http_request_get_response_body( req );
|
|
|
|
|
api_Poll_write( s->poll, f, 0 );
|
|
|
|
|
|
|
|
|
|
goto success;
|
|
|
|
|
} else if( http_request_route_term( req, "votes" ) ) {
|
|
|
|
|
if( http_request_route_method( req, "POST" ) ) {
|
|
|
|
|
if( handle_votes( req, s ) ) { goto success; }
|
|
|
|
|
}
|
|
|
|
|