mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2026-04-28 11:17:38 +02:00
Changed test user ID, added variable for storing questions while processing them, simplifyquestion checking for keys before using them
This commit is contained in:
@@ -64,6 +64,7 @@ function ProcessIncomingRequest(recievedData, qdb, infos, dryRun, user) {
|
||||
try {
|
||||
// recievedData: { version: "", id: "", subj: "" quiz: {} }
|
||||
let data = recievedData
|
||||
const recievedQuestions = []
|
||||
// FIXME: if is for backwards compatibility, remove this sometime in the future
|
||||
if (typeof data !== 'object') {
|
||||
data = JSON.parse(recievedData)
|
||||
@@ -87,6 +88,7 @@ function ProcessIncomingRequest(recievedData, qdb, infos, dryRun, user) {
|
||||
3
|
||||
)
|
||||
logger.DebugLog(currentQuestion, 'actions', 3)
|
||||
recievedQuestions.push(currentQuestion)
|
||||
questionSearchPromises.push(searchData(qdb, currentQuestion, data.subj))
|
||||
})
|
||||
|
||||
@@ -95,7 +97,7 @@ function ProcessIncomingRequest(recievedData, qdb, infos, dryRun, user) {
|
||||
const allQuestions = [] // all new questions here that do not have result
|
||||
results.forEach((result, i) => {
|
||||
if (result.length === 0) {
|
||||
allQuestions.push(data.quiz[i])
|
||||
allQuestions.push(recievedQuestions[i])
|
||||
}
|
||||
})
|
||||
|
||||
@@ -170,7 +172,10 @@ function ProcessIncomingRequest(recievedData, qdb, infos, dryRun, user) {
|
||||
})
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
logger.Log('There was en error handling incoming quiz data, see stderr', logger.GetColor('redbg'))
|
||||
logger.Log(
|
||||
'There was en error handling incoming quiz data, see stderr',
|
||||
logger.GetColor('redbg')
|
||||
)
|
||||
reject(new Error('Couldnt parse JSON data'))
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user