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
1ab512d5
Commit
1ab512d5
authored
Oct 21, 2019
by
李福中
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into release
parents
456db818
953eb382
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
1 deletions
+14
-1
.gitignore
+1
-0
app/controllers/pushs_controller.rb
+12
-0
app/services/push/huawei.rb
+1
-1
No files found.
.gitignore
View file @
1ab512d5
...
...
@@ -6,6 +6,7 @@
/pkg/
/spec/reports/
/tmp/
.idea
# Ignore bundler config.
/.bundle
...
...
app/controllers/pushs_controller.rb
View file @
1ab512d5
...
...
@@ -25,13 +25,25 @@ class PushsController < ApplicationController
param!
:message
,
String
,
required:
true
param!
:igetui_opts
,
String
param!
:app_type
,
String
param!
:sync_push
,
String
igetui_opts
=
JSON
.
parse
(
params
[
:igetui_opts
])
rescue
{}
message
=
JSON
.
parse
(
params
[
:message
])
rescue
{}
device_ids_opts
=
JSON
.
parse
(
params
[
:device_ids_opts
])
rescue
{}
token
=
token_and_options
(
request
).
first
if
token
==
Token
.
token
(
params
[
:app_name
])
if
params
.
has_key?
(
:sync_push
)
timeout_seconds
=
$redis
.
get
(
'push_timeout'
).
to_i
if
timeout_seconds
>
0
Timeout
.
timeout
(
timeout_seconds
)
{
::
PushWorker
.
new
.
perform
(
device_ids_opts
,
message
,
igetui_opts
,
params
[
:app_type
])
}
else
::
PushWorker
.
new
.
perform
(
device_ids_opts
,
message
,
igetui_opts
,
params
[
:app_type
])
end
else
::
PushWorker
.
perform_async
(
device_ids_opts
,
message
,
igetui_opts
,
params
[
:app_type
])
end
render
json:
{
code:
0
,
message:
'success'
,
describe:
'异步任务正在处理'
}
else
render
json:
{
code:
-
1
,
message:
'token 错误/过期'
}
...
...
app/services/push/huawei.rb
View file @
1ab512d5
...
...
@@ -86,7 +86,7 @@ module Push
headers
=
{
'Content-Type'
=>
'application/x-www-form-urlencoded'
}
response
=
HTTParty
.
post
(
url
,
body:
body
,
headers:
headers
,
timeout:
5
)
Push
::
Log
.
info
(
"huawei_push:
\n
access_token:
#{
access_token
}
expire_time:
#{
$redis
.
ttl
(
Push
::
Huawei
::
ACCESS_TOKEN_KEY
)
}
\n
url:
#{
url
}
\n
body:
#{
body
}
\n
response:
#{
response
}
"
)
JSON
.
parse
(
response
)
JSON
.
parse
(
response
.
body
)
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