mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Added user specific motd, and updated make script
This commit is contained in:
parent
45962874fd
commit
c7f3b405e9
2 changed files with 14 additions and 1 deletions
|
@ -54,6 +54,8 @@ echo '{}' >stats/stats
|
|||
echo '{}' >stats/vstats
|
||||
echo '{}' >stats/idstats
|
||||
echo '{}' >stats/idvstats
|
||||
echo '{}' >qminingPublic/userSpecificMotd.json
|
||||
echo '{}' >qminingPublic/news.json
|
||||
|
||||
touch qminingPublic/version
|
||||
touch qminingPublic/motd
|
||||
|
|
|
@ -66,6 +66,7 @@ function GetApp() {
|
|||
const uloadFiles = publicDir + 'f'
|
||||
const dataFile = publicDir + 'data.json'
|
||||
const motdFile = publicDir + 'motd'
|
||||
const userSpecificMotdFile = publicDir + 'userSpecificMotd.json'
|
||||
const versionFile = publicDir + 'version'
|
||||
|
||||
app.use(
|
||||
|
@ -111,6 +112,7 @@ function GetApp() {
|
|||
var data = actions.LoadJSON(dataFile)
|
||||
var version = ''
|
||||
var motd = ''
|
||||
var userSpecificMotd = {}
|
||||
var testUsers = []
|
||||
|
||||
function LoadVersion() {
|
||||
|
@ -121,6 +123,10 @@ function GetApp() {
|
|||
motd = utils.ReadFile(motdFile)
|
||||
}
|
||||
|
||||
function LoadUserSpecificMOTD() {
|
||||
userSpecificMotd = utils.ReadJSON(userSpecificMotdFile)
|
||||
}
|
||||
|
||||
function LoadTestUsers() {
|
||||
testUsers = utils.ReadJSON(testUsersFile)
|
||||
if (testUsers) {
|
||||
|
@ -129,6 +135,10 @@ function GetApp() {
|
|||
}
|
||||
|
||||
function Load() {
|
||||
utils.WatchFile(userSpecificMotdFile, (newData) => {
|
||||
logger.Log(`User Specific Motd changed: ${newData.replace(/\/n/g, '')}`)
|
||||
LoadUserSpecificMOTD()
|
||||
})
|
||||
utils.WatchFile(motdFile, (newData) => {
|
||||
logger.Log(`Motd changed: ${newData.replace(/\/n/g, '')}`)
|
||||
LoadMOTD()
|
||||
|
@ -688,7 +698,7 @@ function GetApp() {
|
|||
// making backup
|
||||
utils.CopyFile(
|
||||
'./' + dataFile,
|
||||
`./qminingPublic/backs/data_before_${
|
||||
`./publicDirs/qminingPublic/backs/data_before_${
|
||||
user.name
|
||||
}_${utils.GetDateString().replace(/ /g, '_')}`
|
||||
) // TODO: rewrite to dinamyc public!!!
|
||||
|
@ -843,6 +853,7 @@ function GetApp() {
|
|||
}
|
||||
if (req.query.motd) {
|
||||
result.motd = motd
|
||||
result.userSpecificMotd = userSpecificMotd[user.id]
|
||||
}
|
||||
res.json(result)
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue