Compare commits

...
5 Commits
17 changed files with 116 additions and 46 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
<relativePath>../</relativePath> <relativePath>../</relativePath>
<artifactId>wildfirechat-parent</artifactId> <artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId> <groupId>cn.wildfirechat</groupId>
<version>1.1.6</version> <version>1.1.7</version>
</parent> </parent>
<artifactId>moquette-broker</artifactId> <artifactId>moquette-broker</artifactId>
@@ -12,9 +12,11 @@ package cn.wildfirechat.push;
public class PushMessage { public class PushMessage {
public String sender; public String sender;
public String senderName; public String senderName;
public String senderPortrait;
public int convType; public int convType;
public String target; public String target;
public String targetName; public String targetName;
public String targetPortrait;
public String userId; public String userId;
public int line; public int line;
public int cntType; public int cntType;
@@ -34,12 +36,14 @@ public class PushMessage {
public String language; public String language;
public long messageId; public long messageId;
public PushMessage(String sender, int conversationType, String target, int line, int messageContentType, long serverTime, String senderName, String targetName, int unReceivedMsg, int mentionedType, boolean isHiddenDetail, String language) { public PushMessage(String sender, int conversationType, String target, int line, int messageContentType, long serverTime, String senderName, String senderPortrait, String targetName, String targetPortrait, int unReceivedMsg, int mentionedType, boolean isHiddenDetail, String language) {
this.sender = sender; this.sender = sender;
this.convType = conversationType; this.convType = conversationType;
this.target = target; this.target = target;
this.senderName = senderName; this.senderName = senderName;
this.senderPortrait = senderPortrait;
this.targetName = targetName; this.targetName = targetName;
this.targetPortrait = targetPortrait;
this.line = line; this.line = line;
this.cntType = messageContentType; this.cntType = messageContentType;
this.serverTime = serverTime; this.serverTime = serverTime;
@@ -25,6 +25,9 @@ import io.netty.util.internal.StringUtil;
import cn.wildfirechat.common.ErrorCode; import cn.wildfirechat.common.ErrorCode;
import win.liyufan.im.IMTopic; import win.liyufan.im.IMTopic;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
@Route(APIPath.Msg_Recall) @Route(APIPath.Msg_Recall)
@HttpMethod("POST") @HttpMethod("POST")
public class RecallMessageAction extends AdminAction { public class RecallMessageAction extends AdminAction {
@@ -42,10 +45,9 @@ public class RecallMessageAction extends AdminAction {
WFCMessage.INT64Buf idBuf = WFCMessage.INT64Buf.newBuilder().setId(recallMessageData.getMessageUid()).build(); WFCMessage.INT64Buf idBuf = WFCMessage.INT64Buf.newBuilder().setId(recallMessageData.getMessageUid()).build();
sendApiMessage(response, recallMessageData.getOperator(), IMTopic.RecallMessageTopic, idBuf.toByteArray(), result -> { sendApiMessage(response, recallMessageData.getOperator(), IMTopic.RecallMessageTopic, idBuf.toByteArray(), result -> {
ByteBuf byteBuf = Unpooled.buffer(); ErrorCode errorCode = ErrorCode.fromCode(result[0]);
byteBuf.writeBytes(result); byte[] data = Arrays.copyOfRange(result,1, result.length);
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte()); return new Result(errorCode, new String(data, StandardCharsets.UTF_8));
return new Result(errorCode);
}); });
return false; return false;
} else { } else {
@@ -23,7 +23,7 @@ public class RecallMessageHandler extends IMHandler<WFCMessage.INT64Buf> {
@Override @Override
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, ProtoConstants.RequestSourceType requestSourceType, WFCMessage.INT64Buf int64Buf, Qos1PublishHandler.IMCallback callback) { public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, ProtoConstants.RequestSourceType requestSourceType, WFCMessage.INT64Buf int64Buf, Qos1PublishHandler.IMCallback callback) {
boolean isAdmin = requestSourceType == ProtoConstants.RequestSourceType.Request_From_Admin; boolean isAdmin = requestSourceType == ProtoConstants.RequestSourceType.Request_From_Admin;
ErrorCode errorCode = m_messagesStore.recallMessage(int64Buf.getId(), fromUser, clientID, isAdmin); ErrorCode errorCode = m_messagesStore.recallMessage(int64Buf.getId(), fromUser, clientID, isAdmin, ackPayload);
if(errorCode != ErrorCode.ERROR_CODE_SUCCESS) { if(errorCode != ErrorCode.ERROR_CODE_SUCCESS) {
return errorCode; return errorCode;
@@ -163,11 +163,8 @@ public class DatabaseStore {
return null; return null;
} }
List<WFCMessage.User> searchUserByNameMobile(String keyword, int searchType, int page) { List<WFCMessage.User> searchUserByNameMobile(String keyword, int searchType) {
ArrayList<WFCMessage.User> out = new ArrayList<>(); ArrayList<WFCMessage.User> out = new ArrayList<>();
if(page > 0) {
return out;
}
Connection connection = null; Connection connection = null;
PreparedStatement statement = null; PreparedStatement statement = null;
ResultSet rs = null; ResultSet rs = null;
@@ -315,7 +312,8 @@ public class DatabaseStore {
return out; return out;
} }
List<WFCMessage.User> searchUserByDisplayName(String keyword, int page) {
List<WFCMessage.User> searchUserByDisplayName(String keyword, int page, List<WFCMessage.User> nameOrIdMatched) {
Connection connection = null; Connection connection = null;
PreparedStatement statement = null; PreparedStatement statement = null;
ResultSet rs = null; ResultSet rs = null;
@@ -326,14 +324,36 @@ public class DatabaseStore {
connection = DBUtil.getConnection(); connection = DBUtil.getConnection();
String sql = "select u._uid, u._name, u._display_name, u._portrait, u._mobile, u._gender, u._email, u._address, u._company, u._social, u._extra, u._dt, u._type " + String sql = "select u._uid, u._name, u._display_name, u._portrait, u._mobile, u._gender, u._email, u._address, u._company, u._social, u._extra, u._dt, u._type " +
" from t_user u left join (select _uid, _value from t_user_setting where _scope = 27) s on u._uid = s._uid " + " from t_user u left join (select _uid, _value from t_user_setting where _scope = 27) s on u._uid = s._uid " +
" where u._display_name like ? and u._type <> 2 and u._deleted = 0 and (s._value is null or (s._value <> 1 and s._value <> 3 and s._value <> 5 and s._value <> 7)) limit 20"; " where u._display_name like ? and u._type <> 2 and u._deleted = 0 ";
if(nameOrIdMatched.size() == 1) {
sql += " and u._uid <> ? and u._name <> ?";
} else if(nameOrIdMatched.size() == 2) {
sql += " and u._uid <> ? and u._uid <>? and u._name <> ? and u._name <>? ";
}
sql += " and (s._value is null or (s._value <> 1 and s._value <> 3 and s._value <> 5 and s._value <> 7)) limit ";
if(page == 0) {
sql += (20 - nameOrIdMatched.size());
} else {
sql += 20;
}
if (page > 0) { if (page > 0) {
sql += " offset " + page * 20; sql += " offset " + (page * 20 - nameOrIdMatched.size());
} }
statement = connection.prepareStatement(sql); statement = connection.prepareStatement(sql);
statement.setString(1, "%" + keyword + "%"); statement.setString(1, "%" + keyword + "%");
if(nameOrIdMatched.size() == 1) {
statement.setString(2, nameOrIdMatched.toArray(new WFCMessage.User[0])[0].getUid());
statement.setString(3, nameOrIdMatched.toArray(new WFCMessage.User[0])[0].getUid());
} else if(nameOrIdMatched.size() == 2) {
statement.setString(2, nameOrIdMatched.toArray(new WFCMessage.User[0])[0].getUid());
statement.setString(3, nameOrIdMatched.toArray(new WFCMessage.User[0])[1].getUid());
statement.setString(4, nameOrIdMatched.toArray(new WFCMessage.User[0])[0].getUid());
statement.setString(5, nameOrIdMatched.toArray(new WFCMessage.User[0])[1].getUid());
}
rs = statement.executeQuery(); rs = statement.executeQuery();
while (rs.next()) { while (rs.next()) {
WFCMessage.User.Builder builder = WFCMessage.User.newBuilder(); WFCMessage.User.Builder builder = WFCMessage.User.newBuilder();
@@ -403,9 +423,15 @@ public class DatabaseStore {
} }
List<WFCMessage.User> searchUserFromDB(String keyword, int searchType, int page) { List<WFCMessage.User> searchUserFromDB(String keyword, int searchType, int page) {
List<WFCMessage.User> out = searchUserByNameMobile(keyword, searchType, page); List<WFCMessage.User> nameOrIdMatched = searchUserByNameMobile(keyword, searchType);
List<WFCMessage.User> out = new ArrayList<>();
if(page == 0) {
out.addAll(nameOrIdMatched);
}
if(searchType == SearchUserType_General) { if(searchType == SearchUserType_General) {
List<WFCMessage.User> general = searchUserByDisplayName(keyword, page); List<WFCMessage.User> general = searchUserByDisplayName(keyword, page, nameOrIdMatched);
general.removeAll(nameOrIdMatched);
out.addAll(general); out.addAll(general);
} }
return out; return out;
@@ -35,6 +35,7 @@ import io.moquette.spi.IMessagesStore;
import io.moquette.spi.impl.security.AES; import io.moquette.spi.impl.security.AES;
import io.moquette.spi.security.Tokenor; import io.moquette.spi.security.Tokenor;
import io.moquette.spi.impl.subscriptions.Topic; import io.moquette.spi.impl.subscriptions.Topic;
import io.netty.buffer.ByteBuf;
import io.netty.handler.codec.mqtt.MqttVersion; import io.netty.handler.codec.mqtt.MqttVersion;
import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.codec.digest.DigestUtils;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
@@ -44,6 +45,7 @@ import win.liyufan.im.*;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@@ -810,7 +812,7 @@ public class MemoryMessagesStore implements IMessagesStore {
} }
if (bundle.getMessage().getContent().getExpireDuration() > 0) { if (bundle.getMessage().getContent().getExpireDuration() > 0) {
if (System.currentTimeMillis() > bundle.getMessage().getServerTimestamp() + bundle.getMessage().getContent().getExpireDuration()*1000) { if (System.currentTimeMillis() > bundle.getMessage().getServerTimestamp() + bundle.getMessage().getContent().getExpireDuration()* 1000L) {
continue; continue;
} }
} }
@@ -2177,7 +2179,7 @@ public class MemoryMessagesStore implements IMessagesStore {
} }
@Override @Override
public ErrorCode recallMessage(long messageUid, String operatorId, String clientId, boolean isAdmin) { public ErrorCode recallMessage(long messageUid, String operatorId, String clientId, boolean isAdmin, ByteBuf ackPayload) {
HazelcastInstance hzInstance = m_Server.getHazelcastInstance(); HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
IMap<Long, MessageBundle> mIMap = hzInstance.getMap(MESSAGES_MAP); IMap<Long, MessageBundle> mIMap = hzInstance.getMap(MESSAGES_MAP);
@@ -2303,6 +2305,7 @@ public class MemoryMessagesStore implements IMessagesStore {
databaseStore.deleteMessage(messageUid); databaseStore.deleteMessage(messageUid);
mIMap.put(messageUid, messageBundle, 7, TimeUnit.DAYS); mIMap.put(messageUid, messageBundle, 7, TimeUnit.DAYS);
ackPayload.writeBytes(recalledContent.getBytes(StandardCharsets.UTF_8));
return ErrorCode.ERROR_CODE_SUCCESS; return ErrorCode.ERROR_CODE_SUCCESS;
} else { } else {
return ErrorCode.ERROR_CODE_NOT_EXIST; return ErrorCode.ERROR_CODE_NOT_EXIST;
@@ -128,7 +128,7 @@ public interface IMessagesStore {
ErrorCode canSendMessageInGroup(String member, String groupId); ErrorCode canSendMessageInGroup(String member, String groupId);
Set<String> getGroupManagers(String groupId, boolean includeOwner); Set<String> getGroupManagers(String groupId, boolean includeOwner);
ErrorCode recallMessage(long messageUid, String operatorId, String clientId, boolean isAdmin); ErrorCode recallMessage(long messageUid, String operatorId, String clientId, boolean isAdmin, ByteBuf ackPayload);
ErrorCode recallCastMessage(long messageUid, String operatorId); ErrorCode recallCastMessage(long messageUid, String operatorId);
void clearUserMessages(String userId); void clearUserMessages(String userId);
@@ -35,14 +35,11 @@ import io.moquette.spi.ISessionsStore;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import io.netty.handler.codec.mqtt.*; import io.netty.handler.codec.mqtt.*;
import win.liyufan.im.GsonUtil; import win.liyufan.im.*;
import win.liyufan.im.HttpUtils;
import win.liyufan.im.IMTopic;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import win.liyufan.im.Utility;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@@ -168,6 +165,9 @@ public class MessagesPublisher {
} }
WFCMessage.Message message = null; WFCMessage.Message message = null;
String senderName = null;
String senderPortrait = null;
boolean sendNameLoaded = false;
for (String user : receivers) { for (String user : receivers) {
if (!user.equals(sender)) { if (!user.equals(sender)) {
WFCMessage.User userInfo = m_messagesStore.getUserInfo(user); WFCMessage.User userInfo = m_messagesStore.getUserInfo(user);
@@ -207,10 +207,10 @@ public class MessagesPublisher {
} }
Collection<Session> sessions = m_sessionsStore.sessionForUser(user); Collection<Session> sessions = m_sessionsStore.sessionForUser(user);
String senderName = null;
String targetName = null;
boolean nameLoaded = false;
String targetName = null;
String targetPortrait = null;
boolean targetNameLoaded = false;
Collection<String> targetClients = null; Collection<String> targetClients = null;
if (pullType == ProtoConstants.PullType.Pull_ChatRoom) { if (pullType == ProtoConstants.PullType.Pull_ChatRoom) {
@@ -386,10 +386,22 @@ public class MessagesPublisher {
boolean isHiddenDetail = m_messagesStore.getUserPushHiddenDetail(user); boolean isHiddenDetail = m_messagesStore.getUserPushHiddenDetail(user);
if(!nameLoaded) { if(!sendNameLoaded) {
senderName = getUserDisplayName(sender, conversationType == ProtoConstants.ConversationType.ConversationType_Group ? target : null); List<String> list = new ArrayList<>();
targetName = getTargetName(target, conversationType); senderName = getUserDisplayName(sender, conversationType == ProtoConstants.ConversationType.ConversationType_Group ? target : null, list);
nameLoaded = true; if(!list.isEmpty()) {
senderPortrait = list.get(0);
}
sendNameLoaded = true;
}
if(!targetNameLoaded) {
List<String> list = new ArrayList<>();
targetName = getTargetName(target, conversationType, user, list);
if(!list.isEmpty()) {
targetPortrait = list.get(0);
}
targetNameLoaded = true;
} }
String name = senderName; String name = senderName;
@@ -399,7 +411,7 @@ public class MessagesPublisher {
name = fd.getAlias(); name = fd.getAlias();
} }
} }
this.messageSender.sendPush(sender, conversationType, target, line, messageId, targetSession.getClientID(), pushContent, pushData, messageContentType, serverTime, name, targetName, targetSession.getUnReceivedMsgs(), curMentionType, isHiddenDetail, targetSession.getLanguage()); this.messageSender.sendPush(sender, conversationType, target, line, messageId, targetSession.getClientID(), pushContent, pushData, messageContentType, serverTime, name, senderPortrait, targetName, targetPortrait, targetSession.getUnReceivedMsgs(), curMentionType, isHiddenDetail, targetSession.getLanguage());
} }
} }
@@ -461,10 +473,13 @@ public class MessagesPublisher {
} }
} }
String getUserDisplayName(String userId, String groupId) { String getUserDisplayName(String userId, String groupId, List<String> portraitList) {
WFCMessage.User user = m_messagesStore.getUserInfo(userId); WFCMessage.User user = m_messagesStore.getUserInfo(userId);
String userName = null; String userName = null;
if(user != null) { if(user != null) {
if(portraitList != null && !StringUtil.isNullOrEmpty(user.getPortrait())) {
portraitList.add(user.getPortrait());
}
userName = user.getDisplayName(); userName = user.getDisplayName();
} }
if (!StringUtil.isNullOrEmpty(groupId)) { if (!StringUtil.isNullOrEmpty(groupId)) {
@@ -476,17 +491,28 @@ public class MessagesPublisher {
return userName; return userName;
} }
String getTargetName(String targetId, int cnvType) { String getTargetName(String targetId, int cnvType, String fromUser, List<String> portraitList) {
if (cnvType == ProtoConstants.ConversationType.ConversationType_Private) { if (cnvType == ProtoConstants.ConversationType.ConversationType_Private) {
return getUserDisplayName(targetId, null); return getUserDisplayName(targetId, null, portraitList);
} else if(cnvType == ProtoConstants.ConversationType.ConversationType_Group) { } else if(cnvType == ProtoConstants.ConversationType.ConversationType_Group) {
WFCMessage.GroupInfo group = m_messagesStore.getGroupInfo(targetId); WFCMessage.GroupInfo group = m_messagesStore.getGroupInfo(targetId);
if(group != null) { if(group != null) {
if(!StringUtil.isNullOrEmpty(group.getPortrait())) {
portraitList.add(group.getPortrait());
}
WFCMessage.UserSettingEntry entry = m_messagesStore.getUserSetting(fromUser, UserSettingScope.kUserSettingGroupRemark, targetId);
if(entry != null && !StringUtil.isNullOrEmpty(entry.getValue())) {
return entry.getValue();
}
return group.getName(); return group.getName();
} }
} else if(cnvType == ProtoConstants.ConversationType.ConversationType_Channel) { } else if(cnvType == ProtoConstants.ConversationType.ConversationType_Channel) {
WFCMessage.ChannelInfo channelInfo = m_messagesStore.getChannelInfo(targetId); WFCMessage.ChannelInfo channelInfo = m_messagesStore.getChannelInfo(targetId);
if (channelInfo != null) { if (channelInfo != null) {
if(!StringUtil.isNullOrEmpty(channelInfo.getPortrait())) {
portraitList.add(channelInfo.getPortrait());
}
return channelInfo.getName(); return channelInfo.getName();
} }
} }
@@ -37,9 +37,9 @@ class PersistentQueueMessageSender {
this.connectionDescriptorStore = connectionDescriptorStore; this.connectionDescriptorStore = connectionDescriptorStore;
} }
void sendPush(String sender, int conversationType, String target, int line, long messageId, String deviceId, String pushContent, String pushData, int messageContentType, long serverTime, String senderName, String targetName, int unReceivedMsg, int mentionType, boolean isHiddenDetail, String language) { void sendPush(String sender, int conversationType, String target, int line, long messageId, String deviceId, String pushContent, String pushData, int messageContentType, long serverTime, String senderName, String senderPortrait, String targetName, String targetPortrait, int unReceivedMsg, int mentionType, boolean isHiddenDetail, String language) {
LOG.info("Send push to {}, message from {}", deviceId, sender); LOG.info("Send push to {}, message from {}", deviceId, sender);
PushMessage pushMessage = new PushMessage(sender, conversationType, target, line, messageContentType, serverTime, senderName, targetName, unReceivedMsg, mentionType, isHiddenDetail, language); PushMessage pushMessage = new PushMessage(sender, conversationType, target, line, messageContentType, serverTime, senderName, senderPortrait, targetName, targetPortrait, unReceivedMsg, mentionType, isHiddenDetail, language);
pushMessage.pushContent = pushContent; pushMessage.pushContent = pushContent;
pushMessage.pushData = pushData; pushMessage.pushData = pushData;
pushMessage.messageId = messageId; pushMessage.messageId = messageId;
+1 -1
View File
@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>wildfirechat-parent</artifactId> <artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId> <groupId>cn.wildfirechat</groupId>
<version>1.1.6</version> <version>1.1.7</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
@@ -156,6 +156,8 @@ public class ProtoConstants {
int Modify_Group_History_Message = 7; int Modify_Group_History_Message = 7;
//仅专业版的server api支持 //仅专业版的server api支持
int Modify_Group_Max_Member_Count = 8; int Modify_Group_Max_Member_Count = 8;
//仅专业版的server api支持
int Modify_Group_Super_Group = 9;
} }
//ModifyGroupInfoRequest -> type //ModifyGroupInfoRequest -> type
+1 -1
View File
@@ -6,7 +6,7 @@
<!--<relativePath>../pom.xml</relativePath>--> <!--<relativePath>../pom.xml</relativePath>-->
<artifactId>wildfirechat-parent</artifactId> <artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId> <groupId>cn.wildfirechat</groupId>
<version>1.1.6</version> <version>1.1.7</version>
</parent> </parent>
<artifactId>distribution</artifactId> <artifactId>distribution</artifactId>
+1 -1
View File
@@ -12,7 +12,7 @@
<artifactId>wildfirechat-parent</artifactId> <artifactId>wildfirechat-parent</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>1.1.6</version> <version>1.1.7</version>
<name>Wildfire Chat</name> <name>Wildfire Chat</name>
<description>Wildfire Chat Server</description> <description>Wildfire Chat Server</description>
<inceptionYear>2019</inceptionYear> <inceptionYear>2019</inceptionYear>
+7
View File
@@ -12,6 +12,13 @@
# 更新记录 # 更新记录
--------------
Release note 1.1.7:
1. 优化用户搜索功能。
2. 推送消息中使用群备注。
3. 推送消息中添加发送者和目标头像。
4. 优化撤回消息流程。
-------------- --------------
Release note 1.1.6: Release note 1.1.6:
1. 支持用户设置查找自己的方法。 1. 支持用户设置查找自己的方法。
+1 -1
View File
@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>wildfirechat-parent</artifactId> <artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId> <groupId>cn.wildfirechat</groupId>
<version>1.1.6</version> <version>1.1.7</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
@@ -747,8 +747,8 @@ public class Main {
System.exit(-1); System.exit(-1);
} }
IMResult<Void> voidIMResult = MessageAdmin.recallMessage("user1", resultSendMessage.getResult().getMessageUid()); IMResult<String> stringIMResult = MessageAdmin.recallMessage("user1", resultSendMessage.getResult().getMessageUid());
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) { if (stringIMResult != null && stringIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
System.out.println("recall message success"); System.out.println("recall message success");
} else { } else {
System.out.println("recall message failure"); System.out.println("recall message failure");
@@ -756,7 +756,7 @@ public class Main {
} }
if (commercialServer) { if (commercialServer) {
voidIMResult = MessageAdmin.deleteMessage(resultSendMessage.getResult().getMessageUid()); IMResult<Void> voidIMResult = MessageAdmin.deleteMessage(resultSendMessage.getResult().getMessageUid());
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) { if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
System.out.println("delete message success"); System.out.println("delete message success");
} else { } else {
@@ -832,7 +832,7 @@ public class Main {
System.exit(-1); System.exit(-1);
} }
voidIMResult = MessageAdmin.recallMultiCastMessage("user1", resultMulticastMessage.result.getMessageUid(), multicastReceivers); IMResult<Void> voidIMResult = MessageAdmin.recallMultiCastMessage("user1", resultMulticastMessage.result.getMessageUid(), multicastReceivers);
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) { if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
System.out.println("Success"); System.out.println("Success");
} else { } else {
@@ -25,12 +25,12 @@ public class MessageAdmin {
return AdminHttpUtils.httpJsonPost(path, messageData, SendMessageResult.class); return AdminHttpUtils.httpJsonPost(path, messageData, SendMessageResult.class);
} }
public static IMResult<Void> recallMessage(String operator, long messageUid) throws Exception { public static IMResult<String> recallMessage(String operator, long messageUid) throws Exception {
String path = APIPath.Msg_Recall; String path = APIPath.Msg_Recall;
RecallMessageData messageData = new RecallMessageData(); RecallMessageData messageData = new RecallMessageData();
messageData.setOperator(operator); messageData.setOperator(operator);
messageData.setMessageUid(messageUid); messageData.setMessageUid(messageUid);
return AdminHttpUtils.httpJsonPost(path, messageData, Void.class); return AdminHttpUtils.httpJsonPost(path, messageData, String.class);
} }
//仅专业版支持 //仅专业版支持