Class: Stealth::Server

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/stealth-webhook/overriding/server.rb

Instance Method Summary collapse

Instance Method Details

#send_message(params, auth_token = nil) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/stealth-webhook/overriding/server.rb', line 18

def send_message(params, auth_token = nil)
  return [401, 'Unauthorized: Invalid Token'] if ENV['WEHBOOK_AUTH_TOKEN'] && auth_token != "Token #{ENV['WEHBOOK_AUTH_TOKEN']}"

  begin
    webhook = StealthWebhook::Webhook.new
    webhook.send_message(params)
  rescue => e
    [503, "Service Unavailable: #{e.message}"]
  end
end