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:
parent
57d8f642a0
commit
175f0235d0
3 changed files with 25 additions and 42 deletions
|
@ -130,7 +130,6 @@ function GetApp(): ModuleType {
|
|||
'/register',
|
||||
'/favicon.ico',
|
||||
'/login',
|
||||
'/postfeedbackfile',
|
||||
'/postfeedback',
|
||||
'/fosuploader',
|
||||
'/badtestsender',
|
||||
|
@ -208,39 +207,6 @@ function GetApp(): ModuleType {
|
|||
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 = [
|
||||
{
|
||||
fname: userSpecificMotdFile,
|
||||
|
@ -1296,7 +1262,6 @@ 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',
|
||||
|
@ -1311,15 +1276,33 @@ function GetApp(): ModuleType {
|
|||
}
|
||||
if (req.query.motd) {
|
||||
result.motd = motd
|
||||
result.userSpecificMotd = userSpecificMotd[user.id].msg
|
||||
result.userShouldGetUserSpecificMOTD = userShouldGetUserSpecificMOTD(
|
||||
user.id,
|
||||
cid
|
||||
)
|
||||
result.userSpecificMotd = {
|
||||
msg: userSpecificMotd[user.id].msg,
|
||||
seen: userSpecificMotd[user.id].seen,
|
||||
}
|
||||
}
|
||||
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) {
|
||||
logger.LogReq(req)
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 07b34762c3265abde099297f1794349022f2e12d
|
||||
Subproject commit 2d6211a80af3ccd6fe78d6e30c98f340f0579ac8
|
|
@ -1 +1 @@
|
|||
Subproject commit 21bd0c01771cce8f693a32a0ae5d2f5fda4d55fb
|
||||
Subproject commit 23dc6197ad6913cf3e3f0a950fabf05c943cfffa
|
Loading…
Add table
Add a link
Reference in a new issue