From b10d1f2e64205308d64a0e690f190a9840aa98b4 Mon Sep 17 00:00:00 2001 From: teknomunk Date: Fri, 15 Sep 2023 14:30:36 -0500 Subject: [PATCH] Make poll update work, and automatically sync with source --- src/controller/api/status.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/controller/api/status.c b/src/controller/api/status.c index 4e466cd..7a3bd1b 100644 --- a/src/controller/api/status.c +++ b/src/controller/api/status.c @@ -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; } }