Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
app_push
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_server
app_push
Commits
97beeb1d
Commit
97beeb1d
authored
Dec 04, 2019
by
liangyuzhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
删除多余代码
parent
0f982532
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
10 additions
and
186 deletions
+10
-186
app/services/push/igetui.rb
+0
-79
app/services/push/igetui/push.rb
+0
-99
app/services/push/igetui_android.rb
+1
-0
app/services/push/igetui_ios.rb
+1
-0
app/services/push_tool_client.rb
+8
-8
No files found.
app/services/push/igetui.rb
deleted
100644 → 0
View file @
0f982532
module
Push
module
Igetui
class
<<
self
def
push
(
user_device_ids
,
template_data
=
{},
opts
=
{})
# 包装成igetui 真正需要的参数格式
opts
[
:transmission_content
]
=
template_data
if
user_device_ids
.
size
>
1
push_transmission_to_list_igetui
(
user_device_ids
,
opts
)
else
push_transmission_to_igetui
(
user_device_ids
,
opts
)
end
rescue
StandardError
=>
err
::
Push
::
Log
.
error
(
err
)
end
def
config
{
push_type:
2
}
end
def
push_transmission_to_igetui
(
user_device_id
,
template_data
=
{})
template_data
=
handle_template_data
(
template_data
)
push_igetui_with_asnyc
(
user_device_id
,
template_data
,
template_type:
'TransmissionTemplate'
)
end
def
push_transmission_to_list_igetui
(
user_device_ids
,
template_data
=
{})
template_data
=
handle_template_data
(
template_data
)
push_list_igetui_with_asnyc
(
user_device_ids
,
template_data
,
template_type:
'TransmissionTemplate'
,
pusher_type:
'push_message_to_list'
)
end
private
def
handle_template_data
(
template_data
)
template_data
=
HashWithIndifferentAccess
.
new
(
template_data
)
transmission_content
=
HashWithIndifferentAccess
.
new
(
template_data
.
delete
(
:transmission_content
))
transmission_content
[
:push_type
]
||=
config
[
:push_type
]
template_data
[
:transmission_type
]
||=
0
template_data
[
:transmission_content
]
=
transmission_content
.
as_json
template_data
end
def
push_igetui_with_asnyc
(
user_device_id
,
template_data
=
{},
opts
=
nil
)
return
if
template_data
.
blank?
opts
||=
HashWithIndifferentAccess
.
new
(
template_type:
'TransmissionTemplate'
)
template_data
=
HashWithIndifferentAccess
.
new
(
template_data
)
perform
(
template_data
,
opts
,
user_device_id
)
end
def
push_list_igetui_with_asnyc
(
user_device_ids
,
template_data
=
{},
opts
=
{
pusher_type:
'push_message_to_list'
})
return
if
user_device_ids
.
blank?
||
template_data
.
blank?
opts
||=
HashWithIndifferentAccess
.
new
(
template_type:
'TransmissionTemplate'
)
perform
(
template_data
,
opts
,
user_device_ids
)
end
def
perform
(
template_data
,
opts
,
user_device_ids
)
opts
=
HashWithIndifferentAccess
.
new
(
opts
)
igetui
=
Igetui
::
Push
.
new
(
template_data
,
opts
)
result
=
igetui
.
push_message_to
(
user_device_ids
)
::
Push
::
Log
.
info
(
"igetui_push:
\n
template_data:
#{
template_data
}
\n
opts:
#{
opts
}
\n
user_device_ids:
#{
user_device_ids
}
\n
response:
#{
result
}
"
)
end
end
end
end
\ No newline at end of file
app/services/push/igetui/push.rb
deleted
100644 → 0
View file @
0f982532
module
Push
module
Igetui
class
Push
attr_accessor
:pusher
,
:pusher_type
,
:template_type
,
:template
,
:template_data
PUSHERTYPES
=
%w[push_message_to_single push_message_to_list push_message_to_app]
.
freeze
TEMPLATETYPES
=
%w[LinkTemplate NotificationTemplate TransmissionTemplate NotyPopLoadTemplate]
.
freeze
DEVICEPLATFORMS
=
%w[android ios]
.
freeze
def
initialize
(
template_data
,
opts
=
{})
opts
=
HashWithIndifferentAccess
.
new
(
opts
)
@template_data
=
HashWithIndifferentAccess
.
new
(
template_data
||
{})
@pusher_type
=
PUSHERTYPES
.
include?
((
opts
[
:pusher_type
]).
to_s
)
?
opts
[:
pusher_type
]
:
'push_message_to_single'
@template_type
=
TEMPLATETYPES
.
include?
((
opts
[
:template_type
]).
to_s
)
?
opts
[:
template_type
]
:
'NotificationTemplate'
::
Push
::
Log
.
info
(
"@template_data is
#{
@template_data
.
to_json
}
"
)
set_message
set_template_data
@message
.
data
=
@template
end
def
push_message_to
(
client_id
)
client_id_list
=
Array
(
client_id
)
case
pusher_type
when
'push_message_to_single'
client_id_list
.
map
do
|
client_id
|
client
=
IGeTui
::
Client
.
new
(
client_id
)
pusher
.
push_message_to_single
(
@message
,
client
)
end
when
'push_message_to_list'
content_id
=
pusher
.
get_content_id
(
@message
)
clients
=
client_id_list
.
map
{
|
client_id
|
IGeTui
::
Client
.
new
(
client_id
)
}
pusher
.
push_message_to_list
(
content_id
,
clients
)
when
'push_message_to_app'
@message
.
app_id_list
=
client_id_list
pusher
.
push_message_to_app
(
@message
)
end
end
private
def
pusher
@pusher
||=
if
DEVICEPLATFORMS
.
include?
((
@template_data
[
'device_platform'
].
to_s
))
case
@template_data
[
'device_platform'
].
to_s
when
'android'
IGeTui
.
pusher
(
Settings
.
platform_settings
.
igetui
.
android
[
'app_id'
],
Settings
.
platform_settings
.
igetui
.
android
[
'app_key'
],
Settings
.
platform_settings
.
igetui
.
android
[
'master_secret'
]
)
when
'ios'
IGeTui
.
pusher
(
Settings
.
platform_settings
.
igetui
.
ios
[
'app_id'
],
Settings
.
platform_settings
.
igetui
.
ios
[
'app_key'
],
Settings
.
platform_settings
.
igetui
.
ios
[
'master_secret'
]
)
end
else
::
Push
::
Log
.
info
(
"设备类型不正确
#{
@device_platform
}
"
)
raise
"Failed to create pusher"
end
end
def
set_message
@message
=
case
pusher_type
when
'push_message_to_single'
IGeTui
::
SingleMessage
.
new
when
'push_message_to_list'
IGeTui
::
ListMessage
.
new
when
'push_message_to_app'
IGeTui
::
AppMessage
.
new
end
end
def
set_template_data
@template
=
"IGeTui::
#{
template_type
}
"
.
constantize
.
new
case
template_type
when
'NotificationTemplate'
,
'NotyPopLoadTemplate'
,
'LinkTemplate'
@template_data
.
reverse_merge!
(
Settings
.
platform_settings
.
igetui
[
'template_base'
])
@template_data
.
each
do
|
k
,
v
|
@template
.
send
(
"
#{
k
}
="
,
v
)
end
@template
.
set_push_info
(
*
@template_data
[
:push_info
])
if
@template_data
.
key?
:push_info
when
'TransmissionTemplate'
@template
.
transmission_content
=
@template_data
[
:transmission_content
].
is_a?
(
Hash
)
?
@template_data
[:
transmission_content
].
to_json
:
@template_data
[
:transmission_content
]
@template
.
transmission_type
=
@template_data
[
:transmission_type
]
if
@template_data
.
key?
(
:transmission_type
)
@template
.
set_push_info
(
*
@template_data
[
:push_info
])
if
@template_data
.
key?
:push_info
end
end
end
end
end
app/services/push/igetui_android.rb
View file @
97beeb1d
#通过组合模块的形式,将这个类赋予了推送的数据结构组合的功能,底层推送代码的功能等
module
Push
module
Push
class
IgetuiAndroid
class
IgetuiAndroid
include
Push
::
Igetui
::
Base
include
Push
::
Igetui
::
Base
...
...
app/services/push/igetui_ios.rb
View file @
97beeb1d
#通过组合模块的形式,将这个类赋予了推送的数据结构组合的功能,底层推送代码的功能等
module
Push
module
Push
class
IgetuiIos
class
IgetuiIos
include
Push
::
Igetui
::
Base
include
Push
::
Igetui
::
Base
...
...
app/services/push_tool_client.rb
View file @
97beeb1d
...
@@ -9,8 +9,8 @@ class PushToolClient
...
@@ -9,8 +9,8 @@ class PushToolClient
def
do_push
def
do_push
@push_collections
||=
push_collections
@push_collections
||=
push_collections
Push
::
IgetuiIos
.
push
(
@push_collections
[
:igetui_ios
],
@opts
)
if
@push_collections
[
:igetui_ios
].
present?
Push
::
IgetuiIos
.
new
(
@push_collections
[
:igetui_ios
],
@opts
).
push
if
@push_collections
[
:igetui_ios
].
present?
Push
::
IgetuiAndroid
.
push
(
@push_collections
[
:igetui_android
],
@opts
)
if
@push_collections
[
:igetui_android
].
present?
Push
::
IgetuiAndroid
.
new
(
@push_collections
[
:igetui_android
],
@opts
).
push
if
@push_collections
[
:igetui_android
].
present?
#现在好像不用了
#现在好像不用了
# Push::IgetuiIos.push(@push_collections[:igetui_ios], @opts) if @push_collections[:apns].present?
# Push::IgetuiIos.push(@push_collections[:igetui_ios], @opts) if @push_collections[:apns].present?
...
@@ -23,7 +23,7 @@ class PushToolClient
...
@@ -23,7 +23,7 @@ class PushToolClient
private
private
def
push_collections
def
push_collections
@
push_collection
=
{
_
push_collection
=
{
igetui_ios:
[],
igetui_ios:
[],
igetui_android:
[],
igetui_android:
[],
apns:
[],
apns:
[],
...
@@ -39,16 +39,16 @@ class PushToolClient
...
@@ -39,16 +39,16 @@ class PushToolClient
case
user_device
.
platform
case
user_device
.
platform
when
'igetui'
when
'igetui'
if
user_device
.
device_platform
==
'ios'
if
user_device
.
device_platform
==
'ios'
@
push_collection
[
:igetui_ios
]
<<
client_id
_
push_collection
[
:igetui_ios
]
<<
client_id
else
else
@
push_collection
[
:igetui_ios
]
<<
client_id
_
push_collection
[
:igetui_ios
]
<<
client_id
end
end
when
'apns'
when
'apns'
@
push_collection
[
:apns
]
<<
client_id
_
push_collection
[
:apns
]
<<
client_id
when
'xiaomi'
when
'xiaomi'
@
push_collection
[
:xiaomi
]
<<
client_id
_
push_collection
[
:xiaomi
]
<<
client_id
when
'huawei'
when
'huawei'
@
push_collection
[
:huawei
]
<<
client_id
_
push_collection
[
:huawei
]
<<
client_id
end
end
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment