Slack command integration broken in official discourse slack plugin

I just updated the slack plugin on our instance to the latest version (compare versions), and it appears the /discourse slack commands are now broken:

Here’s what I see in the logs on our instance:

Started POST "/slack/command" for 52.91.184.228 at 2017-04-08 15:07:59 +0000
Processing by DiscourseSlack::SlackController#command as HTML
  Parameters: {"token"=>"REDACTED", "team_id"=>"REDACTED", "team_domain"=>"mydomain", "channel_id"=>"REDACTED", "channel_name"=>"discourse-test", "user_id"=>"REDACTED", "user_name"=>"someuser", "command"=>"/discourse", "text"=>"help", "response_url"=>"https://hooks.slack.com/commands/FOO/BAR/bazbazbaz"}
Redirected to
Completed 500 Internal Server Error in 5ms (ActiveRecord: 0.0ms)
ActionController::UrlGenerationError (No route matches {:action=>"enter", :controller=>"static"})
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.7.1/lib/action_dispatch/journey/formatter.rb:46:in `generate'

/cc @vinothkannans @tgxworld

1 Like

Is your forum a private forum?

yes, it is a private forum

@tgxworld We should skip before_filter redirect_to_login_if_required here?

3 Likes

Yup I think I removed one of the monkey patches. For the /command path, we need to skip everything because the only authentication we need to do is to check if the Slack token is valid.

3 Likes

my understanding of @vinothkannans suggestion appears to work in a quick test. I’ll let you do what makes the most sense rather than PR it, though.

3 Likes

This is exactly what I’ve done in my Telegram plugin (which is very similar to slack in the way the webhooks work). If there’s a better solution I’d be interested to know!

2 Likes

Thanks for reporting @mcwumbly. I’ve fixed it in

https://github.com/discourse/discourse-slack-official/commit/c7ce5722f041253ef0a2ee98a74303ac99b4ae8b

and added a test case for it. I’ve been involved in refactoring of the plugin but without existing test cases, there is a higher chance of me breaking stuff without knowing. Feel free to report any more bugs that you come across and I’ll get them sorted.

5 Likes