diff --git a/scripts/make.sh b/scripts/make.sh index cefcee3..339ac16 100755 --- a/scripts/make.sh +++ b/scripts/make.sh @@ -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 diff --git a/src/modules/api/api.js b/src/modules/api/api.js index 2225aa8..0c7f269 100644 --- a/src/modules/api/api.js +++ b/src/modules/api/api.js @@ -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) })