Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wecloud_im_server
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
hewei
wecloud_im_server
Commits
6066a5d3
Commit
6066a5d3
authored
Jan 20, 2022
by
hewei
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature-1.4-pushParam' into '1.4'
Feature 1.4 push param See merge request
!12
parents
6fdcff36
78ffad7a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
25 deletions
+62
-25
common/src/main/java/com/wecloud/im/ws/model/request/PushModel.java
+2
-1
common/src/main/java/com/wecloud/im/ws/sender/PushTask.java
+30
-10
common/src/main/java/com/wecloud/im/ws/strategy/concrete/ImChatConcrete.java
+2
-2
config/src/main/resources/config/logback.xml
+28
-12
No files found.
common/src/main/java/com/wecloud/im/ws/model/request/PushModel.java
View file @
6066a5d3
...
...
@@ -3,6 +3,7 @@ package com.wecloud.im.ws.model.request;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.HashMap
;
/**
* @Description 推送model
...
...
@@ -25,7 +26,7 @@ public class PushModel implements Serializable {
/**
* 自定义系统推送内容
*/
private
String
data
;
private
HashMap
data
;
}
common/src/main/java/com/wecloud/im/ws/sender/PushTask.java
View file @
6066a5d3
package
com
.
wecloud
.
im
.
ws
.
sender
;
import
cn.hutool.core.codec.Base64
;
import
com.fasterxml.jackson.databind.json.JsonMapper
;
import
com.turo.pushy.apns.DeliveryPriority
;
import
com.turo.pushy.apns.PushType
;
import
com.wecloud.im.entity.ImApplication
;
...
...
@@ -32,6 +33,7 @@ import java.util.Map;
@Component
@Slf4j
public
class
PushTask
{
private
static
final
JsonMapper
JSON_MAPPER
=
new
JsonMapper
();
@Autowired
private
ImIosApnsService
imIosApnsService
;
...
...
@@ -73,6 +75,7 @@ public class PushTask {
pushModel
=
new
PushModel
();
pushModel
.
setTitle
(
PUSH_TITLE
);
pushModel
.
setSubTitle
(
PUSH_BODY
);
pushModel
.
setData
(
new
HashMap
<>(
1
));
}
// 校验参数
...
...
@@ -102,22 +105,36 @@ public class PushTask {
* @param imClientReceiver
*/
@Async
public
void
push
(
HashMap
<
String
,
String
>
pushMap
,
ImClient
imClientReceiver
,
ImApplication
imApplication
)
{
public
void
push
(
HashMap
<
String
,
Object
>
pushMap
,
ImClient
imClientReceiver
,
ImApplication
imApplication
)
{
log
.
info
(
"push:"
+
imClientReceiver
.
getClientId
());
PushModel
pushModel
=
new
PushModel
();
PushModel
pushModel
=
getPushModel
(
pushMap
);
this
.
push
(
pushModel
,
imClientReceiver
,
imApplication
);
}
private
PushModel
getPushModel
(
HashMap
<
String
,
Object
>
pushMap
)
{
PushModel
pushModel
=
new
PushModel
();
if
(
pushMap
==
null
||
pushMap
.
isEmpty
())
{
pushModel
.
setTitle
(
PUSH_TITLE
);
pushModel
.
setSubTitle
(
PUSH_BODY
);
pushModel
.
setData
(
new
HashMap
<>(
1
));
}
else
{
pushModel
.
setTitle
(
pushMap
.
get
(
title
));
pushModel
.
setSubTitle
(
pushMap
.
get
(
subTitle
));
pushModel
.
setData
(
pushMap
.
get
(
DATA
));
}
pushModel
.
setTitle
((
String
)
pushMap
.
get
(
title
));
pushModel
.
setSubTitle
((
String
)
pushMap
.
get
(
subTitle
));
this
.
push
(
pushModel
,
imClientReceiver
,
imApplication
);
// 自定义推送内容
// try {
HashMap
hashMap
=
(
HashMap
)
pushMap
.
get
(
DATA
);
pushModel
.
setData
(
hashMap
);
// } catch (JsonProcessingException e) {
// log.error("pushModel.setData(hashMap)", e);
// pushModel.setData(new HashMap<>(1));
// }
}
return
pushModel
;
}
private
void
android
(
PushModel
pushModel
,
ImClient
imClientReceiver
,
ImApplication
imApplication
)
{
...
...
@@ -221,9 +238,9 @@ public class PushTask {
info
.
put
(
"body"
,
pushModel
.
getSubTitle
());
// 自定义推送字段
Map
<
String
,
String
>
dataMap
=
new
HashMap
<>();
dataMap
.
put
(
"data"
,
pushModel
.
getData
());
info
.
put
(
"data"
,
dataMap
);
//
Map<String, String> dataMap = new HashMap<>();
// dataMap.put("data", JSON_MAPPER.writeValueAsString
());
json
.
put
(
"data"
,
pushModel
.
getData
()
);
//数据消息data 通知消息 notification
json
.
put
(
"notification"
,
info
);
...
...
@@ -232,6 +249,9 @@ public class PushTask {
OutputStreamWriter
wr
=
new
OutputStreamWriter
(
conn
.
getOutputStream
());
jsonStr
=
json
.
toString
();
log
.
info
(
"FCM push data {}"
,
jsonStr
);
wr
.
write
(
jsonStr
);
wr
.
flush
();
InputStream
inputStream
=
conn
.
getInputStream
();
...
...
common/src/main/java/com/wecloud/im/ws/strategy/concrete/ImChatConcrete.java
View file @
6066a5d3
...
...
@@ -112,9 +112,9 @@ public class ImChatConcrete extends ImCmdAbstract {
receiveModel
.
getData
().
remove
(
TO_CONVERSATION_KEY
);
// 获取自定义推送字段
HashMap
<
String
,
String
>
pushMap
=
null
;
HashMap
<
String
,
Object
>
pushMap
=
null
;
if
(
receiveModel
.
getData
().
get
(
PUSH_KEY
)
!=
null
)
{
pushMap
=
(
HashMap
<
String
,
String
>)
receiveModel
.
getData
().
get
(
PUSH_KEY
);
pushMap
=
(
HashMap
<
String
,
Object
>)
receiveModel
.
getData
().
get
(
PUSH_KEY
);
receiveModel
.
getData
().
remove
(
PUSH_KEY
);
}
...
...
config/src/main/resources/config/logback.xml
View file @
6066a5d3
...
...
@@ -147,18 +147,33 @@
<!-- 解决SpringBootAdmin错误日志问题 -->
<logger
name=
"org.apache.catalina.connector.CoyoteAdapter"
level=
"OFF"
/>
<root
level=
"INFO"
>
<appender-ref
ref=
"ELASTIC"
/>
<appender-ref
ref=
"CONSOLE"
/>
<appender-ref
ref=
"ASYNC_FILE"
/>
<appender-ref
ref=
"ASYNC_ERROR_FILE"
/>
</root>
<!-- <springProfile name="eslog">-->
<!-- <root level="INFO">-->
<!-- <appender-ref ref="ELASTIC"/>-->
<!-- </root>-->
<!-- </springProfile>-->
<springProfile
name=
"dev"
>
<root
level=
"INFO"
>
<!-- <appender-ref ref="ELASTIC"/>-->
<appender-ref
ref=
"CONSOLE"
/>
<appender-ref
ref=
"ASYNC_FILE"
/>
<appender-ref
ref=
"ASYNC_ERROR_FILE"
/>
</root>
</springProfile>
<springProfile
name=
"test"
>
<root
level=
"INFO"
>
<appender-ref
ref=
"ELASTIC"
/>
<appender-ref
ref=
"CONSOLE"
/>
<appender-ref
ref=
"ASYNC_FILE"
/>
<appender-ref
ref=
"ASYNC_ERROR_FILE"
/>
</root>
</springProfile>
<springProfile
name=
"prod"
>
<root
level=
"INFO"
>
<appender-ref
ref=
"ELASTIC"
/>
<appender-ref
ref=
"CONSOLE"
/>
<appender-ref
ref=
"ASYNC_FILE"
/>
<appender-ref
ref=
"ASYNC_ERROR_FILE"
/>
</root>
</springProfile>
</configuration>
\ No newline at end of file
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