mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
User specific motd changes, adding question db name to found question
This commit is contained in:
parent
f19226a74e
commit
57d8f642a0
2 changed files with 25 additions and 12 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue