mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Added images to forum, saving recieved data on isAdding
This commit is contained in:
parent
ea459d05e4
commit
25aa6f3187
2 changed files with 87 additions and 3 deletions
|
@ -47,6 +47,7 @@ import {
|
|||
loadJSON,
|
||||
writeData,
|
||||
editDb,
|
||||
RecievedData,
|
||||
} from '../../../utils/actions'
|
||||
import {
|
||||
dataToString,
|
||||
|
@ -81,6 +82,7 @@ const line = '====================================================' // lol
|
|||
const registeredScriptsFile = 'stats/registeredScripts.json'
|
||||
const testUsersFile = 'data/testUsers.json'
|
||||
const userScriptFile = 'submodules/moodle-test-userscript/stable.user.js'
|
||||
const askedQuestionFile = 'stats/recievedQuestions'
|
||||
const recievedQuestionFile = 'stats/recievedQuestions'
|
||||
const savedQuestionsFileName = 'savedQuestions.json'
|
||||
const oldMotdFile = 'publicDirs/qminingPublic/oldMotd'
|
||||
|
@ -259,6 +261,21 @@ function dbExists(location: string, qdbs: Array<QuestionDb>) {
|
|||
}
|
||||
|
||||
function writeAskData(body: QuestionFromScript) {
|
||||
try {
|
||||
let towrite = utils.GetDateString() + '\n'
|
||||
towrite +=
|
||||
'------------------------------------------------------------------------------\n'
|
||||
towrite += JSON.stringify(body)
|
||||
towrite +=
|
||||
'\n------------------------------------------------------------------------------\n'
|
||||
utils.AppendToFile(towrite, askedQuestionFile)
|
||||
} catch (err) {
|
||||
logger.Log('Error writing revieved /ask POST data')
|
||||
console.error(err)
|
||||
}
|
||||
}
|
||||
|
||||
function writeIsAddingData(body: RecievedData) {
|
||||
try {
|
||||
let towrite = utils.GetDateString() + '\n'
|
||||
towrite +=
|
||||
|
@ -541,7 +558,7 @@ function setup(data: SubmoduleData): Submodule {
|
|||
res.end(stringifiedData)
|
||||
})
|
||||
|
||||
app.post('/isAdding', function (req: Request, res: Response) {
|
||||
app.post('/isAdding', function (req: Request<RecievedData>, res: Response) {
|
||||
logger.LogReq(req)
|
||||
const user: User = req.session.user
|
||||
const dryRun = testUsers.includes(user.id)
|
||||
|
@ -553,6 +570,8 @@ function setup(data: SubmoduleData): Submodule {
|
|||
return
|
||||
}
|
||||
|
||||
writeIsAddingData(req.body)
|
||||
|
||||
const location = req.body.location.split('/')[2]
|
||||
|
||||
try {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue