app.post("/K7ChatAdvDev/webchatapi/webhook",(req, res) => {
console.log("웹훅 실행!!");
console.log("req 내용!!");
console.log(req);
console.log("req body 내용!!");
console.log(req.body);
const body = JSON.stringify(req.body);
console.log("1");
const signature = req.get("x-sendbird-signature");
console.log("2");
const hash = crypto.createHmac('sha256', API_TOKEN).update(body).digest('hex');
console.log("3");
console.log(hash);
console.log(signature);
//body = JSON.parse(req.body); // Convert the body to JSON after creating the hash.
console.log("4");
console.log(body);
console.log(hash);
console.log(signature);
if(signature == hash) {
res.send(200);
body = JSON.parse(req.body); // Convert the body to JSON after creating the hash.
req.body.members[0].forEach(member => {
console.log(member.is_online);
if(!member.is_online) {
sendPush(req.body);
}
});
} else {
res.send(401);
}
});
x-sendbird-signature hash Inconsistency
x-sendbird-signature != hash ----> WHY???