Improve code design
This commit is contained in:
parent
f5ff372140
commit
e6842ff564
2 changed files with 8 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue