Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return ({ dispatch }) => next => ({ cardAction, getSignInUrl }) => {
const { displayText, text, type, value } = cardAction;
switch (type) {
case 'imBack':
if (typeof value === 'string') {
// TODO: [P4] Instead of calling dispatch, we should move to dispatchers instead for completeness
dispatch(sendMessage(value, 'imBack'));
} else {
throw new Error('cannot send "imBack" with a non-string value');
}
break;
case 'messageBack':
dispatch(sendMessageBack(value, text, displayText));
break;
case 'postBack':
dispatch(sendPostBack(value));
break;