Skip to content

Commit

Permalink
Fix incorrect return when not able to post poll
Browse files Browse the repository at this point in the history
  • Loading branch information
polppol committed Nov 22, 2023
1 parent b3f87bc commit 6a90f63
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ const postChat = async (url,type,requestBody) => {
ret.message = "Unknown error";
}
ret.status = false;
return false;
return ret;
}
ret.status = true;
return ret;
Expand Down Expand Up @@ -3915,7 +3915,21 @@ app.view('modal_poll_submit', async ({ ack, body, view, context }) => {
blocks: blocks,
text: `Poll : ${question}`,
};
await postChat(response_url,'post',mRequestBody);
const postRes = await postChat(response_url,'post',mRequestBody);
//console.log(postRes);
if(postRes.status === false) {
try {
let mRequestBody = {
token: context.botToken,
channel: userId,
text: `Error while create poll: \`${cmd}\` \nERROR:${postRes.message}`
};
await postChat(response_url, 'post', mRequestBody);
} catch (e) {
//not able to dm user
console.log(e);
}
}
} else {
//schedule
//console.log(postDateTime);
Expand Down

0 comments on commit 6a90f63

Please sign in to comment.