Skip to content

Commit

Permalink
allow tracking by proposal index
Browse files Browse the repository at this point in the history
  • Loading branch information
Janis Erdmanis committed Jul 6, 2024
1 parent ce80877 commit 8dea562
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/Server/Mapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 6 additions & 3 deletions src/Server/Service.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 8dea562

Please sign in to comment.