conversations now returns all conversations
doesn't just check if you had a conversation with a certain person
This commit is contained in:
parent
2c871e3053
commit
ecacb7568d
@ -28,19 +28,12 @@ module.exports = {
|
||||
router.get("/api/dms/conversations", async function(req,res) {
|
||||
res.set("Access-Control-Allow-Origin","*")
|
||||
|
||||
let otherperson = encodeURIComponent(req.query.otherperson||"")
|
||||
|
||||
if(typeof otherperson != "string" || otherperson.length > 100 || otherperson=="") {
|
||||
res.status(400).json({"error": "invalid otherperson given"})
|
||||
return
|
||||
}
|
||||
|
||||
const columns = [
|
||||
"dms_user_name","dms_receiver"
|
||||
]
|
||||
|
||||
let sql = `select ${columns.join(",")} from ipost.dms where ((dms_receiver = ? and dms_user_name = ?) or (dms_receiver = ? and dms_user_name = ?)) group by dms_receiver,dms_user_name;`
|
||||
con.query(sql, [otherperson,encodeURIComponent(res.locals.username),encodeURIComponent(res.locals.username),otherperson], function (err, result) {
|
||||
let sql = `select ${columns.join(",")} from ipost.dms where ((dms_receiver = ?) or (dms_user_name = ?)) group by dms_receiver,dms_user_name;`
|
||||
con.query(sql, [encodeURIComponent(res.locals.username),encodeURIComponent(res.locals.username)], function (err, result) {
|
||||
if (err) throw err;
|
||||
res.json(result)
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user