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
eda8b90a
Commit
eda8b90a
authored
Jun 11, 2021
by
giaogiao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
消息撤回功能;
您收到一条新消息 系统推送修改为英文
parent
c9bbd69c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
9 deletions
+63
-9
common/src/main/java/com/wecloud/im/controller/ImMessageController.java
+10
-0
common/src/main/java/com/wecloud/im/service/ImMessageService.java
+9
-0
common/src/main/java/com/wecloud/im/service/impl/ImMessageServiceImpl.java
+29
-0
common/src/main/java/com/wecloud/im/tillo/app_ws/sender/PushTask.java
+15
-9
No files found.
common/src/main/java/com/wecloud/im/controller/ImMessageController.java
View file @
eda8b90a
...
...
@@ -18,6 +18,7 @@ import org.springframework.validation.annotation.Validated;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
...
...
@@ -38,6 +39,15 @@ public class ImMessageController extends BaseController {
private
ImMessageService
imMessageService
;
/**
* 消息撤回
*/
@PostMapping
(
"/withdraw"
)
@ApiOperation
(
value
=
"消息撤回"
,
notes
=
"只能撤回客户端自己发送的消息"
)
public
ApiResult
<
Boolean
>
updateMsgWithdrawById
(
@RequestParam
Long
msgId
)
throws
Exception
{
return
imMessageService
.
updateMsgWithdrawById
(
msgId
);
}
/**
* 修改消息体
*/
@PostMapping
(
"/updateMsgById"
)
...
...
common/src/main/java/com/wecloud/im/service/ImMessageService.java
View file @
eda8b90a
...
...
@@ -21,6 +21,15 @@ import java.util.List;
*/
public
interface
ImMessageService
extends
BaseService
<
ImMessage
>
{
/**
* 消息撤回 只能撤回客户端自己发送的消息
*
* @param msgId
* @return
*/
ApiResult
<
Boolean
>
updateMsgWithdrawById
(
Long
msgId
);
/**
* 修改消息体
*
...
...
common/src/main/java/com/wecloud/im/service/impl/ImMessageServiceImpl.java
View file @
eda8b90a
...
...
@@ -28,6 +28,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
/**
...
...
@@ -50,6 +51,34 @@ public class ImMessageServiceImpl extends BaseServiceImpl<ImMessageMapper, ImMes
private
ImConversationService
imConversationService
;
@Override
public
ApiResult
<
Boolean
>
updateMsgWithdrawById
(
Long
msgId
)
{
ImClient
client
=
imClientService
.
getClient
();
// 判断该消息是否是该客户端发送
ImMessage
messageById
=
this
.
getById
(
msgId
);
if
(!
messageById
.
getSender
().
equals
(
client
.
getId
()))
{
log
.
error
(
"判断该消息是否是该客户端发送"
);
return
ApiResult
.
fail
();
}
if
(
messageById
.
getWithdraw
())
{
return
ApiResult
.
ok
();
}
messageById
.
setWithdraw
(
Boolean
.
TRUE
);
messageById
.
setWithdrawTime
(
new
Date
());
messageById
.
setContent
(
"{}"
);
boolean
b
=
this
.
updateById
(
messageById
);
if
(
b
)
{
return
ApiResult
.
ok
();
}
else
{
return
ApiResult
.
fail
();
}
}
@Override
public
ApiResult
<
Boolean
>
updateMsgById
(
ImMsgUpdate
imMsgUpdate
)
{
ImClient
client
=
imClientService
.
getClient
();
...
...
common/src/main/java/com/wecloud/im/tillo/app_ws/sender/PushTask.java
View file @
eda8b90a
...
...
@@ -28,6 +28,13 @@ public class PushTask {
*/
private
static
final
String
API_URL_FCM
=
"https://fcm.googleapis.com/fcm/send"
;
//您收到一条新消息
String
title
=
"You have received a new message"
;
//点击查看
String
body
=
"Click to view"
;
/**
* 异步系统推送
*
...
...
@@ -69,9 +76,8 @@ public class PushTask {
// 安卓 单推
String
deviceTokenIOS
=
imClientReceiver
.
getDeviceToken
();
String
titleIOS
=
"收到新消息"
;
String
titleIOS
=
title
;
String
subtitle
=
""
;
String
body
=
"点击查看"
;
try
{
pushUtils
.
sendIOSUnicast
(
deviceTokenIOS
,
titleIOS
,
subtitle
,
body
);
}
catch
(
Exception
e
)
{
...
...
@@ -99,8 +105,10 @@ public class PushTask {
//推送到哪台客户端机器
json
.
put
(
"to"
,
imClientReceiver
.
getDeviceToken
());
JSONObject
info
=
new
JSONObject
();
info
.
put
(
"title"
,
"新消息"
);
info
.
put
(
"body"
,
"点击查看"
);
info
.
put
(
"title"
,
title
);
info
.
put
(
"body"
,
body
);
//数据消息data 通知消息 notification
json
.
put
(
"notification"
,
info
);
...
...
@@ -111,7 +119,6 @@ public class PushTask {
InputStream
inputStream
=
conn
.
getInputStream
();
InputStreamReader
in
=
new
InputStreamReader
(
inputStream
);
BufferedReader
reader
=
new
BufferedReader
(
in
);
// String line = null;
wr
.
close
();
reader
.
close
();
...
...
@@ -141,8 +148,7 @@ public class PushTask {
// 安卓单推
String
deviceToken
=
imClientReceiver
.
getDeviceToken
();
String
unicastText
=
"Android unicast text"
;
String
unicastTicker
=
"点击查看"
;
String
title
=
"收到新消息"
;
String
unicastTicker
=
body
;
try
{
pushUtils
.
sendAndroidUnicast
(
deviceToken
,
unicastText
,
unicastTicker
,
title
);
}
catch
(
Exception
e
)
{
...
...
@@ -171,8 +177,8 @@ public class PushTask {
//推送到哪台客户端机器
json
.
put
(
"to"
,
imClientReceiver
.
getDeviceToken
());
JSONObject
info
=
new
JSONObject
();
info
.
put
(
"title"
,
"新消息"
);
info
.
put
(
"body"
,
"点击查看"
);
info
.
put
(
"title"
,
title
);
info
.
put
(
"body"
,
body
);
//数据消息data 通知消息 notification
json
.
put
(
"notification"
,
info
);
...
...
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