move PersonalMessages to its own file
This commit is contained in:
parent
d1a7228694
commit
a4b6d24651
24
routes/api/dms/PersonalMessages.js
Normal file
24
routes/api/dms/PersonalMessages.js
Normal file
@ -0,0 +1,24 @@
|
||||
module.exports = {
|
||||
"setup": function(router,con,server) {
|
||||
router.get("/api/getPersonalPosts", async function(req,res) {
|
||||
res.set("Access-Control-Allow-Origin","")
|
||||
|
||||
let otherperson = req.query.otherperson
|
||||
|
||||
if(typeof otherperson != "string" || otherperson.length > 100) {
|
||||
res.status(400).json({"error": "invalid otherperson given"})
|
||||
return
|
||||
}
|
||||
|
||||
const columns = [
|
||||
"dms_user_name","dms_text","dms_time","dms_special_text","dms_id","dms_from_bot","dms_reply_id"
|
||||
]
|
||||
|
||||
let sql = `select ${columns.join(",")} from ipost.dms where (dms_channel = ?) order by dms_id desc;`
|
||||
con.query(sql, [xor(encodeURIComponent(res.locals.username),otherperson)], function (err, result) {
|
||||
if (err) throw err;
|
||||
res.json(result)
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
18
server.js
18
server.js
@ -423,7 +423,8 @@ const toLoad = [
|
||||
"api/options.js",
|
||||
"api/all.js",
|
||||
"api/settingshandler.js",
|
||||
"api/post.js"
|
||||
"api/post.js",
|
||||
"api/dms/PersonalMessages.js"
|
||||
]
|
||||
|
||||
for (let i = 0; i < toLoad.length; i++) {
|
||||
@ -612,22 +613,7 @@ router.get("/api/getPost", async function(req,res) {
|
||||
});
|
||||
})
|
||||
|
||||
router.get("/api/getPersonalPosts", async function(req,res) {
|
||||
res.set("Access-Control-Allow-Origin","")
|
||||
|
||||
let otherperson = req.query.otherperson
|
||||
|
||||
if(typeof otherperson != "string" || otherperson.length > 100) {
|
||||
res.status(400).json({"error": "invalid otherperson given"})
|
||||
return
|
||||
}
|
||||
|
||||
let sql = `select dms_user_name,dms_text,dms_time,dms_special_text,dms_id,dms_from_bot,dms_reply_id from ipost.dms where (dms_channel = ?) order by dms_id desc;`
|
||||
con.query(sql, [xor(encodeURIComponent(res.locals.username),otherperson)], function (err, result) {
|
||||
if (err) throw err;
|
||||
res.json(result)
|
||||
});
|
||||
})
|
||||
|
||||
router.get("/api/getChannels", async function(req,res) {
|
||||
res.set("Access-Control-Allow-Origin","*")
|
||||
|
Loading…
x
Reference in New Issue
Block a user