docbrown/app/observers/application_observer.rb
Andy Zhao 5754b4a169 Add comment markdown to warned_user_ping (#3750)
* Add comment markdown to warned_user_ping

* Add missing argument
2019-08-22 22:04:45 -04:00

19 lines
710 B
Ruby

class ApplicationObserver < ActiveRecord::Observer
def warned_user_ping(activity)
return unless activity.user.warned == true
SlackBotPingJob.perform_later message: message(activity),
channel: "warned-user-comments",
username: "sloan_watch_bot",
icon_emoji: ":sloan:"
end
def message(activity)
<<~HEREDOC
Activity: https://dev.to#{activity.path}
#{'Comment text: ' + activity.body_markdown.truncate(300) if activity.class.name == 'Comment'}
---
Manage commenter - @#{activity.user.username}: https://dev.to/internal/users/#{activity.user.id},
HEREDOC
end
end