Commit 1ab512d5 by 李福中

Merge branch 'master' into release

parents 456db818 953eb382
......@@ -6,6 +6,7 @@
/pkg/
/spec/reports/
/tmp/
.idea
# Ignore bundler config.
/.bundle
......
......@@ -25,13 +25,25 @@ class PushsController < ApplicationController
param! :message, String, required: true
param! :igetui_opts, String
param! :app_type, String
param! :sync_push, String
igetui_opts = JSON.parse(params[:igetui_opts]) rescue {}
message = JSON.parse(params[:message]) rescue {}
device_ids_opts = JSON.parse(params[:device_ids_opts]) rescue {}
token = token_and_options(request).first
if token == Token.token(params[:app_name])
if params.has_key?(:sync_push)
timeout_seconds = $redis.get('push_timeout').to_i
if timeout_seconds > 0
Timeout.timeout(timeout_seconds) {
::PushWorker.new.perform(device_ids_opts, message, igetui_opts, params[:app_type])
}
else
::PushWorker.new.perform(device_ids_opts, message, igetui_opts, params[:app_type])
end
else
::PushWorker.perform_async(device_ids_opts, message, igetui_opts, params[:app_type])
end
render json: { code: 0, message: 'success', describe: '异步任务正在处理'}
else
render json: { code: -1, message: 'token 错误/过期'}
......
......@@ -86,7 +86,7 @@ module Push
headers = { 'Content-Type' => 'application/x-www-form-urlencoded' }
response = HTTParty.post(url, body: body, headers: headers, timeout: 5)
Push::Log.info("huawei_push: \n access_token: #{access_token} expire_time: #{$redis.ttl(Push::Huawei::ACCESS_TOKEN_KEY)}\n url: #{url}\n body: #{body}\n response: #{response}")
JSON.parse(response)
JSON.parse(response.body)
end
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment