From 8dea5627b31ff666428a668edb54974d6442b13e Mon Sep 17 00:00:00 2001 From: Janis Erdmanis Date: Sun, 7 Jul 2024 00:56:05 +0300 Subject: [PATCH] allow tracking by proposal index --- src/Server/Mapper.jl | 3 ++- src/Server/Service.jl | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Server/Mapper.jl b/src/Server/Mapper.jl index 92df502..8371a6c 100644 --- a/src/Server/Mapper.jl +++ b/src/Server/Mapper.jl @@ -641,7 +641,8 @@ end get_ballotbox(uuid::UUID) = get(POLLING_STATION, uuid) -get_proposal(uuid::UUID) = get_ballotbox(uuid).ledger.proposal +get_proposal(uuid::UUID) = get_ballotbox(uuid).ledger.proposal +get_proposal(index::Int) = BRAID_CHAIN[index]::Proposal get_tally(uuid::UUID) = ballotbox(uuid).tally diff --git a/src/Server/Service.jl b/src/Server/Service.jl index ef16084..68c8a4f 100644 --- a/src/Server/Service.jl +++ b/src/Server/Service.jl @@ -276,13 +276,17 @@ end return ack |> json end -@get "/poolingstation/{uuid_hex}/track" function(req::Request, uuid_hex::String) +#@get "/poolingstation/{uuid_hex}/track" function(req::Request, uuid_hex::String) +@get "/poolingstation/{N}/track" function(req::Request, N::Int) # A dirty hack if Mapper.now() - Authorization.timestamp(req) > Second(60) return Response(401, "Request Rejected: The timestamp associated with this request is outdated and cannot be processed. Please ensure your device's clock is correctly set and resend your request.") end - uuid = UUID(uuid_hex) + #uuid = UUID(uuid_hex) + #bbox = Mapper.get_ballotbox(uuid) + proposal = Mapper.get_proposal(N) + uuid = proposal.uuid bbox = Mapper.get_ballotbox(uuid) credential = Authorization.credential(req) @@ -292,7 +296,6 @@ end # @parent return Response(401, "No tracking number with credential $credential found") # end - value = get(bbox.access, credential, nothing) isnothing(value) && return Response(401, "No tracking number with credential $credential found") (key, permit) = value