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
b3d25f2a
Commit
b3d25f2a
authored
Dec 24, 2019
by
liangyuzhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add logger
parent
d3f6c0cd
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
10 deletions
+16
-10
app/controllers/pushs_controller.rb
+10
-6
app/services/igetui/pusher.rb
+6
-4
No files found.
app/controllers/pushs_controller.rb
View file @
b3d25f2a
...
...
@@ -29,14 +29,14 @@ class PushsController < ApplicationController
user_device_exist
=
UserDevice
.
where
(
user_id:
params
[
:user_id
]).
exists?
unless
user_device_exist
render
json:
{
code:
-
1
,
message:
'user_device找不到,user_id错误'
}
re
turn
re
nder
json:
{
code:
-
1
,
message:
'user_device找不到,user_id错误'
}
end
token_array
=
token_and_options
(
request
)
if
token_array
.
blank?
render
json:
{
code:
-
1
,
message:
'token错误'
}
re
turn
re
nder
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'
)})
...
...
@@ -63,11 +63,15 @@ class PushsController < ApplicationController
user_devices_exists
=
UserDevice
.
where
(
user_id:
user_ids
).
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
token
=
token_and_options
(
request
).
first
if
validate_token
(
params
[
:app_name
],
token
)
if
validate_token
(
params
[
:app_name
],
token_array
.
first
)
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:
'异步任务正在处理'
}
...
...
app/services/igetui/pusher.rb
View file @
b3d25f2a
...
...
@@ -42,8 +42,8 @@ module Igetui
client_id_list
.
map
do
|
client_id
|
client
=
IGeTui
::
Client
.
new
(
client_id
)
byebug
pusher
.
push_message_to_single
(
message
,
client
)
res
=
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
when
'push_message_to_list'
message
=
IGeTui
::
ListMessage
.
new
...
...
@@ -52,14 +52,16 @@ module Igetui
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
)
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'
message
=
IGeTui
::
AppMessage
.
new
message
.
data
=
template
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
...
...
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