Slack plugin fails to send notifications for posts containing links


(Dave McClure) #1

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:


(Vinoth Kannan) #2

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


(Alan Tan) #3

Fixed in

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!


(Alan Tan) #4