Module: Wechat::Responder

Extended by:
ActiveSupport::Concern
Includes:
Cipher, ControllerApi
Defined in:
lib/wechat/responder.rb

Defined Under Namespace

Modules: ClassMethods

Constant Summary

Constants included from Cipher

Cipher::BLOCK_SIZE, Cipher::CIPHER

Instance Method Summary collapse

Methods included from Cipher

#decrypt, #encrypt, #pack, #unpack

Methods included from ControllerApi

#wechat, #wechat_oauth2

Instance Method Details

#createObject



189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/wechat/responder.rb', line 189

def create
  request_msg = Wechat::Message.from_hash(post_body)
  response_msg = run_responder(request_msg)

  if response_msg.respond_to? :to_xml
    render plain: process_response(response_msg)
  else
    head :ok, content_type: 'text/html'
  end

  response_msg.save_session if response_msg.is_a?(Wechat::Message) && Wechat.config.have_session_class

  ActiveSupport::Notifications.instrument 'wechat.responder.after_create', request: request_msg, response: response_msg
end

#showObject



180
181
182
183
184
185
186
187
# File 'lib/wechat/responder.rb', line 180

def show
  if @we_corpid.present?
    echostr, _corp_id = unpack(decrypt(Base64.decode64(params[:echostr]), @we_encoding_aes_key))
    render plain: echostr
  else
    render plain: params[:echostr]
  end
end