Commit 8def2ba4 by 万从磊

Merge branch 'fix_push_v2' into 'master'

推送判断client_id

See merge request !10
parents d50f3f68 63880dad
...@@ -13,9 +13,9 @@ class PushsController < ApplicationController ...@@ -13,9 +13,9 @@ class PushsController < ApplicationController
render json: { code: -1, message: '应用不存在或者app_id/app_secret不匹配'} render json: { code: -1, message: '应用不存在或者app_id/app_secret不匹配'}
end end
end end
def push_v2 def push_v2
param! :app_name, String, required: true, in: %w(crm) param! :app_name, String, required: true, in: %w(crm)
# param! :device_ids_opts, String, required: true # param! :device_ids_opts, String, required: true
param! :message, String, required: true param! :message, String, required: true
# param! :igetui_opts, String # param! :igetui_opts, String
...@@ -27,8 +27,10 @@ class PushsController < ApplicationController ...@@ -27,8 +27,10 @@ class PushsController < ApplicationController
user_ids = params[:user_ids] rescue [] user_ids = params[:user_ids] rescue []
user_devices = UserDevice.where(user_id: user_ids)
user_device_exist = UserDevice.where(user_id: user_ids).exists? client_id = message.dig('transmission_content', 'extras', 'extra', 'client_id')
user_devices = user_devices.where.not(client_id: client_id) if client_id
user_device_exist = user_devices.exists?
unless user_device_exist unless user_device_exist
return render json: { code: -1, message: 'user_device找不到,user_ids错误'} return render json: { code: -1, message: 'user_device找不到,user_ids错误'}
...@@ -47,7 +49,7 @@ class PushsController < ApplicationController ...@@ -47,7 +49,7 @@ class PushsController < ApplicationController
# else # else
# render json: { code: 401, message: 'token 错误/过期'} # render json: { code: 401, message: 'token 错误/过期'}
# end # end
end end
def received def received
...@@ -81,7 +83,7 @@ class PushsController < ApplicationController ...@@ -81,7 +83,7 @@ class PushsController < ApplicationController
# if validate_token(params[:app_name], token_array.first) # if validate_token(params[:app_name], token_array.first)
params[:sync_push] ||= false params[:sync_push] ||= false
push_sync(params[:sync_push], {device_ids_opts: device_ids_opts, message: message, app_type: params[:app_type], igetui_opts: igetui_opts.merge(pusher_type: 'push_message_to_list')}) push_sync(params[:sync_push], {device_ids_opts: device_ids_opts, message: message, app_type: params[:app_type], igetui_opts: igetui_opts.merge(pusher_type: 'push_message_to_list')})
# NotificationStatistic.create_by_params(igetui_opts, message, device_ids_opts, params[:app_type]) # NotificationStatistic.create_by_params(igetui_opts, message, device_ids_opts, params[:app_type])
......
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