Improve code design

This commit is contained in:
Kamil Trzcinski 2016-12-19 13:32:37 +01:00
parent f5ff372140
commit e6842ff564
No known key found for this signature in database
GPG key ID: 4505F5C7E12C6A5A
2 changed files with 8 additions and 6 deletions

View file

@ -28,7 +28,7 @@ class ChatSlashCommandsService < Service
end
def trigger(params)
return nil unless valid_token?(params[:token])
return unless valid_token?(params[:token])
user = find_chat_user(params)
unless user

View file

@ -14,13 +14,15 @@ class SlackSlashCommandsService < ChatSlashCommandsService
end
def trigger(params)
result = super
# Format messages to be Slack-compatible
if result && result[:text]
result[:text] = Slack::Notifier::LinkFormatter.format(result[:text])
super.tap do |result|
result[:text] = format(result[:text])
end
end
result
private
def format(text)
Slack::Notifier::LinkFormatter.format(text) if text
end
end