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/vstats
|
||||||
echo '{}' >stats/idstats
|
echo '{}' >stats/idstats
|
||||||
echo '{}' >stats/idvstats
|
echo '{}' >stats/idvstats
|
||||||
|
echo '{}' >qminingPublic/userSpecificMotd.json
|
||||||
|
echo '{}' >qminingPublic/news.json
|
||||||
|
|
||||||
touch qminingPublic/version
|
touch qminingPublic/version
|
||||||
touch qminingPublic/motd
|
touch qminingPublic/motd
|
||||||
|
|
|
@ -66,6 +66,7 @@ function GetApp() {
|
||||||
const uloadFiles = publicDir + 'f'
|
const uloadFiles = publicDir + 'f'
|
||||||
const dataFile = publicDir + 'data.json'
|
const dataFile = publicDir + 'data.json'
|
||||||
const motdFile = publicDir + 'motd'
|
const motdFile = publicDir + 'motd'
|
||||||
|
const userSpecificMotdFile = publicDir + 'userSpecificMotd.json'
|
||||||
const versionFile = publicDir + 'version'
|
const versionFile = publicDir + 'version'
|
||||||
|
|
||||||
app.use(
|
app.use(
|
||||||
|
@ -111,6 +112,7 @@ function GetApp() {
|
||||||
var data = actions.LoadJSON(dataFile)
|
var data = actions.LoadJSON(dataFile)
|
||||||
var version = ''
|
var version = ''
|
||||||
var motd = ''
|
var motd = ''
|
||||||
|
var userSpecificMotd = {}
|
||||||
var testUsers = []
|
var testUsers = []
|
||||||
|
|
||||||
function LoadVersion() {
|
function LoadVersion() {
|
||||||
|
@ -121,6 +123,10 @@ function GetApp() {
|
||||||
motd = utils.ReadFile(motdFile)
|
motd = utils.ReadFile(motdFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function LoadUserSpecificMOTD() {
|
||||||
|
userSpecificMotd = utils.ReadJSON(userSpecificMotdFile)
|
||||||
|
}
|
||||||
|
|
||||||
function LoadTestUsers() {
|
function LoadTestUsers() {
|
||||||
testUsers = utils.ReadJSON(testUsersFile)
|
testUsers = utils.ReadJSON(testUsersFile)
|
||||||
if (testUsers) {
|
if (testUsers) {
|
||||||
|
@ -129,6 +135,10 @@ function GetApp() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function Load() {
|
function Load() {
|
||||||
|
utils.WatchFile(userSpecificMotdFile, (newData) => {
|
||||||
|
logger.Log(`User Specific Motd changed: ${newData.replace(/\/n/g, '')}`)
|
||||||
|
LoadUserSpecificMOTD()
|
||||||
|
})
|
||||||
utils.WatchFile(motdFile, (newData) => {
|
utils.WatchFile(motdFile, (newData) => {
|
||||||
logger.Log(`Motd changed: ${newData.replace(/\/n/g, '')}`)
|
logger.Log(`Motd changed: ${newData.replace(/\/n/g, '')}`)
|
||||||
LoadMOTD()
|
LoadMOTD()
|
||||||
|
@ -688,7 +698,7 @@ function GetApp() {
|
||||||
// making backup
|
// making backup
|
||||||
utils.CopyFile(
|
utils.CopyFile(
|
||||||
'./' + dataFile,
|
'./' + dataFile,
|
||||||
`./qminingPublic/backs/data_before_${
|
`./publicDirs/qminingPublic/backs/data_before_${
|
||||||
user.name
|
user.name
|
||||||
}_${utils.GetDateString().replace(/ /g, '_')}`
|
}_${utils.GetDateString().replace(/ /g, '_')}`
|
||||||
) // TODO: rewrite to dinamyc public!!!
|
) // TODO: rewrite to dinamyc public!!!
|
||||||
|
@ -843,6 +853,7 @@ function GetApp() {
|
||||||
}
|
}
|
||||||
if (req.query.motd) {
|
if (req.query.motd) {
|
||||||
result.motd = motd
|
result.motd = motd
|
||||||
|
result.userSpecificMotd = userSpecificMotd[user.id]
|
||||||
}
|
}
|
||||||
res.json(result)
|
res.json(result)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue