mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Merge
This commit is contained in:
commit
0a40e1024b
9 changed files with 230 additions and 9 deletions
|
@ -131,7 +131,7 @@ function setup(data: SubmoduleData): void {
|
|||
const msgObj = {
|
||||
sender: userid,
|
||||
reciever: parseInt(reciever),
|
||||
msg: msg.replace(/'/g, '').replace(/;/g, ''),
|
||||
msg: dbtools.sanitizeQuery(msg),
|
||||
type: type || 'text',
|
||||
date: new Date().getTime(),
|
||||
unread: 1,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import fs from 'fs'
|
||||
import { fork } from 'child_process'
|
||||
|
||||
import logger from '../../../utils/logger'
|
||||
import utils from '../../../utils/utils'
|
||||
|
@ -600,7 +601,7 @@ function setup(data: SubmoduleData): any {
|
|||
|
||||
if (!req.body.questions) {
|
||||
res.json({
|
||||
message: `ask something! { question:'' ,subject:'', location:'' }`,
|
||||
message: `ask something! { questions:'' ,subject:'', location:'' }`,
|
||||
result: [],
|
||||
recievedData: JSON.stringify(req.body),
|
||||
success: false,
|
||||
|
@ -1006,6 +1007,57 @@ function setup(data: SubmoduleData): any {
|
|||
})
|
||||
})
|
||||
|
||||
let questionCleaner = null
|
||||
app.get('/clearQuestions', (req: Request, res) => {
|
||||
// TODO: dont allow multiple instances
|
||||
// TODO: get status of it cleaning
|
||||
logger.LogReq(req)
|
||||
const user: User = req.session.user
|
||||
const status: any = req.query.status
|
||||
|
||||
if (status) {
|
||||
if (!questionCleaner) {
|
||||
res.json({
|
||||
msg: 'question cleaner not running',
|
||||
success: false,
|
||||
})
|
||||
return
|
||||
}
|
||||
questionCleaner.once('message', function (response) {
|
||||
res.json({
|
||||
msg: response,
|
||||
success: true,
|
||||
})
|
||||
})
|
||||
|
||||
questionCleaner.send({ data: 'asd' })
|
||||
return
|
||||
}
|
||||
|
||||
if (questionCleaner) {
|
||||
res.json({
|
||||
msg: 'question cleaner already running',
|
||||
success: false,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
questionCleaner = fork(
|
||||
`${process.cwd()}/src/standaloneUtils/rmDuplicates.js`,
|
||||
['-s', `${process.cwd()}/${questionDbs[0].path}`]
|
||||
)
|
||||
questionCleaner.on('exit', function (code) {
|
||||
console.log('EXIT', code)
|
||||
questionCleaner = null
|
||||
})
|
||||
|
||||
res.json({
|
||||
user: user,
|
||||
success: true,
|
||||
msg: 'OK',
|
||||
})
|
||||
})
|
||||
|
||||
return {
|
||||
dailyAction: () => {
|
||||
backupData(questionDbs)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue