Slack plugin fails to send notifications for posts containing links

Using the most recent version of the Slack plugin, a post I created recently never got posted to Slack.

In there error logs, I see this message and backtrace:

Job exception: undefined method `absolute' for DiscourseSlack::Slack:Class
...
/var/www/discourse/plugins/discourse-slack-official/slack_parser.rb:54:in `start_element'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/nokogiri-1.6.8.1/lib/nokogiri/html/sax/parser.rb:36:in `parse_with'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/nokogiri-1.6.8.1/lib/nokogiri/html/sax/parser.rb:36:in `parse_memory'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/nokogiri-1.6.8.1/lib/nokogiri/xml/sax/parser.rb:84:in `parse'
/var/www/discourse/plugins/discourse-slack-official/slack_parser.rb:20:in `block in get_excerpt'
/var/www/discourse/plugins/discourse-slack-official/slack_parser.rb:19:in `catch'
/var/www/discourse/plugins/discourse-slack-official/slack_parser.rb:19:in `get_excerpt'
/var/www/discourse/plugins/discourse-slack-official/lib/discourse_slack/slack.rb:18:in `excerpt'
/var/www/discourse/plugins/discourse-slack-official/lib/discourse_slack/slack.rb:93:in `slack_message'
/var/www/discourse/plugins/discourse-slack-official/lib/discourse_slack/slack.rb:176:in `block in notify'
/var/www/discourse/plugins/discourse-slack-official/lib/discourse_slack/slack.rb:170:in `each'
/var/www/discourse/plugins/discourse-slack-official/lib/discourse_slack/slack.rb:170:in `notify'
/var/www/discourse/plugins/discourse-slack-official/app/jobs/regular/notify_slack.rb:4:in `execute'
/var/www/discourse/app/jobs/base.rb:154:in `block (2 levels) in perform'

That method is trying to be called here:

https://github.com/discourse/discourse-slack-official/blob/7e1432d99a673e28bfb10cc5abf186dfba1f02e8/slack_parser.rb#L54

2 Likes

thank you @mcwumbly. Yes absolute method missing in latest commit. I think it was removed mistakenly. If yes then @tgxworld merge my PR below.

https://github.com/discourse/discourse-slack-official/pull/33

6 Likes

Fixed in

https://github.com/discourse/discourse-slack-official/commit/6eaf264df706d98cd7732880c28b233e6c047d36

with test cases added.

@vinothkannans Thanks for looking into this as well. I made some changes to the existing method instead of reusing the previous one. Thank you for your PR!

6 Likes