const oppsid = this.getOppsid(c);
if (oppsid)
this.send("refusechallenge", { data: c.id, target: oppsid });
+ if (c.type == "corr")
+ ajax("/challenges", "DELETE", { id: c.id });
}
this.send("deletechallenge", { data: c.id });
},
}
else {
// My challenge
- if (c.type == "corr") {
+ if (c.type == "corr")
ajax("/challenges", "DELETE", { id: c.id });
- }
this.send("deletechallenge", { data: c.id });
}
// In all cases, the challenge is consumed:
const query =
"SELECT 1 " +
"FROM Challenges " +
- "WHERE id = " + id + " AND uid = " + uid;
+ "WHERE id = " + id + " " +
+ // Condition: I'm the sender or the target
+ "AND (uid = " + uid + " OR to = " + uid + ")";
db.get(query, (err,chall) => {
if (!err && chall)
ChallengeModel.remove(id);