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
6e731a60
Commit
6e731a60
authored
Dec 24, 2019
by
liangyuzhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init pusher
parent
b3d25f2a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
82 additions
and
31 deletions
+82
-31
app/controllers/pushs_controller.rb
+1
-2
app/services/igetui/pusher.rb
+11
-7
app/services/push_tool_client.rb
+9
-8
config/database.yml
+6
-4
config/initializers/pusher.rb
+55
-10
No files found.
app/controllers/pushs_controller.rb
View file @
6e731a60
...
...
@@ -36,10 +36,9 @@ class PushsController < ApplicationController
if
token_array
.
blank?
return
render
json:
{
code:
-
1
,
message:
'token错误'
}
end
byebug
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'
)})
render
json:
{
code:
0
,
message:
'success'
,
describe:
'异步任务正在处理'
}
else
...
...
app/services/igetui/pusher.rb
View file @
6e731a60
...
...
@@ -6,7 +6,7 @@ module Igetui
@template_data
=
opts
[
:message
]
@igetui_opts
=
opts
[
:igetui_opts
]
@user_device_ids
=
user_device_ids
@pusher
=
pusher
(
opts
[
:device_platform
])
@pusher
=
pusher
(
opts
[
:device_platform
]
,
opts
[
:app_type
]
)
@pusher_type
=
@igetui_opts
[
:pusher_type
]
end
...
...
@@ -22,12 +22,16 @@ module Igetui
end
private
def
pusher
(
device_platform
)
case
device_platform
when
'android'
$android_pusher
when
'ios'
$ios_pusher
def
pusher
(
device_platform
,
app_type
)
case
app_type
when
'lx_duli'
device_platform
==
'android'
?
$lx_duli_android_pusher
:
$lx_duli_ios_pusher
when
'lx_yun'
device_platform
==
'android'
?
$lx_yun_android_pusher
:
$lx_yun_ios_pusher
when
'aike_yun'
device_platform
==
'android'
?
$aike_yun_android_pusher
:
$aike_yun_ios_pusher
else
'ik_duli'
device_platform
==
'android'
?
$ik_duli_android_pusher
:
$ik_duli_ios_pusher
end
end
...
...
app/services/push_tool_client.rb
View file @
6e731a60
...
...
@@ -12,21 +12,21 @@ class PushToolClient
@push_device_collections
||=
UserDevice
.
where
(
user_id:
@user_ids
).
group_by
(
&
:platform
)
@igetui_push_device_collections
||=
@push_device_collections
[
'igetui'
].
group_by
(
&
:device_platform
)
if
@push_device_collections
[
'igetui'
].
is_a?
Array
if
@igetui_push_device_collections
.
is_a?
Hash
igetui_android_
device_ids
=
@igetui_push_device_collections
[
'android'
].
map
(
&
:device
_id
)
if
@igetui_push_device_collections
[
'android'
].
is_a?
Array
igetui_ios_
device_ids
=
@igetui_push_device_collections
[
'ios'
].
map
(
&
:devendice
_id
)
if
@igetui_push_device_collections
[
'ios'
].
is_a?
Array
igetui_android_
client_ids
=
@igetui_push_device_collections
[
'android'
].
map
(
&
:client
_id
)
if
@igetui_push_device_collections
[
'android'
].
is_a?
Array
igetui_ios_
client_ids
=
@igetui_push_device_collections
[
'ios'
].
map
(
&
:client
_id
)
if
@igetui_push_device_collections
[
'ios'
].
is_a?
Array
end
Igetui
::
Pusher
.
new
(
igetui_android_
device_ids
,
@opts
.
merge
(
device_platform:
'android'
)).
perform
if
igetui_android_device
_ids
.
present?
Igetui
::
Pusher
.
new
(
igetui_ios_
device_ids
,
@opts
.
merge
(
device_platform:
'ios'
)).
perform
if
igetui_ios_device
_ids
.
present?
Igetui
::
Pusher
.
new
(
igetui_android_
client_ids
,
@opts
.
merge
(
device_platform:
'android'
)).
perform
if
igetui_android_client
_ids
.
present?
Igetui
::
Pusher
.
new
(
igetui_ios_
client_ids
,
@opts
.
merge
(
device_platform:
'ios'
)).
perform
if
igetui_ios_client
_ids
.
present?
#现在好像不用了
# Push::IgetuiIos.push(@push_collections[:igetui_ios], @opts) if @push_collections[:apns].present?
# Push::IgetuiAndroid.push(@push_collections[:igetui_android], @opts) if @push_collections[:apns].present?
xiaomi_
device_ids
=
@push_device_collections
[
'xiaomi'
].
map
(
&
:device
_id
)
if
@push_device_collections
[
'xiaomi'
].
is_a?
Array
huawei_
device_ids
=
@push_device_collections
[
'huawei'
].
map
(
&
:device
_id
)
if
@push_device_collections
[
'huawei'
].
is_a?
Array
xiaomi_
client_ids
=
@push_device_collections
[
'xiaomi'
].
map
(
&
:client
_id
)
if
@push_device_collections
[
'xiaomi'
].
is_a?
Array
huawei_
client_ids
=
@push_device_collections
[
'huawei'
].
map
(
&
:client
_id
)
if
@push_device_collections
[
'huawei'
].
is_a?
Array
Xiaomi
::
Pusher
.
new
(
xiaomi_
device_ids
,
@opts
[
:message
]).
perform
if
xiaomi_device
_ids
.
present?
Huawei
::
Pusher
.
new
(
huawei_
device_ids
,
@opts
[
:message
]).
perform
if
huawei_device
_ids
.
present?
Xiaomi
::
Pusher
.
new
(
xiaomi_
client_ids
,
@opts
[
:message
]).
perform
if
xiaomi_client
_ids
.
present?
Huawei
::
Pusher
.
new
(
huawei_
client_ids
,
@opts
[
:message
]).
perform
if
huawei_client
_ids
.
present?
end
end
\ No newline at end of file
config/database.yml
View file @
6e731a60
...
...
@@ -8,7 +8,8 @@ default: &default
adapter
:
mysql2
encoding
:
utf8
pool
:
10
host
:
rdscbq34656z0ix59br0.mysql.rds.aliyuncs.com
host
:
rm-m5eu4m6a4rugr22fcno.mysql.rds.aliyuncs.com
development
:
<<
:
*default
...
...
@@ -16,9 +17,9 @@ development:
#host: 10.140.235.122
#username: vcooline_ikcrm_testing
#password: ikcrm_123
database
:
crm_
test
username
:
lx_duli_test
password
:
'
@NshoftqW!$%0eFQ'
database
:
crm_
staging
username
:
crm_staging
password
:
rCxWfEbdJrEp3Mff
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
...
...
@@ -30,3 +31,4 @@ test:
production
:
<<
:
*default
database
:
db/production.sqlite3
config/initializers/pusher.rb
View file @
6e731a60
$android_pusher
||=
$
ik_duli_
android_pusher
||=
IGeTui
.
pusher
(
Settings
.
platform_settings
.
igetui
.
android
[
'app_id'
],
Settings
.
platform_settings
.
igetui
.
android
[
'app_key'
],
Settings
.
platform_settings
.
igetui
.
android
[
'master_secret'
]
Settings
.
ik_duli
.
igetui
.
android
[
'app_id'
],
Settings
.
ik_duli
.
igetui
.
android
[
'app_key'
],
Settings
.
ik_duli
.
igetui
.
android
[
'master_secret'
]
)
$ios_pusher
||=
$i
k_duli_i
os_pusher
||=
IGeTui
.
pusher
(
Settings
.
platform_settings
.
igetui
.
ios
[
'app_id'
],
Settings
.
platform_settings
.
igetui
.
ios
[
'app_key'
],
Settings
.
platform_settings
.
igetui
.
ios
[
'master_secret'
]
)
\ No newline at end of file
Settings
.
ik_duli
.
igetui
.
ios
[
'app_id'
],
Settings
.
ik_duli
.
igetui
.
ios
[
'app_key'
],
Settings
.
ik_duli
.
igetui
.
ios
[
'master_secret'
]
)
$lx_duli_android_pusher
||=
IGeTui
.
pusher
(
Settings
.
lx_duli
.
igetui
.
android
[
'app_id'
],
Settings
.
lx_duli
.
igetui
.
android
[
'app_key'
],
Settings
.
lx_duli
.
igetui
.
android
[
'master_secret'
]
)
$lx_duli_ios_pusher
||=
IGeTui
.
pusher
(
Settings
.
lx_duli
.
igetui
.
ios
[
'app_id'
],
Settings
.
lx_duli
.
igetui
.
ios
[
'app_key'
],
Settings
.
lx_duli
.
igetui
.
ios
[
'master_secret'
]
)
$lx_yun_android_pusher
||=
IGeTui
.
pusher
(
Settings
.
lx_yun
.
igetui
.
android
[
'app_id'
],
Settings
.
lx_yun
.
igetui
.
android
[
'app_key'
],
Settings
.
lx_yun
.
igetui
.
android
[
'master_secret'
]
)
$lx_yun_ios_pusher
||=
IGeTui
.
pusher
(
Settings
.
lx_yun
.
igetui
.
ios
[
'app_id'
],
Settings
.
lx_yun
.
igetui
.
ios
[
'app_key'
],
Settings
.
lx_yun
.
igetui
.
ios
[
'master_secret'
]
)
$aike_yun_android_pusher
||=
IGeTui
.
pusher
(
Settings
.
aike_yun
.
igetui
.
android
[
'app_id'
],
Settings
.
aike_yun
.
igetui
.
android
[
'app_key'
],
Settings
.
aike_yun
.
igetui
.
android
[
'master_secret'
]
)
$aike_yun_ios_pusher
||=
IGeTui
.
pusher
(
Settings
.
aike_yun
.
igetui
.
ios
[
'app_id'
],
Settings
.
aike_yun
.
igetui
.
ios
[
'app_key'
],
Settings
.
aike_yun
.
igetui
.
ios
[
'master_secret'
]
)
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