mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
User specific motd changes (again)
This commit is contained in:
@@ -130,7 +130,6 @@ function GetApp(): ModuleType {
|
|||||||
'/register',
|
'/register',
|
||||||
'/favicon.ico',
|
'/favicon.ico',
|
||||||
'/login',
|
'/login',
|
||||||
'/postfeedbackfile',
|
|
||||||
'/postfeedback',
|
'/postfeedback',
|
||||||
'/fosuploader',
|
'/fosuploader',
|
||||||
'/badtestsender',
|
'/badtestsender',
|
||||||
@@ -208,39 +207,6 @@ function GetApp(): ModuleType {
|
|||||||
rootRedirectURL = utils.ReadFile(rootRedirectToFile)
|
rootRedirectURL = utils.ReadFile(rootRedirectToFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
function userShouldGetUserSpecificMOTD(id, cid) {
|
|
||||||
let shouldSee = true
|
|
||||||
let write = false
|
|
||||||
|
|
||||||
if (!userSpecificMotd[id].seen) {
|
|
||||||
logger.Log(
|
|
||||||
`User #${id}'s user specific motd is now seen.`,
|
|
||||||
logger.GetColor('bluebg')
|
|
||||||
)
|
|
||||||
logger.Log(userSpecificMotd[id].msg)
|
|
||||||
|
|
||||||
userSpecificMotd[id].seen = true
|
|
||||||
write = true
|
|
||||||
}
|
|
||||||
|
|
||||||
if (userSpecificMotd[id].seeCounter) {
|
|
||||||
if (userSpecificMotd[id].seeCounter <= 1) {
|
|
||||||
shouldSee = false
|
|
||||||
} else if (cid) {
|
|
||||||
userSpecificMotd[id].seeCounter -= 1
|
|
||||||
write = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (write) {
|
|
||||||
utils.WriteFile(
|
|
||||||
JSON.stringify(userSpecificMotd, null, 2),
|
|
||||||
userSpecificMotdFile
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return shouldSee
|
|
||||||
}
|
|
||||||
|
|
||||||
const filesToWatch = [
|
const filesToWatch = [
|
||||||
{
|
{
|
||||||
fname: userSpecificMotdFile,
|
fname: userSpecificMotdFile,
|
||||||
@@ -1296,7 +1262,6 @@ function GetApp(): ModuleType {
|
|||||||
|
|
||||||
app.get('/infos', function(req: Request, res) {
|
app.get('/infos', function(req: Request, res) {
|
||||||
const user: User = req.session.user
|
const user: User = req.session.user
|
||||||
const cid: any = req.query.cid
|
|
||||||
|
|
||||||
const result: any = {
|
const result: any = {
|
||||||
result: 'success',
|
result: 'success',
|
||||||
@@ -1311,15 +1276,33 @@ function GetApp(): ModuleType {
|
|||||||
}
|
}
|
||||||
if (req.query.motd) {
|
if (req.query.motd) {
|
||||||
result.motd = motd
|
result.motd = motd
|
||||||
result.userSpecificMotd = userSpecificMotd[user.id].msg
|
result.userSpecificMotd = {
|
||||||
result.userShouldGetUserSpecificMOTD = userShouldGetUserSpecificMOTD(
|
msg: userSpecificMotd[user.id].msg,
|
||||||
user.id,
|
seen: userSpecificMotd[user.id].seen,
|
||||||
cid
|
}
|
||||||
)
|
|
||||||
}
|
}
|
||||||
res.json(result)
|
res.json(result)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
app.post('/infos', (req: Request, res) => {
|
||||||
|
const user: User = req.session.user
|
||||||
|
|
||||||
|
if (req.body.userSpecificMotdSeen) {
|
||||||
|
userSpecificMotd[user.id].seen = true
|
||||||
|
|
||||||
|
logger.Log(
|
||||||
|
`User #${user.id}'s user specific motd is now seen.`,
|
||||||
|
logger.GetColor('bluebg')
|
||||||
|
)
|
||||||
|
utils.WriteFile(
|
||||||
|
JSON.stringify(userSpecificMotd, null, 2),
|
||||||
|
userSpecificMotdFile
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
res.json({ msg: 'done' })
|
||||||
|
})
|
||||||
|
|
||||||
app.post('/registerscript', function(req: Request, res) {
|
app.post('/registerscript', function(req: Request, res) {
|
||||||
logger.LogReq(req)
|
logger.LogReq(req)
|
||||||
|
|
||||||
|
Submodule submodules/qmining-data-editor updated: 07b34762c3...2d6211a80a
Submodule submodules/qmining-page updated: 21bd0c0177...23dc6197ad
Reference in New Issue
Block a user