diff --git a/src/modules/api/api.ts b/src/modules/api/api.ts index a50880b..ef47b5b 100644 --- a/src/modules/api/api.ts +++ b/src/modules/api/api.ts @@ -208,7 +208,7 @@ function GetApp(): ModuleType { rootRedirectURL = utils.ReadFile(rootRedirectToFile) } - function userShouldGetUserSpecificMOTD(id) { + function userShouldGetUserSpecificMOTD(id, cid) { let shouldSee = true let write = false @@ -226,7 +226,7 @@ function GetApp(): ModuleType { if (userSpecificMotd[id].seeCounter) { if (userSpecificMotd[id].seeCounter <= 1) { shouldSee = false - } else { + } else if (cid) { userSpecificMotd[id].seeCounter -= 1 write = true } @@ -1137,11 +1137,9 @@ function GetApp(): ModuleType { res.json(response) const saveableQuestions = response.reduce((acc, res) => { - // TODO: only save if there isnt an answer for it - // if (res.answers.length === 0) { - // acc.push(res.question) - // } - acc.push(res.question) + if (res.answers.length === 0) { + acc.push(res.question) + } return acc }, []) @@ -1298,6 +1296,7 @@ function GetApp(): ModuleType { app.get('/infos', function(req: Request, res) { const user: User = req.session.user + const cid: any = req.query.cid const result: any = { result: 'success', @@ -1312,9 +1311,11 @@ function GetApp(): ModuleType { } if (req.query.motd) { result.motd = motd - if (userSpecificMotd[user.id] && userShouldGetUserSpecificMOTD(user.id)) { - result.userSpecificMotd = userSpecificMotd[user.id].msg - } + result.userSpecificMotd = userSpecificMotd[user.id].msg + result.userShouldGetUserSpecificMOTD = userShouldGetUserSpecificMOTD( + user.id, + cid + ) } res.json(result) }) @@ -1330,7 +1331,7 @@ function GetApp(): ModuleType { req.headers['cf-connecting-ip'] || req.connection.remoteAddress const ua: any = req.headers['user-agent'] const registeredScripts = utils.ReadJSON(registeredScriptsFile) - const { cid, uid, version, date } = req.body + const { cid, uid, version, installSource, date } = req.body const index = registeredScripts.findIndex((registration) => { return registration.cid === cid @@ -1340,6 +1341,7 @@ function GetApp(): ModuleType { const x: any = { cid: cid, version: version, + installSource: installSource, date: date, ip: ip, userAgent: ua, diff --git a/src/utils/classes.ts b/src/utils/classes.ts index ca0af48..214dec6 100755 --- a/src/utils/classes.ts +++ b/src/utils/classes.ts @@ -569,7 +569,18 @@ if (!isMainThread) { searchTillMatchPercent, searchInAllIfNoResult ) - searchResult = [...searchResult, ...res] + searchResult = [ + ...searchResult, + ...res.map((x) => { + return { + ...x, + detailedMatch: { + ...x.detailedMatch, + qdb: qdb.name, + }, + } + }), + ] } }) } catch (err) {