Commit b3d25f2a by liangyuzhe

add logger

parent d3f6c0cd
...@@ -29,14 +29,14 @@ class PushsController < ApplicationController ...@@ -29,14 +29,14 @@ class PushsController < ApplicationController
user_device_exist = UserDevice.where(user_id: params[:user_id]).exists? user_device_exist = UserDevice.where(user_id: params[:user_id]).exists?
unless user_device_exist unless user_device_exist
render json: { code: -1, message: 'user_device找不到,user_id错误'} return render json: { code: -1, message: 'user_device找不到,user_id错误'}
end end
token_array = token_and_options(request) token_array = token_and_options(request)
if token_array.blank? if token_array.blank?
render json: { code: -1, message: 'token错误'} return render json: { code: -1, message: 'token错误'}
end end
byebug
if validate_token(params[:app_name], token_array.first) if validate_token(params[:app_name], token_array.first)
push_sync(params[:sync_push], {user_ids: Array(params[:user_id]), message: message, app_type: params[:app_type], igetui_opts: igetui_opts.merge(pusher_type: 'push_message_to_single')}) push_sync(params[:sync_push], {user_ids: Array(params[:user_id]), message: message, app_type: params[:app_type], igetui_opts: igetui_opts.merge(pusher_type: 'push_message_to_single')})
...@@ -63,11 +63,15 @@ class PushsController < ApplicationController ...@@ -63,11 +63,15 @@ class PushsController < ApplicationController
user_devices_exists = UserDevice.where(user_id: user_ids).exists? user_devices_exists = UserDevice.where(user_id: user_ids).exists?
unless user_devices_exists unless user_devices_exists
render json: { code: -1, message: 'user_device找不到,user_ids错误'} return render json: { code: -1, message: 'user_device找不到,user_ids错误'}
end
token_array = token_and_options(request)
if token_array.blank?
return render json: { code: -1, message: 'token错误'}
end end
token = token_and_options(request).first if validate_token(params[:app_name], token_array.first)
if validate_token(params[:app_name], token)
push_sync(params[:sync_push], {user_ids: user_ids, message: message, app_type: params[:app_type], igetui_opts: igetui_opts.merge(pusher_type: 'push_message_to_list')}) push_sync(params[:sync_push], {user_ids: user_ids, message: message, app_type: params[:app_type], igetui_opts: igetui_opts.merge(pusher_type: 'push_message_to_list')})
render json: { code: 0, message: 'success', describe: '异步任务正在处理'} render json: { code: 0, message: 'success', describe: '异步任务正在处理'}
......
...@@ -42,8 +42,8 @@ module Igetui ...@@ -42,8 +42,8 @@ module Igetui
client_id_list.map do |client_id| client_id_list.map do |client_id|
client = IGeTui::Client.new(client_id) client = IGeTui::Client.new(client_id)
byebug res = pusher.push_message_to_single(message, client)
pusher.push_message_to_single(message, client) ::Log.info(" push_message_to_single client: #{client.to_json} and message is #{message.to_json} and res is #{res}")
end end
when 'push_message_to_list' when 'push_message_to_list'
message = IGeTui::ListMessage.new message = IGeTui::ListMessage.new
...@@ -52,14 +52,16 @@ module Igetui ...@@ -52,14 +52,16 @@ module Igetui
content_id = pusher.get_content_id(message) content_id = pusher.get_content_id(message)
clients = client_id_list.map { |client_id| IGeTui::Client.new(client_id) } clients = client_id_list.map { |client_id| IGeTui::Client.new(client_id) }
pusher.push_message_to_list(content_id, clients) res = pusher.push_message_to_list(content_id, clients)
::Log.info("push_message_to_list clients: #{clients.to_json} and message is #{message.to_json} and res is #{res}")
when 'push_message_to_app' when 'push_message_to_app'
message = IGeTui::AppMessage.new message = IGeTui::AppMessage.new
message.data = template message.data = template
message.app_id_list = client_id_list message.app_id_list = client_id_list
pusher.push_message_to_app(message) res = pusher.push_message_to_app(message)
::Log.info("push_message_to_app message is #{message.to_json} and res is #{res}")
end 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