添加服务器端删除消息的api

This commit is contained in:
imhao183
2020-05-03 13:38:18 +08:00
parent 2163b9d580
commit 1654baa523
4 changed files with 53 additions and 0 deletions
@@ -465,6 +465,13 @@ public class Main {
System.exit(-1);
}
voidIMResult = MessageAdmin.deleteMessage(resultSendMessage.getResult().getMessageUid());
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
System.out.println("delete message success");
} else {
System.out.println("delete message failure");
System.exit(-1);
}
IMResult<BroadMessageResult> resultBroadcastMessage = MessageAdmin.broadcastMessage("user1", 0, payload);
if (resultBroadcastMessage != null && resultBroadcastMessage.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
@@ -25,6 +25,30 @@ public class MessageAdmin {
return AdminHttpUtils.httpJsonPost(path, messageData, Void.class);
}
public static IMResult<Void> deleteMessage(long messageUid) throws Exception {
String path = APIPath.Msg_Delete;
DeleteMessageData deleteMessageData = new DeleteMessageData();
deleteMessageData.setMessageUid(messageUid);
return AdminHttpUtils.httpJsonPost(path, deleteMessageData, Void.class);
}
/**
* 撤回群发或者广播的消息
* @param target 目标用户
* @param messageUid 消息唯一ID
* @return
* @throws Exception
*/
public static IMResult<Void> recallBroadcastOrMulticastMessage(String target, long messageUid) throws Exception {
String path = APIPath.Msg_Recall;
RecallMessageData messageData = new RecallMessageData();
messageData.setOperator(target);
messageData.setMessageUid(messageUid);
return AdminHttpUtils.httpJsonPost(path, messageData, Void.class);
}
public static IMResult<BroadMessageResult> broadcastMessage(String sender, int line, MessagePayload payload) throws Exception {
String path = APIPath.Msg_Broadcast;
BroadMessageData messageData = new BroadMessageData();