mirror of
https://github.com/siv-org/siv.git
synced 2026-05-03 03:00:59 -04:00
Fix /api/is-unlock-blocked for new partials location
This commit is contained in:
@@ -18,6 +18,11 @@ export default async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
|
||||
// Begin preloading all these docs
|
||||
const loadTrustees = election.collection('trustees').orderBy('index', 'asc').get()
|
||||
const loadTrusteePartials = Promise.all(
|
||||
(await loadTrustees).docs.map(async (doc) =>
|
||||
(await doc.ref.collection('post-election-data').doc('partials').get()).data(),
|
||||
),
|
||||
)
|
||||
|
||||
// Confirm they're a valid admin that created this election
|
||||
const jwt = await checkJwtOwnsElection(req, res, election_id)
|
||||
@@ -52,16 +57,17 @@ export default async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
}
|
||||
return !waiting_on // Break out of loop when we find one
|
||||
})
|
||||
if (waiting_on) return res.status(206).send(waiting_on)
|
||||
if (waiting_on)
|
||||
return res.status(206).send(waiting_on)
|
||||
|
||||
// Check if any trustees haven't decrypted
|
||||
trustees.every(({ email, partials }, index) => {
|
||||
// Check if any trustees haven't decrypted
|
||||
;(await loadTrusteePartials).every((data, index) => {
|
||||
// Skip admin
|
||||
if (index === 0) return true
|
||||
|
||||
const num_decrypted = (partials || {})[first_col]?.length || 0
|
||||
const num_decrypted = (data?.partials || {})[first_col]?.length || 0
|
||||
if (num_decrypted < num_admin_shuffled) {
|
||||
waiting_on = email
|
||||
waiting_on = trustees[index].email
|
||||
}
|
||||
return !waiting_on // Break out of loop when we find one
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user