Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
server.post('/api/messages', (req, res, next) => {
console.log('processReq:', req.body);
let activity = req.body;
// authenticate request
JwtTokenValidation.assertValidActivity(activity, req.headers.authorization, authenticator).then(() => {
// On message activity, reply with the same text
if (activity.type === ActivityTypes.Message) {
var reply = createReply(activity, `You said: ${activity.text}`);
const client = new ConnectorClient(credentials, activity.serviceUrl);
client.conversations.replyToActivity(activity.conversation.id, activity.id, reply)
.then((reply) => {
console.log('reply send with id: ' + reply.id);
});
}
res.send(202);
}).catch(err => {
console.log('Could not authenticate request:', err);
res.send(401);
});
server.post('/api/messages', (req, res) => {
console.log('processReq:', req.body);
let activity = req.body;
// authenticate request
JwtTokenValidation.assertValidActivity(activity, req.headers.authorization, authenticator).then(() => {
// dispatch the inbound activity to redux
store.dispatch({ type: activity.type, activity: activity });
res.send(202);
}).catch(err => {
console.log('Could not authenticate request:', err);
res.send(401);
});
});