Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
clear attachments if parsing fails on postMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
colestrode committed Jul 20, 2016
1 parent dc56ba6 commit 439a601
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/Slack_web_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,12 @@ module.exports = function(bot, config) {
// overwrite default behavior
slack_api.chat.postMessage = function(options, cb) {
if (options.attachments && typeof(options.attachments) != 'string') {
options.attachments = JSON.stringify(options.attachments);
try {
options.attachments = JSON.stringify(options.attachments);
} catch(err) {
delete options.attachments;
bot.log.error('Could not parse attachments', err);
}
}
slack_api.callAPI('chat.postMessage', options, cb);
};
Expand Down

0 comments on commit 439a601

Please sign in to comment.