mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Merge branch 'master' of gitlab.com:MrFry/mrfrys-node-server
This commit is contained in:
commit
fe8503a43e
4 changed files with 26 additions and 4 deletions
|
@ -41,6 +41,7 @@ const dailyDataCountFile = 'stats/dailyDataCount'
|
|||
const usersDbBackupPath = 'data/dbs/backup'
|
||||
const quickVoteResultsDir = 'stats/qvote'
|
||||
const quickVotes = 'stats/qvote/votes.json'
|
||||
const testUsersFile = 'data/testUsers.json'
|
||||
|
||||
// other constants
|
||||
const maxVeteranPwGetCount = 10
|
||||
|
@ -104,6 +105,7 @@ function GetApp () {
|
|||
var data = actions.LoadJSON(dataFile)
|
||||
var version = ''
|
||||
var motd = ''
|
||||
var testUsers = []
|
||||
|
||||
function LoadVersion () {
|
||||
version = utils.ReadFile(versionFile)
|
||||
|
@ -113,6 +115,13 @@ function GetApp () {
|
|||
motd = utils.ReadFile(motdFile)
|
||||
}
|
||||
|
||||
function LoadTestUsers () {
|
||||
testUsers = utils.ReadJSON(testUsersFile)
|
||||
if (testUsers) {
|
||||
testUsers = testUsers.userIds
|
||||
}
|
||||
}
|
||||
|
||||
function Load () {
|
||||
utils.WatchFile(motdFile, (newData) => {
|
||||
logger.Log(`Motd changed: ${newData.replace(/\/n/g, '')}`)
|
||||
|
@ -122,7 +131,12 @@ function GetApp () {
|
|||
logger.Log(`Version changed: ${newData.replace(/\/n/g, '')}`)
|
||||
LoadVersion()
|
||||
})
|
||||
utils.WatchFile(testUsersFile, (newData) => {
|
||||
logger.Log(`Test Users file changed: ${newData.replace(/\/n/g, '')}`)
|
||||
LoadTestUsers()
|
||||
})
|
||||
|
||||
LoadTestUsers()
|
||||
LoadVersion()
|
||||
LoadMOTD()
|
||||
}
|
||||
|
@ -566,12 +580,17 @@ function GetApp () {
|
|||
app.post('/isAdding', function (req, res) {
|
||||
logger.LogReq(req)
|
||||
|
||||
const user = req.session.user
|
||||
|
||||
const dryRun = testUsers.includes(user.id)
|
||||
|
||||
// automatically saves to dataFile every n write
|
||||
// FIXME: req.body.datatoadd is for backwards compatibility, remove this sometime in the future
|
||||
let result = actions.ProcessIncomingRequest(
|
||||
req.body.datatoadd || req.body,
|
||||
data,
|
||||
{ motd, version }
|
||||
{ motd, version },
|
||||
dryRun
|
||||
)
|
||||
|
||||
res.json({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue