Class: KannelRails::SmsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/kannel_rails/sms_controller.rb

Instance Method Summary collapse

Instance Method Details

#receive_messageObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/kannel_rails/sms_controller.rb', line 4

def receive_message
  if KannelRails.config.api_secret and KannelRails.config.api_secret != params[:api_secret]
    render :status => :forbidden, :text => "Unauthorized Request"
  else
    reply = ""

    KannelRails::Handlers.each do |h|
      handler_class = h.is_a?(String) ? h.constantize : h
      handler = handler_class.new(params)

      if handler.handle?
        reply = handler.invoke
        break
      end
    end

    render :text => reply
  end
end