Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle block_actions FIXES #1595 #1596

Merged
merged 2 commits into from
Feb 25, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion lib/SlackBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,22 @@ function Slackbot(configuration) {
next();
});

slack_botkit.middleware.normalize.use(function handleBlockActions(bot, message, next) {

if (message.trigger_id) {

message.user = message.user.id;
message.channel = message.channel.id;

if (message.type == 'block_actions') {
message.text = message.actions[0].value;
message.type = 'block_actions_callback';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should just leave the type as is -- less to understand!

}
}

next();

});

slack_botkit.middleware.format.use(function formatForSlack(bot, message, platform_message, next) {

Expand All @@ -576,7 +591,7 @@ function Slackbot(configuration) {
if(message.blocks){
platform_message.blocks = JSON.stringify(message.blocks);
}

platform_message.unfurl_links = typeof message.unfurl_links !== 'undefined' ? message.unfurl_links : null;
platform_message.unfurl_media = typeof message.unfurl_media !== 'undefined' ? message.unfurl_media : null;
platform_message.icon_url = message.icon_url || null;
Expand Down