Commit 56e473d6 by 杨璇

Merge branch 'fix/xiaomi_push' into testing

parents 35285f68 82acbcb2
module Igetui module Igetui
class Pusher class Pusher
def initialize(user_device_ids, opts) def initialize(user_device_ids, opts)
opts = HashWithIndifferentAccess.new(opts) opts = HashWithIndifferentAccess.new(opts)
@template_data = opts[:message] @template_data = opts[:message]
...@@ -10,7 +10,7 @@ module Igetui ...@@ -10,7 +10,7 @@ module Igetui
@pusher_type = @igetui_opts[:pusher_type] @pusher_type = @igetui_opts[:pusher_type]
@uuid = Random.uuid.to_s @uuid = Random.uuid.to_s
end end
def perform def perform
@template_data[:push_type] ||= 2 @template_data[:push_type] ||= 2
@igetui_opts[:transmission_type] ||= 0 @igetui_opts[:transmission_type] ||= 0
...@@ -21,7 +21,7 @@ module Igetui ...@@ -21,7 +21,7 @@ module Igetui
result = push_message_to(@pusher, @pusher_type, template_type, template_data, @user_device_ids) result = push_message_to(@pusher, @pusher_type, template_type, template_data, @user_device_ids)
::Log.info("igetui_push: \n template_data: #{template_data}\n user_device_ids: #{@user_device_ids}\n response: #{result}", @uuid) ::Log.info("igetui_push: \n template_data: #{template_data}\n user_device_ids: #{@user_device_ids}\n response: #{result}", @uuid)
end end
private private
def pusher(device_platform, app_type) def pusher(device_platform, app_type)
case app_type case app_type
...@@ -44,7 +44,7 @@ module Igetui ...@@ -44,7 +44,7 @@ module Igetui
when 'push_message_to_single' when 'push_message_to_single'
message = IGeTui::SingleMessage.new message = IGeTui::SingleMessage.new
message.data = template message.data = template
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)
res = pusher.push_message_to_single(message, client) res = pusher.push_message_to_single(message, client)
...@@ -53,18 +53,18 @@ module Igetui ...@@ -53,18 +53,18 @@ module Igetui
when 'push_message_to_list' when 'push_message_to_list'
message = IGeTui::ListMessage.new message = IGeTui::ListMessage.new
message.data = template message.data = template
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) }
res = 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}", @uuid) ::Log.info("push_message_to_list clients: #{clients.to_json} and message is #{message.to_json} and res is #{res}", @uuid)
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
res = 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}", @uuid) ::Log.info("push_message_to_app message is #{message.to_json} and res is #{res}", @uuid)
end end
...@@ -75,7 +75,7 @@ module Igetui ...@@ -75,7 +75,7 @@ module Igetui
case template_type case template_type
when 'NotificationTemplate', 'NotyPopLoadTemplate', 'LinkTemplate' when 'NotificationTemplate', 'NotyPopLoadTemplate', 'LinkTemplate'
template_data.reverse_merge!(Settings.platform_settings.igetui['template_base']) template_data.reverse_merge!(Settings.platform_settings.igetui['template_base'])
template_data.each do |k, v| template_data.each do |k, v|
@template.send("#{k}=", v) @template.send("#{k}=", v)
end end
......
...@@ -2,7 +2,7 @@ module Xiaomi ...@@ -2,7 +2,7 @@ module Xiaomi
class Pusher class Pusher
PUSH_URL = 'https://api.xmpush.xiaomi.com/v3/message/regid'.freeze PUSH_URL = 'https://api.xmpush.xiaomi.com/v3/message/regid'.freeze
BATCH_PUSH_MAX = 80 BATCH_PUSH_MAX = 80
def initialize(device_ids, message, app_type) def initialize(device_ids, message, app_type)
@registration_ids = device_ids @registration_ids = device_ids
@payload = message @payload = message
...@@ -39,10 +39,10 @@ module Xiaomi ...@@ -39,10 +39,10 @@ module Xiaomi
# 0 表示通知栏消息, 1 表示透传消息 # 0 表示通知栏消息, 1 表示透传消息
def config def config
restricted_package_name = Settings.send(@app_type).xiaomi['package_name'] restricted_package_name = Settings.send(@app_type).xiaomi['package_name']
{ {
restricted_package_name: restricted_package_name, restricted_package_name: restricted_package_name,
pass_through: 1, pass_through: 0,
title: 'xiaomi push', title: 'xiaomi push',
description: 'xiaomi push', description: 'xiaomi push',
notify_type: 1 notify_type: 1
......
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