Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3bb23f92c4 | ||
|
|
804c12845e | ||
|
|
fe15a32499 | ||
|
|
06d168935d | ||
|
|
c1984d27b3 | ||
|
|
29ef46b7a0 | ||
|
|
0bdff3fd89 | ||
|
|
cd03583dab | ||
|
|
3f8fd7e5e0 | ||
|
|
fdfe71f700 | ||
|
|
35ecf7ccc6 | ||
|
|
8f798742c3 | ||
|
|
f4ea8b184c | ||
|
|
2d7f344b1a | ||
|
|
bee03cd2f8 | ||
|
|
59b1c3180f |
@@ -170,6 +170,10 @@ robot.callback_with_sender_info false
|
|||||||
## 机器人回调信息是否带上目标的信息,单聊时是对方用户信息,群聊时是群组信息,频道时是频道信息
|
## 机器人回调信息是否带上目标的信息,单聊时是对方用户信息,群聊时是群组信息,频道时是频道信息
|
||||||
robot.callback_with_target_info false
|
robot.callback_with_target_info false
|
||||||
|
|
||||||
|
## 是否允许@会话外的机器人。如果为true,单聊或者群聊时,可以@不在会话中的机器人。当机器人收到消息后,可以回复消息。
|
||||||
|
## 如果为false,不能@不在会话中的机器人。机器人不在会话中时,也不能回复消息。
|
||||||
|
robot.mention_external_robot true
|
||||||
|
|
||||||
## 频道回调信息是否带上用户clientId和平台类型。
|
## 频道回调信息是否带上用户clientId和平台类型。
|
||||||
channel.callback_with_client_info false
|
channel.callback_with_client_info false
|
||||||
|
|
||||||
@@ -448,6 +452,10 @@ push.harmony.server.address http://localhost:8085/harmony/push
|
|||||||
## 如果开启 message.sensitive.forward.url 配置,命中敏感词的消息还会被回调到这个地址
|
## 如果开启 message.sensitive.forward.url 配置,命中敏感词的消息还会被回调到这个地址
|
||||||
sensitive.filter.type 2
|
sensitive.filter.type 2
|
||||||
|
|
||||||
|
## 敏感词是否只处理消息。如果为true,只过滤消息;如果为false,会同时过滤用户昵称、群组名和群昵称。
|
||||||
|
## 除了消息之外的信息只支持内部敏感词处理,不支持外置审核。
|
||||||
|
sensitive.only_message false
|
||||||
|
|
||||||
## 敏感词添加或者删除有2种方式,一种是通过Server API进行,这种方式会立即生效。另外一种方法是修改数据库,直接中数据库的t_sensitive_word表中处理
|
## 敏感词添加或者删除有2种方式,一种是通过Server API进行,这种方式会立即生效。另外一种方法是修改数据库,直接中数据库的t_sensitive_word表中处理
|
||||||
## 修改数据库的方法不会立即生效,IM服务会2个小时重新加载一次敏感词。所以如果直接修改敏感词表,需要等2个小时,或者重启才能生效。
|
## 修改数据库的方法不会立即生效,IM服务会2个小时重新加载一次敏感词。所以如果直接修改敏感词表,需要等2个小时,或者重启才能生效。
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
CREATE INDEX `user_gid_mid_dt_index` ON `t_group_member` (`_gid`, `_mid`, `_dt`);
|
CREATE INDEX `user_gid_dt_index` ON `t_group_member` (`_gid`, `_dt`);
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
insert into t_settings(`id`, `_value`,`_desc`) values (2, '文件传输助手,客服,官方', '禁止使用名称,如果有多个,以英文逗号隔开。直接修改数据库,不用重启IM服务');
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
alter table `t_messages` modify column `_target` varchar(129) NOT NULL;
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
DROP INDEX `user_gid_mid_dt_index` ON `t_group_member`;
|
||||||
|
CREATE INDEX `user_gid_dt_index` ON `t_group_member` (`_gid`, `_dt`);
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
insert into t_settings(`id`, `_value`,`_desc`) values (2, '文件传输助手,客服,官方', '禁止使用名称,如果有多个,以英文逗号隔开。直接修改数据库,不用重启IM服务');
|
||||||
+37
@@ -0,0 +1,37 @@
|
|||||||
|
alter table `t_messages` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_0` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_1` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_2` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_3` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_4` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_5` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_6` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_7` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_8` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_9` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_10` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_11` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_12` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_13` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_14` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_15` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_16` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_17` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_18` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_19` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_20` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_21` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_22` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_23` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_24` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_25` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_26` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_27` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_28` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_29` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_30` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_31` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_32` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_33` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_34` modify column `_target` varchar(129) NOT NULL;
|
||||||
|
alter table `t_messages_35` modify column `_target` varchar(129) NOT NULL;
|
||||||
+1
-1
@@ -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.3.7</version>
|
<version>1.3.9</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>moquette-broker</artifactId>
|
<artifactId>moquette-broker</artifactId>
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public class SendMessageAction extends AdminAction {
|
|||||||
} else {
|
} else {
|
||||||
return new Result(errorCode);
|
return new Result(errorCode);
|
||||||
}
|
}
|
||||||
});
|
}, sendMessageData.isUserMessage());
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||||
|
|||||||
+112
@@ -0,0 +1,112 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the Wildfire Chat package.
|
||||||
|
* (c) Heavyrain2012 <[email protected]>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.xiaoleilu.loServer.action.robot;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.wildfirechat.common.APIPath;
|
||||||
|
import cn.wildfirechat.common.ErrorCode;
|
||||||
|
import cn.wildfirechat.pojos.Conversation;
|
||||||
|
import cn.wildfirechat.pojos.ReplyMessageData;
|
||||||
|
import cn.wildfirechat.pojos.SendMessageData;
|
||||||
|
import cn.wildfirechat.pojos.SendMessageResult;
|
||||||
|
import cn.wildfirechat.proto.ProtoConstants;
|
||||||
|
import cn.wildfirechat.proto.WFCMessage;
|
||||||
|
import com.xiaoleilu.loServer.RestResult;
|
||||||
|
import com.xiaoleilu.loServer.annotation.HttpMethod;
|
||||||
|
import com.xiaoleilu.loServer.annotation.Route;
|
||||||
|
import com.xiaoleilu.loServer.handler.Request;
|
||||||
|
import com.xiaoleilu.loServer.handler.Response;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.buffer.Unpooled;
|
||||||
|
import io.netty.handler.codec.http.FullHttpRequest;
|
||||||
|
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import win.liyufan.im.IMTopic;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
@Route(APIPath.Robot_Message_Reply)
|
||||||
|
@HttpMethod("POST")
|
||||||
|
public class ReplyMessageAction extends RobotAction {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isTransactionAction() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean action(Request request, Response response) {
|
||||||
|
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||||
|
ReplyMessageData replyMessageData = getRequestBody(request.getNettyRequest(), ReplyMessageData.class);
|
||||||
|
if (ReplyMessageData.isValide(replyMessageData)) {
|
||||||
|
WFCMessage.Message message = messagesStore.getMessage(replyMessageData.getMessageUid());
|
||||||
|
ErrorCode errorCode = null;
|
||||||
|
if(message == null) {
|
||||||
|
errorCode = ErrorCode.ERROR_CODE_NOT_EXIST;
|
||||||
|
} else if(!message.getContent().getMentionedTargetList().contains(robot.getUid())) {
|
||||||
|
errorCode = ErrorCode.ERROR_CODE_INVALID_MESSAGE;
|
||||||
|
} else if(message.getConversation().getType() != ProtoConstants.ConversationType.ConversationType_Private && message.getConversation().getType() != ProtoConstants.ConversationType.ConversationType_Group) {
|
||||||
|
errorCode = ErrorCode.ERROR_CODE_NOT_IMPLEMENT;
|
||||||
|
} else if(System.currentTimeMillis() - message.getServerTimestamp() > 15*60*1000) {
|
||||||
|
errorCode = ErrorCode.ERROR_CODE_RECALL_TIME_EXPIRED;
|
||||||
|
} else if(!messagesStore.isRobotMentionExternalRobot()) {
|
||||||
|
if(message.getConversation().getType() != ProtoConstants.ConversationType.ConversationType_Group) {
|
||||||
|
errorCode = ErrorCode.ERROR_CODE_NOT_IMPLEMENT;
|
||||||
|
} else {
|
||||||
|
WFCMessage.GroupMember member = messagesStore.getGroupMember(message.getConversation().getTarget(), robot.getUid());
|
||||||
|
if(member == null || member.getType() == ProtoConstants.GroupMemberType.GroupMemberType_Removed) {
|
||||||
|
errorCode = ErrorCode.ERROR_CODE_NOT_IMPLEMENT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(errorCode != null) {
|
||||||
|
response.setStatus(HttpResponseStatus.OK);
|
||||||
|
RestResult result = RestResult.resultOf(errorCode);
|
||||||
|
response.setContent(gson.toJson(result));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
SendMessageData sendMessageData = getSendMessageData(message, replyMessageData);
|
||||||
|
WFCMessage.Message newMsg = sendMessageData.toProtoMessage().toBuilder().setMessageId(message.getMessageId()).build();
|
||||||
|
sendApiRequest(response, IMTopic.RobotReplyMessageTopic, newMsg.toByteArray(), result -> {
|
||||||
|
ByteBuf byteBuf = Unpooled.buffer();
|
||||||
|
byteBuf.writeBytes(result);
|
||||||
|
ErrorCode ec = ErrorCode.fromCode(byteBuf.readByte());
|
||||||
|
if (ec == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
|
long messageId = byteBuf.readLong();
|
||||||
|
long timestamp = byteBuf.readLong();
|
||||||
|
sendResponse(response, null, new SendMessageResult(messageId, timestamp));
|
||||||
|
} else {
|
||||||
|
sendResponse(response, ec, null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private @NotNull SendMessageData getSendMessageData(WFCMessage.Message message, ReplyMessageData replyMessageData) {
|
||||||
|
SendMessageData sendMessageData = new SendMessageData();
|
||||||
|
sendMessageData.setSender(robot.getUid());
|
||||||
|
Conversation conversation = new Conversation();
|
||||||
|
conversation.setType(message.getConversation().getType());
|
||||||
|
conversation.setLine(message.getConversation().getLine());
|
||||||
|
conversation.setTarget(message.getConversation().getTarget());
|
||||||
|
sendMessageData.setConv(conversation);
|
||||||
|
sendMessageData.setPayload(replyMessageData.getPayload());
|
||||||
|
if(replyMessageData.isOnly2Sender()) {
|
||||||
|
sendMessageData.setToUsers(Arrays.asList(message.getFromUser()));
|
||||||
|
}
|
||||||
|
return sendMessageData;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -124,7 +124,7 @@ public final class BrokerConstants {
|
|||||||
|
|
||||||
|
|
||||||
public static final String SENSITIVE_Filter_Type = "sensitive.filter.type";
|
public static final String SENSITIVE_Filter_Type = "sensitive.filter.type";
|
||||||
|
public static final String SENSITIVE_Only_Message = "sensitive.only_message";
|
||||||
public static final String SENSITIVE_Remote_Server_URL = "sensitive.remote_server_url";
|
public static final String SENSITIVE_Remote_Server_URL = "sensitive.remote_server_url";
|
||||||
public static final String SENSITIVE_Remote_Message_Type = "sensitive.remote_sensitive_message_type";
|
public static final String SENSITIVE_Remote_Message_Type = "sensitive.remote_sensitive_message_type";
|
||||||
public static final String SENSITIVE_Remote_Fail_When_Matched = "sensitive.remote_fail_when_matched";
|
public static final String SENSITIVE_Remote_Fail_When_Matched = "sensitive.remote_fail_when_matched";
|
||||||
@@ -173,6 +173,8 @@ public final class BrokerConstants {
|
|||||||
public static final String ROBOT_Callback_With_Client_Info = "robot.callback_with_client_info";
|
public static final String ROBOT_Callback_With_Client_Info = "robot.callback_with_client_info";
|
||||||
public static final String ROBOT_Callback_With_Sender_Info = "robot.callback_with_sender_info";
|
public static final String ROBOT_Callback_With_Sender_Info = "robot.callback_with_sender_info";
|
||||||
public static final String ROBOT_Callback_With_Target_Info = "robot.callback_with_target_info";
|
public static final String ROBOT_Callback_With_Target_Info = "robot.callback_with_target_info";
|
||||||
|
public static final String ROBOT_Mention_External_Robot = "robot.mention_external_robot";
|
||||||
|
|
||||||
|
|
||||||
public static final String CHANNEL_Callback_With_Client_Info = "channel.callback_with_client_info";
|
public static final String CHANNEL_Callback_With_Client_Info = "channel.callback_with_client_info";
|
||||||
public static final String CHANNEL_Callback_With_Sender_Info = "channel.callback_with_sender_info";
|
public static final String CHANNEL_Callback_With_Sender_Info = "channel.callback_with_sender_info";
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import win.liyufan.im.IMTopic;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
@Handler(value = IMTopic.CreateGroupTopic)
|
@Handler(value = IMTopic.CreateGroupTopic)
|
||||||
public class CreateGroupHandler extends GroupHandler<WFCMessage.CreateGroupRequest> {
|
public class CreateGroupHandler extends GroupHandler<WFCMessage.CreateGroupRequest> {
|
||||||
@@ -68,6 +69,19 @@ public class CreateGroupHandler extends GroupHandler<WFCMessage.CreateGroupReque
|
|||||||
return ErrorCode.INVALID_PARAMETER;
|
return ErrorCode.INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!isAdmin && !StringUtil.isNullOrEmpty(request.getGroup().getGroupInfo().getName())) {
|
||||||
|
if(!m_messagesStore.isSensitiveOnlyMessage()) {
|
||||||
|
Set<String> matched = m_messagesStore.handleSensitiveWord(request.getGroup().getGroupInfo().getName());
|
||||||
|
if (matched != null && !matched.isEmpty()) {
|
||||||
|
return ErrorCode.ERROR_CODE_SENSITIVE_MATCHED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!m_messagesStore.isAllowName(request.getGroup().getGroupInfo().getName())) {
|
||||||
|
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
WFCMessage.GroupInfo groupInfo = m_messagesStore.createGroup(fromUser, request.getGroup().getGroupInfo(), request.getGroup().getMembersList(), request.getMemberExtra(), isAdmin, failedMembers);
|
WFCMessage.GroupInfo groupInfo = m_messagesStore.createGroup(fromUser, request.getGroup().getGroupInfo(), request.getGroup().getMembersList(), request.getMemberExtra(), isAdmin, failedMembers);
|
||||||
if (groupInfo != null && groupInfo.getDeleted() == 0) {
|
if (groupInfo != null && groupInfo.getDeleted() == 0) {
|
||||||
if(request.hasNotifyContent() && request.getNotifyContent().getType() > 0) {
|
if(request.hasNotifyContent() && request.getNotifyContent().getType() > 0) {
|
||||||
|
|||||||
@@ -11,11 +11,14 @@ package io.moquette.imhandler;
|
|||||||
import cn.wildfirechat.proto.ProtoConstants;
|
import cn.wildfirechat.proto.ProtoConstants;
|
||||||
import cn.wildfirechat.proto.WFCMessage;
|
import cn.wildfirechat.proto.WFCMessage;
|
||||||
import cn.wildfirechat.pojos.GroupNotificationBinaryContent;
|
import cn.wildfirechat.pojos.GroupNotificationBinaryContent;
|
||||||
|
import com.hazelcast.util.StringUtil;
|
||||||
import io.moquette.spi.impl.Qos1PublishHandler;
|
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import cn.wildfirechat.common.ErrorCode;
|
import cn.wildfirechat.common.ErrorCode;
|
||||||
import win.liyufan.im.IMTopic;
|
import win.liyufan.im.IMTopic;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_SUCCESS;
|
import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_SUCCESS;
|
||||||
|
|
||||||
@Handler(IMTopic.ModifyGroupAliasTopic)
|
@Handler(IMTopic.ModifyGroupAliasTopic)
|
||||||
@@ -26,10 +29,24 @@ public class ModifyGroupAliasHandler extends GroupHandler<WFCMessage.ModifyGroup
|
|||||||
if(request.hasNotifyContent() && request.getNotifyContent().getType() > 0 && requestSourceType == ProtoConstants.RequestSourceType.Request_From_User && !m_messagesStore.isAllowClientCustomGroupNotification()) {
|
if(request.hasNotifyContent() && request.getNotifyContent().getType() > 0 && requestSourceType == ProtoConstants.RequestSourceType.Request_From_User && !m_messagesStore.isAllowClientCustomGroupNotification()) {
|
||||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(request.hasNotifyContent() && request.getNotifyContent().getType() > 0 && requestSourceType == ProtoConstants.RequestSourceType.Request_From_Robot && !m_messagesStore.isAllowRobotCustomGroupNotification()) {
|
if(request.hasNotifyContent() && request.getNotifyContent().getType() > 0 && requestSourceType == ProtoConstants.RequestSourceType.Request_From_Robot && !m_messagesStore.isAllowRobotCustomGroupNotification()) {
|
||||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isAdmin && !StringUtil.isNullOrEmpty(request.getAlias())) {
|
||||||
|
if(!m_messagesStore.isSensitiveOnlyMessage()) {
|
||||||
|
Set<String> matched = m_messagesStore.handleSensitiveWord(request.getAlias());
|
||||||
|
if (matched != null && !matched.isEmpty()) {
|
||||||
|
return ErrorCode.ERROR_CODE_SENSITIVE_MATCHED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!m_messagesStore.isAllowName(request.getAlias())) {
|
||||||
|
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ErrorCode errorCode = m_messagesStore.modifyGroupMemberAlias(fromUser, request.getGroupId(), request.getAlias(), null, isAdmin);
|
ErrorCode errorCode = m_messagesStore.modifyGroupMemberAlias(fromUser, request.getGroupId(), request.getAlias(), null, isAdmin);
|
||||||
if (errorCode == ERROR_CODE_SUCCESS) {
|
if (errorCode == ERROR_CODE_SUCCESS) {
|
||||||
if (request.hasNotifyContent()&& request.getNotifyContent().getType() > 0) {
|
if (request.hasNotifyContent()&& request.getNotifyContent().getType() > 0) {
|
||||||
|
|||||||
@@ -12,10 +12,13 @@ import cn.wildfirechat.common.ErrorCode;
|
|||||||
import cn.wildfirechat.pojos.GroupNotificationBinaryContent;
|
import cn.wildfirechat.pojos.GroupNotificationBinaryContent;
|
||||||
import cn.wildfirechat.proto.ProtoConstants;
|
import cn.wildfirechat.proto.ProtoConstants;
|
||||||
import cn.wildfirechat.proto.WFCMessage;
|
import cn.wildfirechat.proto.WFCMessage;
|
||||||
|
import com.hazelcast.util.StringUtil;
|
||||||
import io.moquette.spi.impl.Qos1PublishHandler;
|
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import win.liyufan.im.IMTopic;
|
import win.liyufan.im.IMTopic;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_SUCCESS;
|
import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_SUCCESS;
|
||||||
|
|
||||||
@Handler(IMTopic.ModifyGroupMemberAliasTopic)
|
@Handler(IMTopic.ModifyGroupMemberAliasTopic)
|
||||||
@@ -29,6 +32,18 @@ public class ModifyGroupMemberAliasHandler extends GroupHandler<WFCMessage.Modif
|
|||||||
if(request.hasNotifyContent() && request.getNotifyContent().getType() > 0 && requestSourceType == ProtoConstants.RequestSourceType.Request_From_Robot && !m_messagesStore.isAllowRobotCustomGroupNotification()) {
|
if(request.hasNotifyContent() && request.getNotifyContent().getType() > 0 && requestSourceType == ProtoConstants.RequestSourceType.Request_From_Robot && !m_messagesStore.isAllowRobotCustomGroupNotification()) {
|
||||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||||
}
|
}
|
||||||
|
if (!isAdmin && !StringUtil.isNullOrEmpty(request.getAlias())) {
|
||||||
|
if(!m_messagesStore.isSensitiveOnlyMessage()) {
|
||||||
|
Set<String> matched = m_messagesStore.handleSensitiveWord(request.getAlias());
|
||||||
|
if (matched != null && !matched.isEmpty()) {
|
||||||
|
return ErrorCode.ERROR_CODE_SENSITIVE_MATCHED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!m_messagesStore.isAllowName(request.getAlias())) {
|
||||||
|
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ErrorCode errorCode = m_messagesStore.modifyGroupMemberAlias(fromUser, request.getGroupId(), request.getAlias(), request.getMemberId(), isAdmin);
|
ErrorCode errorCode = m_messagesStore.modifyGroupMemberAlias(fromUser, request.getGroupId(), request.getAlias(), request.getMemberId(), isAdmin);
|
||||||
if (errorCode == ERROR_CODE_SUCCESS) {
|
if (errorCode == ERROR_CODE_SUCCESS) {
|
||||||
|
|||||||
@@ -0,0 +1,348 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the Wildfire Chat package.
|
||||||
|
* (c) Heavyrain2012 <[email protected]>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.moquette.imhandler;
|
||||||
|
|
||||||
|
import cn.wildfirechat.common.ErrorCode;
|
||||||
|
import cn.wildfirechat.pojos.MessagePayload;
|
||||||
|
import cn.wildfirechat.proto.ProtoConstants;
|
||||||
|
import cn.wildfirechat.proto.WFCMessage;
|
||||||
|
import com.hazelcast.util.StringUtil;
|
||||||
|
import io.moquette.BrokerConstants;
|
||||||
|
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.buffer.Unpooled;
|
||||||
|
import win.liyufan.im.*;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_NOT_IN_GROUP;
|
||||||
|
import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_SUCCESS;
|
||||||
|
|
||||||
|
@Handler(value = IMTopic.RobotReplyMessageTopic)
|
||||||
|
public class ReplyMessageHandler extends IMHandler<WFCMessage.Message> {
|
||||||
|
private int mSensitiveType = 0; //命中敏感词时,0 失败,1 吞掉, 2 敏感词替换成*。
|
||||||
|
private String mForwardUrl = null;
|
||||||
|
private String mSensitiveMessageForwardUrl = null;
|
||||||
|
private Set<Integer> mForwardMessageTypes = new HashSet<>();
|
||||||
|
private Set<Integer> mForwardExcludeMessageTypes = new HashSet<>();
|
||||||
|
private String mMentionForwardUrl = null;
|
||||||
|
private int mBlacklistStrategy = 0; //黑名单中时,0失败,1吞掉。
|
||||||
|
private boolean mBlacklistAllowSend2Black = true;
|
||||||
|
private boolean mNoForwardAdminMessage = false;
|
||||||
|
private boolean mAllowSend2ForbiddenUser = false;
|
||||||
|
|
||||||
|
private String mRemoteSensitiveServerUrl = null;
|
||||||
|
private Set<Integer> mRemoteSensitiveMessageTypes;
|
||||||
|
private boolean mWaitRemoteSensitiveServerResponse = false;
|
||||||
|
|
||||||
|
public ReplyMessageHandler() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
mForwardUrl = mServer.getConfig().getProperty(BrokerConstants.MESSAGE_Forward_Url);
|
||||||
|
if (!StringUtil.isNullOrEmpty(mForwardUrl)) {
|
||||||
|
String forwardTypes = mServer.getConfig().getProperty(BrokerConstants.MESSAGE_Forward_Types);
|
||||||
|
parseTypes(mForwardMessageTypes, forwardTypes);
|
||||||
|
String excludeTypes = mServer.getConfig().getProperty(BrokerConstants.MESSAGE_Forward_Exclude_Types);
|
||||||
|
parseTypes(mForwardExcludeMessageTypes, excludeTypes);
|
||||||
|
}
|
||||||
|
mSensitiveMessageForwardUrl = mServer.getConfig().getProperty(BrokerConstants.MESSAGE_Sensitive_Forward_Url);
|
||||||
|
mMentionForwardUrl = mServer.getConfig().getProperty(BrokerConstants.MESSAGE_MentionMsg_Forward_Url);
|
||||||
|
|
||||||
|
try {
|
||||||
|
mSensitiveType = Integer.parseInt(mServer.getConfig().getProperty(BrokerConstants.SENSITIVE_Filter_Type));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Utility.printExecption(LOG, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
mBlacklistStrategy = Integer.parseInt(mServer.getConfig().getProperty(BrokerConstants.MESSAGE_Blacklist_Strategy));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Utility.printExecption(LOG, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
mBlacklistAllowSend2Black = Boolean.parseBoolean(mServer.getConfig().getProperty(BrokerConstants.MESSAGE_Blacklist_Allow_Send, "true"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
mRemoteSensitiveServerUrl = mServer.getConfig().getProperty(BrokerConstants.SENSITIVE_Remote_Server_URL);
|
||||||
|
if(!StringUtil.isNullOrEmpty(mRemoteSensitiveServerUrl)) {
|
||||||
|
mWaitRemoteSensitiveServerResponse = Boolean.parseBoolean(mServer.getConfig().getProperty(BrokerConstants.SENSITIVE_Remote_Fail_When_Matched, "false"));
|
||||||
|
String types = mServer.getConfig().getProperty(BrokerConstants.SENSITIVE_Remote_Message_Type, "");
|
||||||
|
mRemoteSensitiveMessageTypes = new HashSet<>();
|
||||||
|
if(!StringUtil.isNullOrEmpty(types)) {
|
||||||
|
String[] ts = types.split(",");
|
||||||
|
for (String t:ts) {
|
||||||
|
mRemoteSensitiveMessageTypes.add(Integer.parseInt(t.trim()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Utility.printExecption(LOG, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
mNoForwardAdminMessage = Boolean.parseBoolean(mServer.getConfig().getProperty(BrokerConstants.MESSAGE_NO_Forward_Admin_Message, "false"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Utility.printExecption(LOG, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
mAllowSend2ForbiddenUser = Boolean.parseBoolean(mServer.getConfig().getProperty(BrokerConstants.MESSAGES_ALLOW_SEND_TO_FORBIDDEN_USER, "false"));
|
||||||
|
} catch (Exception e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseTypes(Collection<Integer> collection, String types) {
|
||||||
|
try {
|
||||||
|
if (!StringUtil.isNullOrEmpty(types)) {
|
||||||
|
String[] tss = types.split(",");
|
||||||
|
for (String ts:tss) {
|
||||||
|
if(ts.contains("-")) {
|
||||||
|
String[] ss = ts.split("-");
|
||||||
|
if(ss.length == 2) {
|
||||||
|
int begin = Integer.parseInt(ss[0]);
|
||||||
|
int end = Integer.parseInt(ss[1]);
|
||||||
|
for (int i = begin; i <= end ; i++) {
|
||||||
|
collection.add(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
collection.add(Integer.parseInt(ts.trim()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, ProtoConstants.RequestSourceType requestSourceType, WFCMessage.Message message, Qos1PublishHandler.IMCallback callback) {
|
||||||
|
if(requestSourceType != ProtoConstants.RequestSourceType.Request_From_Robot) {
|
||||||
|
return ErrorCode.ERROR_CODE_NOT_IMPLEMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorCode errorCode = ErrorCode.ERROR_CODE_SUCCESS;
|
||||||
|
|
||||||
|
if (message != null) {
|
||||||
|
if(message.getContent().getContent().length() +
|
||||||
|
message.getContent().getSearchableContent().length() +
|
||||||
|
message.getContent().getData().size() +
|
||||||
|
message.getContent().getExtra().length() +
|
||||||
|
message.getContent().getPushContent().length() +
|
||||||
|
message.getContent().getPushData().length() > 64 * 1024) {
|
||||||
|
return ErrorCode.ERROR_CODE_MESSAGE_TOO_LARGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean ignoreMsg = false;
|
||||||
|
|
||||||
|
// 不能在端上直接发送撤回和群通知
|
||||||
|
if (message.getContent().getType() == 80 || message.getContent().getType() == 81 || (message.getContent().getType() >= 100 && message.getContent().getType() < 200)) {
|
||||||
|
return ErrorCode.INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(m_messagesStore.getClientForbiddenSendTypes().contains(message.getContent().getType())) {
|
||||||
|
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||||
|
}
|
||||||
|
|
||||||
|
int userStatus = m_messagesStore.getUserStatus(fromUser);
|
||||||
|
if (userStatus == ProtoConstants.UserStatus.Muted || userStatus == ProtoConstants.UserStatus.Forbidden) {
|
||||||
|
if(!m_messagesStore.getGlobalMuteExceptionTypes().contains(message.getContent().getType())) {
|
||||||
|
return ErrorCode.ERROR_CODE_FORBIDDEN_SEND_MSG;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Private) {
|
||||||
|
if(!m_messagesStore.getBlackListExceptionTypes().contains(message.getContent().getType())) {
|
||||||
|
errorCode = m_messagesStore.isAllowUserMessage(message.getConversation().getTarget(), fromUser, message.getConversation().getLine());
|
||||||
|
if (errorCode != ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
|
if (errorCode == ErrorCode.ERROR_CODE_IN_BLACK_LIST && mBlacklistStrategy != ProtoConstants.BlacklistStrategy.Message_Reject) {
|
||||||
|
ignoreMsg = true;
|
||||||
|
errorCode = ErrorCode.ERROR_CODE_SUCCESS;
|
||||||
|
} else {
|
||||||
|
return errorCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!mBlacklistAllowSend2Black) {
|
||||||
|
errorCode = m_messagesStore.isBlacked(fromUser, message.getConversation().getTarget());
|
||||||
|
if (errorCode != ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
|
return errorCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mAllowSend2ForbiddenUser) {
|
||||||
|
userStatus = m_messagesStore.getUserStatus(message.getConversation().getTarget());
|
||||||
|
if (userStatus == ProtoConstants.UserStatus.Forbidden) {
|
||||||
|
return ErrorCode.ERROR_CODE_USER_FORBIDDEN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Group ) {
|
||||||
|
if(!m_messagesStore.getGroupMuteExceptionTypes().contains(message.getContent().getType())) {
|
||||||
|
errorCode = m_messagesStore.canSendMessageInGroup(fromUser, message.getConversation().getTarget());
|
||||||
|
if(errorCode == ERROR_CODE_NOT_IN_GROUP) {
|
||||||
|
errorCode = ERROR_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
if (errorCode != ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
|
return errorCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_ChatRoom) {
|
||||||
|
if(!m_messagesStore.getGroupMuteExceptionTypes().contains(message.getContent().getType())) {
|
||||||
|
if (!m_messagesStore.checkUserClientInChatroom(fromUser, clientID, message.getConversation().getTarget())) {
|
||||||
|
return ErrorCode.ERROR_CODE_NOT_IN_CHATROOM;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Channel) {
|
||||||
|
if(!m_messagesStore.getGroupMuteExceptionTypes().contains(message.getContent().getType())) {
|
||||||
|
if (!m_messagesStore.canSendMessageInChannel(fromUser, message.getConversation().getTarget())) {
|
||||||
|
return ErrorCode.ERROR_CODE_NOT_IN_CHANNEL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Private) {
|
||||||
|
long beforeMessageId = message.getMessageId();
|
||||||
|
WFCMessage.Message replyMsg = m_messagesStore.getMessage(beforeMessageId);
|
||||||
|
message = message.toBuilder().setConversation(message.getConversation().toBuilder().setTarget(replyMsg.getFromUser() + "|" + replyMsg.getConversation().getTarget())).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
long timestamp = System.currentTimeMillis();
|
||||||
|
final long messageId;
|
||||||
|
try {
|
||||||
|
messageId = MessageShardingUtil.generateId();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return ErrorCode.ERROR_CODE_SERVER_ERROR;
|
||||||
|
}
|
||||||
|
message = message.toBuilder().setFromUser(fromUser).setMessageId(messageId).setServerTimestamp(timestamp).build();
|
||||||
|
|
||||||
|
|
||||||
|
if (!StringUtil.isNullOrEmpty(mForwardUrl) && (mForwardMessageTypes.isEmpty() || mForwardMessageTypes.contains(message.getContent().getType())) && !mForwardExcludeMessageTypes.contains(message.getContent().getType())) {
|
||||||
|
publisher.forwardMessage(message, mForwardUrl, clientID);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!StringUtil.isNullOrEmpty(mMentionForwardUrl) && message.hasContent() && message.getContent().getMentionedType() != 0) {
|
||||||
|
publisher.forwardMessage(message, mMentionForwardUrl, clientID);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(StringUtil.isNullOrEmpty(mRemoteSensitiveServerUrl)) {
|
||||||
|
Set<String> matched = m_messagesStore.handleSensitiveWord(message.getContent().getSearchableContent());
|
||||||
|
if (matched != null && !matched.isEmpty()) {
|
||||||
|
m_messagesStore.storeSensitiveMessage(message);
|
||||||
|
if (!StringUtil.isNullOrEmpty(mSensitiveMessageForwardUrl)) {
|
||||||
|
publisher.forwardMessage(message, mSensitiveMessageForwardUrl, clientID);
|
||||||
|
}
|
||||||
|
if (mSensitiveType == 0) {
|
||||||
|
errorCode = ErrorCode.ERROR_CODE_SENSITIVE_MATCHED;
|
||||||
|
} else if (mSensitiveType == 1) {
|
||||||
|
ignoreMsg = true;
|
||||||
|
} else if (mSensitiveType == 2) {
|
||||||
|
String text = message.getContent().getSearchableContent();
|
||||||
|
for (String word : matched) {
|
||||||
|
text = text.replace(word, "***");
|
||||||
|
}
|
||||||
|
message = message.toBuilder().setContent(message.getContent().toBuilder().setSearchableContent(text).build()).build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(mRemoteSensitiveMessageTypes.contains(message.getContent().getType())) {
|
||||||
|
final WFCMessage.Message finalMsg = message;
|
||||||
|
publisher.forwardMessageWithCallback(message, clientID, mRemoteSensitiveServerUrl, new HttpUtils.HttpCallback() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(String content) {
|
||||||
|
if(StringUtil.isNullOrEmpty(content)) {
|
||||||
|
saveAndPublish(fromUser, clientID, finalMsg, requestSourceType);
|
||||||
|
} else {
|
||||||
|
MessagePayload payload = GsonUtil.gson.fromJson(content, MessagePayload.class);
|
||||||
|
if (payload != null && payload.getType() > 0) {
|
||||||
|
WFCMessage.Message newMsg = finalMsg.toBuilder().setContent(payload.toProtoMessageContent()).build();
|
||||||
|
saveAndPublish(fromUser, clientID, newMsg, requestSourceType);
|
||||||
|
} else {
|
||||||
|
LOG.error("Response content {} from censor is invalid payload, ignore response and send original message", content);
|
||||||
|
saveAndPublish(fromUser, clientID, finalMsg, requestSourceType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(mWaitRemoteSensitiveServerResponse) {
|
||||||
|
ByteBuf ackPayload = Unpooled.buffer(21);
|
||||||
|
ErrorCode errorCode = ERROR_CODE_SUCCESS;
|
||||||
|
ackPayload.writeByte(errorCode.getCode());
|
||||||
|
ackPayload.writeLong(messageId);
|
||||||
|
ackPayload.writeLong(timestamp);
|
||||||
|
callback.onIMHandled(ErrorCode.ERROR_CODE_SUCCESS, ackPayload);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(int statusCode, String errorMessage) {
|
||||||
|
ByteBuf ackPayload = null;
|
||||||
|
ErrorCode errorCode = ERROR_CODE_SUCCESS;
|
||||||
|
if(statusCode == 403) {
|
||||||
|
if(mWaitRemoteSensitiveServerResponse) {
|
||||||
|
errorCode = ErrorCode.ERROR_CODE_SENSITIVE_MATCHED;
|
||||||
|
ackPayload = Unpooled.buffer(1);
|
||||||
|
ackPayload.writeByte(errorCode.getCode());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LOG.warn("Failed to censor message with status {}, errorMessage {}. Send the original message", statusCode, errorMessage);
|
||||||
|
saveAndPublish(fromUser, clientID, finalMsg, requestSourceType);
|
||||||
|
|
||||||
|
if(mWaitRemoteSensitiveServerResponse) {
|
||||||
|
errorCode = ERROR_CODE_SUCCESS;
|
||||||
|
ackPayload = Unpooled.buffer(21);
|
||||||
|
ackPayload.writeByte(errorCode.getCode());
|
||||||
|
ackPayload.writeLong(messageId);
|
||||||
|
ackPayload.writeLong(timestamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mWaitRemoteSensitiveServerResponse) {
|
||||||
|
callback.onIMHandled(errorCode, ackPayload);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if(mWaitRemoteSensitiveServerResponse) {
|
||||||
|
ackPayload.clear();
|
||||||
|
return ErrorCode.INVALID_ASYNC_HANDLING;
|
||||||
|
} else {
|
||||||
|
ackPayload = ackPayload.capacity(20);
|
||||||
|
ackPayload.writeLong(messageId);
|
||||||
|
ackPayload.writeLong(timestamp);
|
||||||
|
return ErrorCode.ERROR_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
|
if(!ignoreMsg) {
|
||||||
|
saveAndPublish(fromUser, clientID, message, requestSourceType);
|
||||||
|
}
|
||||||
|
ackPayload = ackPayload.capacity(20);
|
||||||
|
ackPayload.writeLong(messageId);
|
||||||
|
ackPayload.writeLong(timestamp);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
errorCode = ErrorCode.ERROR_CODE_INVALID_MESSAGE;
|
||||||
|
}
|
||||||
|
return errorCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -136,6 +136,15 @@ public class SendMessageHandler extends IMHandler<WFCMessage.Message> {
|
|||||||
ErrorCode errorCode = ErrorCode.ERROR_CODE_SUCCESS;
|
ErrorCode errorCode = ErrorCode.ERROR_CODE_SUCCESS;
|
||||||
boolean isAdmin = requestSourceType == ProtoConstants.RequestSourceType.Request_From_Admin;
|
boolean isAdmin = requestSourceType == ProtoConstants.RequestSourceType.Request_From_Admin;
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
|
if(message.getContent().getContent().length() +
|
||||||
|
message.getContent().getSearchableContent().length() +
|
||||||
|
message.getContent().getData().size() +
|
||||||
|
message.getContent().getExtra().length() +
|
||||||
|
message.getContent().getPushContent().length() +
|
||||||
|
message.getContent().getPushData().length() > 64 * 1024) {
|
||||||
|
return ErrorCode.ERROR_CODE_MESSAGE_TOO_LARGE;
|
||||||
|
}
|
||||||
|
|
||||||
boolean ignoreMsg = false;
|
boolean ignoreMsg = false;
|
||||||
if (!isAdmin) { //admin do not check the right
|
if (!isAdmin) { //admin do not check the right
|
||||||
// 不能在端上直接发送撤回和群通知
|
// 不能在端上直接发送撤回和群通知
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
private boolean mGroupAllowPartSuccess = false;
|
private boolean mGroupAllowPartSuccess = false;
|
||||||
|
|
||||||
private boolean mIDUseUUID = true;
|
private boolean mIDUseUUID = true;
|
||||||
|
private boolean mSensitiveOnlyMessage = true;
|
||||||
private Set<String> mClientSignatureSet = new HashSet<>();
|
private Set<String> mClientSignatureSet = new HashSet<>();
|
||||||
private boolean mRejectEmptySignature = true;
|
private boolean mRejectEmptySignature = true;
|
||||||
|
|
||||||
@@ -213,6 +213,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
private boolean mRobotCallbackWithClientInfo = false;
|
private boolean mRobotCallbackWithClientInfo = false;
|
||||||
private boolean mRobotCallbackWithSenderInfo = false;
|
private boolean mRobotCallbackWithSenderInfo = false;
|
||||||
private boolean mRobotCallbackWithTargetInfo = false;
|
private boolean mRobotCallbackWithTargetInfo = false;
|
||||||
|
private boolean mRobotMentionExternalRobot = false;
|
||||||
|
|
||||||
private boolean mChannelCallbackWithClientInfo = false;
|
private boolean mChannelCallbackWithClientInfo = false;
|
||||||
private boolean mChannelCallbackWithSenderInfo = false;
|
private boolean mChannelCallbackWithSenderInfo = false;
|
||||||
@@ -646,6 +647,9 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
try {
|
try {
|
||||||
mRobotCallbackWithTargetInfo = Boolean.parseBoolean(server.getConfig().getProperty(BrokerConstants.ROBOT_Callback_With_Target_Info, "false"));
|
mRobotCallbackWithTargetInfo = Boolean.parseBoolean(server.getConfig().getProperty(BrokerConstants.ROBOT_Callback_With_Target_Info, "false"));
|
||||||
} catch (Exception e) {}
|
} catch (Exception e) {}
|
||||||
|
try {
|
||||||
|
mRobotMentionExternalRobot = Boolean.parseBoolean(server.getConfig().getProperty(BrokerConstants.ROBOT_Mention_External_Robot, "false"));
|
||||||
|
} catch (Exception e) {}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mChannelCallbackWithClientInfo = Boolean.parseBoolean(server.getConfig().getProperty(BrokerConstants.CHANNEL_Callback_With_Client_Info, "false"));
|
mChannelCallbackWithClientInfo = Boolean.parseBoolean(server.getConfig().getProperty(BrokerConstants.CHANNEL_Callback_With_Client_Info, "false"));
|
||||||
@@ -671,6 +675,11 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
mIDUseUUID = Boolean.parseBoolean(server.getConfig().getProperty(BrokerConstants.ID_USE_UUID, "false"));
|
mIDUseUUID = Boolean.parseBoolean(server.getConfig().getProperty(BrokerConstants.ID_USE_UUID, "false"));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
mSensitiveOnlyMessage = Boolean.parseBoolean(server.getConfig().getProperty(BrokerConstants.SENSITIVE_Only_Message, "true"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printMissConfigLog(String config, String defaultValue) {
|
private void printMissConfigLog(String config, String defaultValue) {
|
||||||
@@ -737,13 +746,34 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
int pullType = ProtoConstants.PullType.Pull_Normal;
|
int pullType = ProtoConstants.PullType.Pull_Normal;
|
||||||
|
|
||||||
if (type == ProtoConstants.ConversationType.ConversationType_Private) {
|
if (type == ProtoConstants.ConversationType.ConversationType_Private) {
|
||||||
notifyReceivers.add(fromUser);
|
if(mRobotMentionExternalRobot && message.getConversation().getTarget().contains("|")) {
|
||||||
if(message.getToCount() > 0) {
|
String[] ss = message.getConversation().getTarget().split("\\|");
|
||||||
if(message.getToList().contains(message.getConversation().getTarget())) {
|
notifyReceivers.add(ss[0]);
|
||||||
notifyReceivers.add(message.getConversation().getTarget());
|
notifyReceivers.add(ss[1]);
|
||||||
|
if(!message.getToList().isEmpty()) {
|
||||||
|
notifyReceivers.addAll(message.getToList());
|
||||||
|
} else if(!StringUtil.isNullOrEmpty(message.getToUser())) {
|
||||||
|
notifyReceivers.add(message.getToUser());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
notifyReceivers.add(message.getConversation().getTarget());
|
notifyReceivers.add(fromUser);
|
||||||
|
if (message.getToCount() > 0) {
|
||||||
|
if (message.getToList().contains(message.getConversation().getTarget())) {
|
||||||
|
notifyReceivers.add(message.getConversation().getTarget());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
notifyReceivers.add(message.getConversation().getTarget());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mRobotMentionExternalRobot && message.getContent().getMentionedTargetCount() > 0) {
|
||||||
|
for (String mentioned : message.getContent().getMentionedTargetList()) {
|
||||||
|
if (!notifyReceivers.contains(mentioned)) {
|
||||||
|
WFCMessage.User user = getUserInfo(mentioned);
|
||||||
|
if(user != null && user.getType() == ProtoConstants.UserType.UserType_Robot) {
|
||||||
|
notifyReceivers.add(mentioned);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pullType = ProtoConstants.PullType.Pull_Normal;
|
pullType = ProtoConstants.PullType.Pull_Normal;
|
||||||
} else if (type == ProtoConstants.ConversationType.ConversationType_Group) {
|
} else if (type == ProtoConstants.ConversationType.ConversationType_Group) {
|
||||||
@@ -773,6 +803,16 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (mRobotMentionExternalRobot && message.getContent().getMentionedTargetCount() > 0) {
|
||||||
|
for (String mentioned : message.getContent().getMentionedTargetList()) {
|
||||||
|
if (!notifyReceivers.contains(mentioned)) {
|
||||||
|
WFCMessage.User user = getUserInfo(mentioned);
|
||||||
|
if(user != null && user.getType() == ProtoConstants.UserType.UserType_Robot) {
|
||||||
|
notifyReceivers.add(mentioned);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
pullType = ProtoConstants.PullType.Pull_Normal;
|
pullType = ProtoConstants.PullType.Pull_Normal;
|
||||||
} else if (type == ProtoConstants.ConversationType.ConversationType_ChatRoom) {
|
} else if (type == ProtoConstants.ConversationType.ConversationType_ChatRoom) {
|
||||||
boolean isDirect = !StringUtil.isNullOrEmpty(message.getToUser()) || !message.getToList().isEmpty();
|
boolean isDirect = !StringUtil.isNullOrEmpty(message.getToUser()) || !message.getToList().isEmpty();
|
||||||
@@ -1974,6 +2014,19 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
if (!isAllow) {
|
if (!isAllow) {
|
||||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (modifyType == Modify_Group_Name && !StringUtil.isNullOrEmpty(value)) {
|
||||||
|
if(!mSensitiveOnlyMessage) {
|
||||||
|
Set<String> matched = handleSensitiveWord(value);
|
||||||
|
if (matched != null && !matched.isEmpty()) {
|
||||||
|
return ErrorCode.ERROR_CODE_SENSITIVE_MATCHED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isAllowName(value)) {
|
||||||
|
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldInfo.getType() == ProtoConstants.GroupType.GroupType_Normal) {
|
if (oldInfo.getType() == ProtoConstants.GroupType.GroupType_Normal) {
|
||||||
@@ -2810,6 +2863,19 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
) {
|
) {
|
||||||
switch (entry.getType()) {
|
switch (entry.getType()) {
|
||||||
case Modify_DisplayName:
|
case Modify_DisplayName:
|
||||||
|
if(!StringUtil.isNullOrEmpty(entry.getValue())) {
|
||||||
|
if (!mSensitiveOnlyMessage) {
|
||||||
|
Set<String> matched = handleSensitiveWord(entry.getValue());
|
||||||
|
if (matched != null && !matched.isEmpty()) {
|
||||||
|
return ErrorCode.ERROR_CODE_SENSITIVE_MATCHED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isAllowName(entry.getValue())) {
|
||||||
|
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
builder.setDisplayName(entry.getValue());
|
builder.setDisplayName(entry.getValue());
|
||||||
modified = true;
|
modified = true;
|
||||||
break;
|
break;
|
||||||
@@ -3901,6 +3967,25 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
return ErrorCode.ERROR_CODE_SUCCESS;
|
return ErrorCode.ERROR_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAllowName(String name) {
|
||||||
|
if(StringUtil.isNullOrEmpty(name)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
name = name.trim();
|
||||||
|
SystemSettingPojo notAllowNameSetting = getSystemSetting(ProtoConstants.SystemSettingType.NOT_ALLOW_USER_NAMES);
|
||||||
|
if (notAllowNameSetting != null && !StringUtil.isNullOrEmpty(notAllowNameSetting.value)) {
|
||||||
|
String[] ss = notAllowNameSetting.value.split(",");
|
||||||
|
for (String s : ss) {
|
||||||
|
if(name.contains(s.trim())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ErrorCode handleJoinChatroom(String userId, String clientId, String chatroomId) {
|
public ErrorCode handleJoinChatroom(String userId, String clientId, String chatroomId) {
|
||||||
IMap<String, WFCMessage.ChatroomInfo> chatroomInfoMap = m_Server.getHazelcastInstance().getMap(CHATROOMS);
|
IMap<String, WFCMessage.ChatroomInfo> chatroomInfoMap = m_Server.getHazelcastInstance().getMap(CHATROOMS);
|
||||||
@@ -4770,6 +4855,11 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
return new ArrayList<>(databaseStore.getSensitiveWord());
|
return new ArrayList<>(databaseStore.getSensitiveWord());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSensitiveOnlyMessage() {
|
||||||
|
return mSensitiveOnlyMessage;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WFCMessage.Message getMessage(long messageId) {
|
public WFCMessage.Message getMessage(long messageId) {
|
||||||
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
||||||
@@ -4836,6 +4926,11 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
return mRobotCallbackWithTargetInfo;
|
return mRobotCallbackWithTargetInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isRobotMentionExternalRobot() {
|
||||||
|
return mRobotMentionExternalRobot;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isChannelCallbackWithClientInfo() {
|
public boolean isChannelCallbackWithClientInfo() {
|
||||||
return mChannelCallbackWithClientInfo;
|
return mChannelCallbackWithClientInfo;
|
||||||
|
|||||||
@@ -190,6 +190,8 @@ public interface IMessagesStore {
|
|||||||
ErrorCode setFriendAliasRequest(String fromUser, String targetUserId, String alias, long[] head);
|
ErrorCode setFriendAliasRequest(String fromUser, String targetUserId, String alias, long[] head);
|
||||||
ErrorCode setFriendExtraRequest(String fromUser, String targetUserId, String extra, long[] head);
|
ErrorCode setFriendExtraRequest(String fromUser, String targetUserId, String extra, long[] head);
|
||||||
|
|
||||||
|
boolean isAllowName(String name);
|
||||||
|
|
||||||
ErrorCode handleJoinChatroom(String userId, String clientId, String chatroomId);
|
ErrorCode handleJoinChatroom(String userId, String clientId, String chatroomId);
|
||||||
ErrorCode handleQuitChatroom(String userId, String clientId, String chatroomId);
|
ErrorCode handleQuitChatroom(String userId, String clientId, String chatroomId);
|
||||||
|
|
||||||
@@ -232,6 +234,7 @@ public interface IMessagesStore {
|
|||||||
boolean addSensitiveWords(List<String> words);
|
boolean addSensitiveWords(List<String> words);
|
||||||
boolean removeSensitiveWords(List<String> words);
|
boolean removeSensitiveWords(List<String> words);
|
||||||
List<String> getAllSensitiveWords();
|
List<String> getAllSensitiveWords();
|
||||||
|
boolean isSensitiveOnlyMessage();
|
||||||
|
|
||||||
WFCMessage.Message getMessage(long messageId);
|
WFCMessage.Message getMessage(long messageId);
|
||||||
|
|
||||||
@@ -251,6 +254,7 @@ public interface IMessagesStore {
|
|||||||
boolean isRobotCallbackWithClientInfo();
|
boolean isRobotCallbackWithClientInfo();
|
||||||
boolean isRobotCallbackWithSenderInfo();
|
boolean isRobotCallbackWithSenderInfo();
|
||||||
boolean isRobotCallbackWithTargetInfo();
|
boolean isRobotCallbackWithTargetInfo();
|
||||||
|
boolean isRobotMentionExternalRobot();
|
||||||
|
|
||||||
boolean isChannelCallbackWithClientInfo();
|
boolean isChannelCallbackWithClientInfo();
|
||||||
boolean isChannelCallbackWithSenderInfo();
|
boolean isChannelCallbackWithSenderInfo();
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ package win.liyufan.im;
|
|||||||
|
|
||||||
public interface IMTopic {
|
public interface IMTopic {
|
||||||
String SendMessageTopic = "MS";
|
String SendMessageTopic = "MS";
|
||||||
|
String RobotReplyMessageTopic = "RRM";
|
||||||
String MultiCastMessageTopic = "MMC";
|
String MultiCastMessageTopic = "MMC";
|
||||||
String RecallMessageTopic = "MR";
|
String RecallMessageTopic = "MR";
|
||||||
String RecallMultiCastMessageTopic = "MRMC";
|
String RecallMultiCastMessageTopic = "MRMC";
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>wildfirechat-parent</artifactId>
|
<artifactId>wildfirechat-parent</artifactId>
|
||||||
<groupId>cn.wildfirechat</groupId>
|
<groupId>cn.wildfirechat</groupId>
|
||||||
<version>1.3.7</version>
|
<version>1.3.9</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ public interface APIPath {
|
|||||||
String Get_Domain = "/admin/domain/get";
|
String Get_Domain = "/admin/domain/get";
|
||||||
String Destroy_Domain = "/admin/domain/destroy";
|
String Destroy_Domain = "/admin/domain/destroy";
|
||||||
String List_Domain = "/admin/domain/list";
|
String List_Domain = "/admin/domain/list";
|
||||||
|
String Ping_Domain = "/admin/domain/ping";
|
||||||
|
|
||||||
String Create_User = "/admin/user/create";
|
String Create_User = "/admin/user/create";
|
||||||
String Update_User = "/admin/user/update";
|
String Update_User = "/admin/user/update";
|
||||||
@@ -128,6 +129,8 @@ public interface APIPath {
|
|||||||
String Channel_Update_Profile = "/channel/update_profile";
|
String Channel_Update_Profile = "/channel/update_profile";
|
||||||
String Channel_Get_Profile = "/channel/get_profile";
|
String Channel_Get_Profile = "/channel/get_profile";
|
||||||
String Channel_Message_Send = "/channel/message/send";
|
String Channel_Message_Send = "/channel/message/send";
|
||||||
|
String Channel_Msg_Recall = "/channel/message/recall";
|
||||||
|
String Channel_Msg_Republish = "/channel/message/republish";
|
||||||
String Channel_Subscribe = "/channel/subscribe";
|
String Channel_Subscribe = "/channel/subscribe";
|
||||||
String Channel_Subscriber_List = "/channel/subscriber_list";
|
String Channel_Subscriber_List = "/channel/subscriber_list";
|
||||||
String Channel_Is_Subscriber = "/channel/is_subscriber";
|
String Channel_Is_Subscriber = "/channel/is_subscriber";
|
||||||
@@ -136,6 +139,7 @@ public interface APIPath {
|
|||||||
String Robot_User_Info = "/robot/user_info";
|
String Robot_User_Info = "/robot/user_info";
|
||||||
String Robot_Get_Profile = "/robot/profile";
|
String Robot_Get_Profile = "/robot/profile";
|
||||||
String Robot_Message_Send = "/robot/message/send";
|
String Robot_Message_Send = "/robot/message/send";
|
||||||
|
String Robot_Message_Reply = "/robot/message/reply";
|
||||||
String Robot_Message_Recall = "/robot/message/recall";
|
String Robot_Message_Recall = "/robot/message/recall";
|
||||||
String Robot_Message_Update = "/robot/message/update";
|
String Robot_Message_Update = "/robot/message/update";
|
||||||
String Robot_Set_Callback = "/robot/set_callback";
|
String Robot_Set_Callback = "/robot/set_callback";
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ public enum ErrorCode {
|
|||||||
ERROR_CODE_ROBOT_NO_TOKEN(27, "robot no token"),
|
ERROR_CODE_ROBOT_NO_TOKEN(27, "robot no token"),
|
||||||
ERROR_CODE_WS_NOT_CONFIGURED_CORRECTLY(28, "ws not configured correctly"),
|
ERROR_CODE_WS_NOT_CONFIGURED_CORRECTLY(28, "ws not configured correctly"),
|
||||||
ERROR_CODE_TIME_INCONSISTENT(30, "time inconsistent"),
|
ERROR_CODE_TIME_INCONSISTENT(30, "time inconsistent"),
|
||||||
|
ERROR_CODE_MESSAGE_TOO_LARGE(35, "message too large"),
|
||||||
ERROR_CODE_CONFERENCE_ROOM_NOT_EXIST(60, "conference room not exist"),
|
ERROR_CODE_CONFERENCE_ROOM_NOT_EXIST(60, "conference room not exist"),
|
||||||
ERROR_CODE_CONFERENCE_SERVICE_NOT_AVAILABLE(61, "conference service not available"),
|
ERROR_CODE_CONFERENCE_SERVICE_NOT_AVAILABLE(61, "conference service not available"),
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the Wildfire Chat package.
|
||||||
|
* (c) Heavyrain2012 <heavyrain.lee@gmail.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package cn.wildfirechat.pojos;
|
||||||
|
|
||||||
|
import cn.wildfirechat.proto.WFCMessage;
|
||||||
|
import io.netty.util.internal.StringUtil;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ReplyMessageData {
|
||||||
|
private long messageUid;
|
||||||
|
private MessagePayload payload;
|
||||||
|
private boolean only2Sender;
|
||||||
|
|
||||||
|
public long getMessageUid() {
|
||||||
|
return messageUid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessageUid(long messageUid) {
|
||||||
|
this.messageUid = messageUid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessagePayload getPayload() {
|
||||||
|
return payload;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPayload(MessagePayload payload) {
|
||||||
|
this.payload = payload;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isOnly2Sender() {
|
||||||
|
return only2Sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnly2Sender(boolean only2Sender) {
|
||||||
|
this.only2Sender = only2Sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isValide(ReplyMessageData sendMessageData) {
|
||||||
|
if(sendMessageData.messageUid <=0 ||
|
||||||
|
sendMessageData.getPayload() == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the Wildfire Chat package.
|
||||||
|
* (c) Heavyrain2012 <heavyrain.lee@gmail.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package cn.wildfirechat.pojos;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class RepublishChannelMessageData {
|
||||||
|
private List<String> targets;
|
||||||
|
private long messageId;
|
||||||
|
|
||||||
|
public List<String> getTargets() {
|
||||||
|
return targets;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTargets(List<String> targets) {
|
||||||
|
this.targets = targets;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getMessageId() {
|
||||||
|
return messageId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessageId(long messageId) {
|
||||||
|
this.messageId = messageId;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,6 +20,7 @@ public class SendMessageData {
|
|||||||
private MessagePayload payload;
|
private MessagePayload payload;
|
||||||
private List<String> toUsers;
|
private List<String> toUsers;
|
||||||
private boolean isMeshMessage;
|
private boolean isMeshMessage;
|
||||||
|
private boolean isUserMessage;
|
||||||
|
|
||||||
public String getSender() {
|
public String getSender() {
|
||||||
return sender;
|
return sender;
|
||||||
@@ -61,6 +62,14 @@ public class SendMessageData {
|
|||||||
isMeshMessage = meshMessage;
|
isMeshMessage = meshMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isUserMessage() {
|
||||||
|
return isUserMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserMessage(boolean userMessage) {
|
||||||
|
isUserMessage = userMessage;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isValide(SendMessageData sendMessageData) {
|
public static boolean isValide(SendMessageData sendMessageData) {
|
||||||
if(sendMessageData == null ||
|
if(sendMessageData == null ||
|
||||||
sendMessageData.getConv() == null ||
|
sendMessageData.getConv() == null ||
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the Wildfire Chat package.
|
||||||
|
* (c) Heavyrain2012 <heavyrain.lee@gmail.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package cn.wildfirechat.pojos.mesh;
|
||||||
|
|
||||||
|
|
||||||
|
public class PojoDomainPingRequest {
|
||||||
|
public String domainId;
|
||||||
|
}
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the Wildfire Chat package.
|
||||||
|
* (c) Heavyrain2012 <heavyrain.lee@gmail.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package cn.wildfirechat.pojos.mesh;
|
||||||
|
|
||||||
|
|
||||||
|
public class PojoDomainPingResponse {
|
||||||
|
public boolean success;
|
||||||
|
public String errorMessage;
|
||||||
|
public String myDomainName;
|
||||||
|
}
|
||||||
@@ -226,6 +226,7 @@ public class ProtoConstants {
|
|||||||
|
|
||||||
public interface SystemSettingType {
|
public interface SystemSettingType {
|
||||||
int Group_Max_Member_Count = 1;
|
int Group_Max_Member_Count = 1;
|
||||||
|
int NOT_ALLOW_USER_NAMES = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface SearchUserType {
|
public interface SearchUserType {
|
||||||
|
|||||||
@@ -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.3.7</version>
|
<version>1.3.9</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>distribution</artifactId>
|
<artifactId>distribution</artifactId>
|
||||||
|
|||||||
@@ -167,6 +167,10 @@ robot.callback_with_sender_info false
|
|||||||
## 机器人回调信息是否带上目标的信息,单聊时是对方用户信息,群聊时是群组信息,频道时是频道信息
|
## 机器人回调信息是否带上目标的信息,单聊时是对方用户信息,群聊时是群组信息,频道时是频道信息
|
||||||
robot.callback_with_target_info false
|
robot.callback_with_target_info false
|
||||||
|
|
||||||
|
## 是否允许@会话外的机器人。如果为true,单聊或者群聊时,可以@不在会话中的机器人。当机器人收到消息后,可以回复消息。
|
||||||
|
## 如果为false,不能@不在会话中的机器人。机器人不在会话中时,也不能回复消息。
|
||||||
|
robot.mention_external_robot true
|
||||||
|
|
||||||
## 频道回调信息是否带上用户clientId和平台类型。
|
## 频道回调信息是否带上用户clientId和平台类型。
|
||||||
channel.callback_with_client_info false
|
channel.callback_with_client_info false
|
||||||
|
|
||||||
@@ -455,6 +459,10 @@ push.harmony.server.address http://localhost:8085/harmony/push
|
|||||||
## 如果开启 message.sensitive.forward.url 配置,命中敏感词的消息还会被回调到这个地址
|
## 如果开启 message.sensitive.forward.url 配置,命中敏感词的消息还会被回调到这个地址
|
||||||
sensitive.filter.type 2
|
sensitive.filter.type 2
|
||||||
|
|
||||||
|
## 敏感词是否只处理消息。如果为true,只过滤消息;如果为false,会同时过滤用户昵称、群组名和群昵称。
|
||||||
|
## 除了消息之外的信息只支持内部敏感词处理,不支持外置审核。
|
||||||
|
sensitive.only_message false
|
||||||
|
|
||||||
## 敏感词添加或者删除有2种方式,一种是通过Server API进行,这种方式会立即生效。另外一种方法是修改数据库,直接中数据库的t_sensitive_word表中处理
|
## 敏感词添加或者删除有2种方式,一种是通过Server API进行,这种方式会立即生效。另外一种方法是修改数据库,直接中数据库的t_sensitive_word表中处理
|
||||||
## 修改数据库的方法不会立即生效,IM服务会2个小时重新加载一次敏感词。所以如果直接修改敏感词表,需要等2个小时,或者重启才能生效。
|
## 修改数据库的方法不会立即生效,IM服务会2个小时重新加载一次敏感词。所以如果直接修改敏感词表,需要等2个小时,或者重启才能生效。
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
<artifactId>wildfirechat-parent</artifactId>
|
<artifactId>wildfirechat-parent</artifactId>
|
||||||
|
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<version>1.3.7</version>
|
<version>1.3.9</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>
|
||||||
|
|||||||
@@ -9,8 +9,24 @@
|
|||||||
8. *** 从0.78 版本起把MySQL数据库中关键字都改为大小写敏感,另外生成id的方法也做了改变,只生成小写的id,避免出现id重复的问题,建议所有客户都升级 ***
|
8. *** 从0.78 版本起把MySQL数据库中关键字都改为大小写敏感,另外生成id的方法也做了改变,只生成小写的id,避免出现id重复的问题,建议所有客户都升级 ***
|
||||||
9. *** 从0.79 版本起把log4j升级到log4j2,因为log4j已经不再维护而且还有已知的漏洞,建议所有客户都升级,升级时注意更新log4j2的配置文件 ***
|
9. *** 从0.79 版本起把log4j升级到log4j2,因为log4j已经不再维护而且还有已知的漏洞,建议所有客户都升级,升级时注意更新log4j2的配置文件 ***
|
||||||
10. *** 0.97版本更改了启动脚本```wildfirechat.sh```,如果是升级服务,请注意更新启动脚本。***
|
10. *** 0.97版本更改了启动脚本```wildfirechat.sh```,如果是升级服务,请注意更新启动脚本。***
|
||||||
|
11. *** 1.3.8版本添加了server api发送消息的限制,限制消息体最大内容不能超过64KB,如果升级请注意业务系统发送消息大小。***
|
||||||
|
|
||||||
# 更新记录
|
# 更新记录
|
||||||
|
--------------
|
||||||
|
Release note 1.3.9:
|
||||||
|
1. 解决server sdk反复初始化内存泄漏的问题。
|
||||||
|
2. 群组支持用户@不在群组中的机器人。
|
||||||
|
3. 单聊会话支持@机器人。
|
||||||
|
4. 机器人支持回复消息,可以回复单聊或者群聊消息。
|
||||||
|
|
||||||
|
--------------
|
||||||
|
Release note 1.3.8:
|
||||||
|
1. 添加限制,server api发送消息,限制消息体不能大于64KB。
|
||||||
|
2. 添加配置敏感词是否过滤用户信息群组信息昵称等。
|
||||||
|
3. 配置文件可以设置不允许使用的用户名字群组名称群名片等。
|
||||||
|
4. server api发送消息添加参数,可以以用户权限发送消息。
|
||||||
|
5. server api添加群备注和收藏群组接口。
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
Release note 1.3.7:
|
Release note 1.3.7:
|
||||||
1. 搜索用户可以指定搜索机器人、普通用户或者所有。
|
1. 搜索用户可以指定搜索机器人、普通用户或者所有。
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>wildfirechat-parent</artifactId>
|
<artifactId>wildfirechat-parent</artifactId>
|
||||||
<groupId>cn.wildfirechat</groupId>
|
<groupId>cn.wildfirechat</groupId>
|
||||||
<version>1.3.7</version>
|
<version>1.3.9</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -4,16 +4,19 @@ import cn.wildfirechat.common.APIPath;
|
|||||||
import cn.wildfirechat.pojos.*;
|
import cn.wildfirechat.pojos.*;
|
||||||
import cn.wildfirechat.proto.ProtoConstants;
|
import cn.wildfirechat.proto.ProtoConstants;
|
||||||
import cn.wildfirechat.sdk.model.IMResult;
|
import cn.wildfirechat.sdk.model.IMResult;
|
||||||
|
import cn.wildfirechat.sdk.utilities.AdminHttpUtils;
|
||||||
import cn.wildfirechat.sdk.utilities.ChannelHttpUtils;
|
import cn.wildfirechat.sdk.utilities.ChannelHttpUtils;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static cn.wildfirechat.proto.ProtoConstants.ApplicationType.ApplicationType_Channel;
|
import static cn.wildfirechat.proto.ProtoConstants.ApplicationType.ApplicationType_Channel;
|
||||||
|
|
||||||
//仅专业版支持,社区版不支持
|
//仅专业版支持,社区版不支持
|
||||||
public class ChannelServiceApi {
|
public class ChannelServiceApi implements Closeable {
|
||||||
private final ChannelHttpUtils channelHttpUtils;
|
private final ChannelHttpUtils channelHttpUtils;
|
||||||
|
|
||||||
public ChannelServiceApi(String imurl, String channelId, String secret) {
|
public ChannelServiceApi(String imurl, String channelId, String secret) {
|
||||||
@@ -65,6 +68,21 @@ public class ChannelServiceApi {
|
|||||||
return channelHttpUtils.httpJsonPost(path, messageData, SendMessageResult.class);
|
return channelHttpUtils.httpJsonPost(path, messageData, SendMessageResult.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IMResult<String> recallMessage(long messageUid) throws Exception {
|
||||||
|
String path = APIPath.Channel_Msg_Recall;
|
||||||
|
RecallMessageData messageData = new RecallMessageData();
|
||||||
|
messageData.setMessageUid(messageUid);
|
||||||
|
return channelHttpUtils.httpJsonPost(path, messageData, String.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IMResult<Void> republishMessage(long messageUid, List<String> targets) throws Exception {
|
||||||
|
String path = APIPath.Channel_Msg_Republish;
|
||||||
|
RepublishChannelMessageData messageData = new RepublishChannelMessageData();
|
||||||
|
messageData.setMessageId(messageUid);
|
||||||
|
messageData.setTargets(targets);
|
||||||
|
return channelHttpUtils.httpJsonPost(path, messageData, Void.class);
|
||||||
|
}
|
||||||
|
|
||||||
public IMResult<Void> subscribe(String userId) throws Exception {
|
public IMResult<Void> subscribe(String userId) throws Exception {
|
||||||
String path = APIPath.Channel_Subscribe;
|
String path = APIPath.Channel_Subscribe;
|
||||||
InputChannelSubscribe input = new InputChannelSubscribe();
|
InputChannelSubscribe input = new InputChannelSubscribe();
|
||||||
@@ -113,4 +131,8 @@ public class ChannelServiceApi {
|
|||||||
return configData;
|
return configData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() throws IOException {
|
||||||
|
channelHttpUtils.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package cn.wildfirechat.sdk;
|
package cn.wildfirechat.sdk;
|
||||||
|
|
||||||
import cn.wildfirechat.common.APIPath;
|
import cn.wildfirechat.common.APIPath;
|
||||||
|
import cn.wildfirechat.common.ErrorCode;
|
||||||
import cn.wildfirechat.pojos.*;
|
import cn.wildfirechat.pojos.*;
|
||||||
import cn.wildfirechat.sdk.model.IMResult;
|
import cn.wildfirechat.sdk.model.IMResult;
|
||||||
import cn.wildfirechat.sdk.utilities.AdminHttpUtils;
|
import cn.wildfirechat.sdk.utilities.AdminHttpUtils;
|
||||||
@@ -178,6 +179,36 @@ public class GroupAdmin {
|
|||||||
return AdminHttpUtils.httpJsonPost(path, input, Void.class);
|
return AdminHttpUtils.httpJsonPost(path, input, Void.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IMResult<Void> setGroupRemark(String userId, String groupId, String remark) throws Exception {
|
||||||
|
return GeneralAdmin.setUserSetting(userId, 26, groupId, remark);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IMResult<String> getGroupRemark(String userId, String groupId) throws Exception {
|
||||||
|
IMResult<UserSettingPojo> imResult = GeneralAdmin.getUserSetting(userId, 26, groupId);
|
||||||
|
IMResult<String> result = new IMResult<>();
|
||||||
|
result.code = imResult.code;;
|
||||||
|
result.msg = imResult.msg;;
|
||||||
|
if(imResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
|
result.result = imResult.result.getValue();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IMResult<Void> setFavGroup(String userId, String groupId, boolean fav) throws Exception {
|
||||||
|
return GeneralAdmin.setUserSetting(userId, 6, groupId, fav?"1":"0");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IMResult<Boolean> isFavGroup(String userId, String groupId) throws Exception {
|
||||||
|
IMResult<UserSettingPojo> imResult = GeneralAdmin.getUserSetting(userId, 6, groupId);
|
||||||
|
IMResult<Boolean> result = new IMResult<>();
|
||||||
|
result.code = imResult.code;;
|
||||||
|
result.msg = imResult.msg;;
|
||||||
|
if(imResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
|
result.result = "1".equals(imResult.getResult().getValue());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public static IMResult<OutputGroupIds> getUserGroups(String user) throws Exception {
|
public static IMResult<OutputGroupIds> getUserGroups(String user) throws Exception {
|
||||||
String path = APIPath.Get_User_Groups;
|
String path = APIPath.Get_User_Groups;
|
||||||
InputUserId inputUserId = new InputUserId();
|
InputUserId inputUserId = new InputUserId();
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import static cn.wildfirechat.proto.ProtoConstants.ChannelState.*;
|
|||||||
import static cn.wildfirechat.proto.ProtoConstants.SystemSettingType.Group_Max_Member_Count;
|
import static cn.wildfirechat.proto.ProtoConstants.SystemSettingType.Group_Max_Member_Count;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
private static boolean commercialServer = false;
|
private static boolean commercialServer = true;
|
||||||
private static boolean advanceVoip = false;
|
private static boolean advanceVoip = false;
|
||||||
private static boolean robotMomentsEnabled = false;
|
private static boolean robotMomentsEnabled = false;
|
||||||
private static boolean momentsEnabled = false;
|
private static boolean momentsEnabled = false;
|
||||||
@@ -58,6 +58,9 @@ public class Main {
|
|||||||
//测试解析数据库中消息内容
|
//测试解析数据库中消息内容
|
||||||
testReadMessageContentFromDB();
|
testReadMessageContentFromDB();
|
||||||
|
|
||||||
|
//计算消息分表
|
||||||
|
testMessageSharding();
|
||||||
|
|
||||||
//Robot和Channel都是使用的80端口,第三方可以创建或者为第三方创建,第三方可以使用robot或者channel与IM系统进行对接。
|
//Robot和Channel都是使用的80端口,第三方可以创建或者为第三方创建,第三方可以使用robot或者channel与IM系统进行对接。
|
||||||
testRobot();
|
testRobot();
|
||||||
testChannel();
|
testChannel();
|
||||||
@@ -616,7 +619,7 @@ public class Main {
|
|||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
voidIMResult = GroupAdmin.setGroupMemberAlias("user1", groupInfo.getTarget_id(), "user3", "test user3", null, null);
|
voidIMResult = GroupAdmin.setGroupMemberAlias("user1", groupInfo.getTarget_id(), "user2", "test user2", null, null);
|
||||||
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
System.out.println("set group member alias success");
|
System.out.println("set group member alias success");
|
||||||
} else {
|
} else {
|
||||||
@@ -1003,13 +1006,24 @@ public class Main {
|
|||||||
testStreamingText(sender, conversation);
|
testStreamingText(sender, conversation);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void testReadMessageContentFromDB() throws Exception {
|
//消息相关表分为2类,分表是:t_messages_x和t_user_messages_y,并且是分表存储的。表内存储数据和分表规则请参考 https://docs.wildfirechat.cn/faq/server.html 问题2
|
||||||
//需要注意几点:
|
static void testMessageSharding() {
|
||||||
// 1 WFCMessage类不能混淆,如果混淆 WFCMessage.MessageContent.parseFrom(data) 就会失败。
|
String userId = "user1";
|
||||||
// 2 MessageContentFactory方法会自动查找所有的消息类,包括文本/图片/语音等。也有可能在某些环境下找不到这些类。可以检查MessageContentFactory
|
int hashId = Math.abs(userId.hashCode())%128;
|
||||||
// 类的源码,修改registerAllMessageContent方法,确保能找到所有的内容类。也可以显式调用注册的方法把所有已知消息都注册一遍,比如:
|
String userMessageTable = "t_user_messages_" + hashId;
|
||||||
// MessageContentFactory.registerCustomMessageContent(TextMessageContent.class); //这里示例只写了文本的,其他所有已知消息都需要注册一遍。
|
System.out.println("user:" + userId + " user messages table is " + userMessageTable);
|
||||||
|
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
Date date = new Date();
|
||||||
|
calendar.setTime(date);
|
||||||
|
int month = calendar.get(Calendar.MONTH);
|
||||||
|
int year = calendar.get(Calendar.YEAR);
|
||||||
|
year %= 3;
|
||||||
|
String messageTable = "t_messages_" + (year * 12 + month);
|
||||||
|
System.out.println("This month save message to table " + messageTable);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void testReadMessageContentFromDB() throws Exception {
|
||||||
//从数据库t_messages_x表中读取到消息内容字段_data的二进制数据为
|
//从数据库t_messages_x表中读取到消息内容字段_data的二进制数据为
|
||||||
byte[] data = {8,1,18,5,72,101,108,108,111,64,3};
|
byte[] data = {8,1,18,5,72,101,108,108,111,64,3};
|
||||||
//1. 先把二进制数据转化为协议栈消息内容。
|
//1. 先把二进制数据转化为协议栈消息内容。
|
||||||
@@ -1399,6 +1413,7 @@ public class Main {
|
|||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//使用完需要释放
|
||||||
RobotService robotService = new RobotService(IMUrl, robotId, robotSecret);
|
RobotService robotService = new RobotService(IMUrl, robotId, robotSecret);
|
||||||
|
|
||||||
//***********************************************
|
//***********************************************
|
||||||
@@ -1605,7 +1620,7 @@ public class Main {
|
|||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
voidIMResult = robotService.setGroupMemberAlias(groupInfo.getTarget_id(), "user3", "test user3", null, null);
|
voidIMResult = robotService.setGroupMemberAlias(groupInfo.getTarget_id(), "user2", "test user2", null, null);
|
||||||
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
System.out.println("set group member alias success");
|
System.out.println("set group member alias success");
|
||||||
} else {
|
} else {
|
||||||
@@ -1798,6 +1813,9 @@ public class Main {
|
|||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//使用完需要释放
|
||||||
|
robotService.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
//***测试频道API功能,仅专业版支持***
|
//***测试频道API功能,仅专业版支持***
|
||||||
@@ -1868,7 +1886,7 @@ public class Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//2. 初始化api,注意端口是80,不是18080
|
//2. 初始化api,注意端口是80,不是18080 //使用完需要释放
|
||||||
ChannelServiceApi channelServiceApi = new ChannelServiceApi(IMUrl, channelId, secret);
|
ChannelServiceApi channelServiceApi = new ChannelServiceApi(IMUrl, channelId, secret);
|
||||||
|
|
||||||
|
|
||||||
@@ -2024,6 +2042,9 @@ public class Main {
|
|||||||
}
|
}
|
||||||
OutputApplicationConfigData config = channelServiceApi.getApplicationSignature();
|
OutputApplicationConfigData config = channelServiceApi.getApplicationSignature();
|
||||||
System.out.println(config);
|
System.out.println(config);
|
||||||
|
|
||||||
|
//使用完需要释放
|
||||||
|
channelServiceApi.close();
|
||||||
}
|
}
|
||||||
static void testSensitiveApi() throws Exception {
|
static void testSensitiveApi() throws Exception {
|
||||||
List<String> words = Arrays.asList("a","b","c");
|
List<String> words = Arrays.asList("a","b","c");
|
||||||
|
|||||||
@@ -227,4 +227,10 @@ public class MeshAdmin {
|
|||||||
return AdminHttpUtils.httpJsonPost(path, event, Void.class);
|
return AdminHttpUtils.httpJsonPost(path, event, Void.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IMResult<PojoDomainPingResponse> pingDomain(String domainId) throws Exception {
|
||||||
|
String path = APIPath.Ping_Domain;
|
||||||
|
PojoDomainPingRequest request = new PojoDomainPingRequest();
|
||||||
|
request.domainId = domainId;
|
||||||
|
return AdminHttpUtils.httpJsonPost(path, request, PojoDomainPingResponse.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,14 +11,21 @@ public class MessageAdmin {
|
|||||||
public static IMResult<SendMessageResult> sendMessage(String sender, Conversation conversation, MessagePayload payload) throws Exception {
|
public static IMResult<SendMessageResult> sendMessage(String sender, Conversation conversation, MessagePayload payload) throws Exception {
|
||||||
return sendMessage(sender, conversation, payload, null);
|
return sendMessage(sender, conversation, payload, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
//toUsers为发送给会话中部分用户用的,正常为null,仅当需要指定群/频道/聊天室中部分接收用户时使用
|
//toUsers为发送给会话中部分用户用的,正常为null,仅当需要指定群/频道/聊天室中部分接收用户时使用
|
||||||
public static IMResult<SendMessageResult> sendMessage(String sender, Conversation conversation, MessagePayload payload, List<String> toUsers) throws Exception {
|
public static IMResult<SendMessageResult> sendMessage(String sender, Conversation conversation, MessagePayload payload, List<String> toUsers) throws Exception {
|
||||||
|
return sendMessage(sender, conversation, payload, toUsers, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
//toUsers为发送给会话中部分用户用的,正常为null,仅当需要指定群/频道/聊天室中部分接收用户时使用
|
||||||
|
public static IMResult<SendMessageResult> sendMessage(String sender, Conversation conversation, MessagePayload payload, List<String> toUsers, boolean isUserMessage) throws Exception {
|
||||||
String path = APIPath.Msg_Send;
|
String path = APIPath.Msg_Send;
|
||||||
SendMessageData messageData = new SendMessageData();
|
SendMessageData messageData = new SendMessageData();
|
||||||
messageData.setSender(sender);
|
messageData.setSender(sender);
|
||||||
messageData.setConv(conversation);
|
messageData.setConv(conversation);
|
||||||
messageData.setPayload(payload);
|
messageData.setPayload(payload);
|
||||||
messageData.setToUsers(toUsers);
|
messageData.setToUsers(toUsers);
|
||||||
|
messageData.setUserMessage(isUserMessage);
|
||||||
if (payload.getType() == 1 && (payload.getSearchableContent() == null || payload.getSearchableContent().isEmpty())) {
|
if (payload.getType() == 1 && (payload.getSearchableContent() == null || payload.getSearchableContent().isEmpty())) {
|
||||||
System.out.println("Payload错误,Payload格式应该跟客户端消息encode出来的Payload对齐,这样客户端才能正确识别。比如文本消息,文本需要放到searchableContent属性。请与客户端同事确认Payload的格式,或则去 https://gitee.com/wfchat/android-chat/tree/master/client/src/main/java/cn/wildfirechat/message 找到消息encode的实现方法!");
|
System.out.println("Payload错误,Payload格式应该跟客户端消息encode出来的Payload对齐,这样客户端才能正确识别。比如文本消息,文本需要放到searchableContent属性。请与客户端同事确认Payload的格式,或则去 https://gitee.com/wfchat/android-chat/tree/master/client/src/main/java/cn/wildfirechat/message 找到消息encode的实现方法!");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,11 +8,13 @@ import cn.wildfirechat.sdk.model.IMResult;
|
|||||||
import cn.wildfirechat.sdk.utilities.RobotHttpUtils;
|
import cn.wildfirechat.sdk.utilities.RobotHttpUtils;
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static cn.wildfirechat.proto.ProtoConstants.ApplicationType.ApplicationType_Robot;
|
import static cn.wildfirechat.proto.ProtoConstants.ApplicationType.ApplicationType_Robot;
|
||||||
|
|
||||||
public class RobotService {
|
public class RobotService implements Closeable {
|
||||||
private final RobotHttpUtils robotHttpUtils;
|
private final RobotHttpUtils robotHttpUtils;
|
||||||
|
|
||||||
public RobotService(String url, String robotId, String robotSecret) {
|
public RobotService(String url, String robotId, String robotSecret) {
|
||||||
@@ -37,6 +39,15 @@ public class RobotService {
|
|||||||
return robotHttpUtils.httpJsonPost(path, messageData, SendMessageResult.class);
|
return robotHttpUtils.httpJsonPost(path, messageData, SendMessageResult.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IMResult<SendMessageResult> replyMessage(long messageUid, MessagePayload payload, boolean only2Sender) throws Exception {
|
||||||
|
String path = APIPath.Robot_Message_Reply;
|
||||||
|
ReplyMessageData messageData = new ReplyMessageData();
|
||||||
|
messageData.setMessageUid(messageUid);
|
||||||
|
messageData.setOnly2Sender(only2Sender);
|
||||||
|
messageData.setPayload(payload);
|
||||||
|
return robotHttpUtils.httpJsonPost(path, messageData, SendMessageResult.class);
|
||||||
|
}
|
||||||
|
|
||||||
public IMResult<String> recallMessage(long messageUid) throws Exception {
|
public IMResult<String> recallMessage(long messageUid) throws Exception {
|
||||||
String path = APIPath.Robot_Message_Recall;
|
String path = APIPath.Robot_Message_Recall;
|
||||||
RecallMessageData messageData = new RecallMessageData();
|
RecallMessageData messageData = new RecallMessageData();
|
||||||
@@ -423,4 +434,9 @@ public class RobotService {
|
|||||||
requestPojo.rl = removeList;
|
requestPojo.rl = removeList;
|
||||||
return robotHttpUtils.httpJsonPost(path, requestPojo, Void.class);
|
return robotHttpUtils.httpJsonPost(path, requestPojo, Void.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() throws IOException {
|
||||||
|
robotHttpUtils.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,34 +41,36 @@ public class AdminHttpUtils extends JsonUtils {
|
|||||||
init(url, secret, 15000);
|
init(url, secret, 15000);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void init(String url, String secret, int timeout) {
|
public static synchronized void init(String url, String secret, int timeout) {
|
||||||
adminUrl = url.trim();
|
adminUrl = url.trim();
|
||||||
adminSecret = secret.trim();
|
adminSecret = secret.trim();
|
||||||
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
|
if(httpClient == null) {
|
||||||
cm.setValidateAfterInactivity(1000);
|
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
|
||||||
int connectTimeout = 15000; // 连接超时时间
|
cm.setValidateAfterInactivity(1000);
|
||||||
int connectionRequestTimeout = 3000; // 从连接池获取连接的超时时间
|
int connectTimeout = 15000; // 连接超时时间
|
||||||
RequestConfig requestConfig = RequestConfig.custom()
|
int connectionRequestTimeout = 3000; // 从连接池获取连接的超时时间
|
||||||
.setConnectTimeout(connectTimeout)
|
RequestConfig requestConfig = RequestConfig.custom()
|
||||||
.setSocketTimeout(timeout)
|
.setConnectTimeout(connectTimeout)
|
||||||
.setConnectionRequestTimeout(connectionRequestTimeout)
|
.setSocketTimeout(timeout)
|
||||||
.build();
|
.setConnectionRequestTimeout(connectionRequestTimeout)
|
||||||
|
.build();
|
||||||
|
|
||||||
httpClient = HttpClients.custom()
|
httpClient = HttpClients.custom()
|
||||||
.setDefaultRequestConfig(requestConfig)
|
.setDefaultRequestConfig(requestConfig)
|
||||||
.setConnectionManager(cm)
|
.setConnectionManager(cm)
|
||||||
.evictExpiredConnections()
|
.evictExpiredConnections()
|
||||||
.evictIdleConnections(60L, TimeUnit.SECONDS)
|
.evictIdleConnections(60L, TimeUnit.SECONDS)
|
||||||
.setRetryHandler(DefaultHttpRequestRetryHandler.INSTANCE)
|
.setRetryHandler(DefaultHttpRequestRetryHandler.INSTANCE)
|
||||||
.setMaxConnTotal(100)
|
.setMaxConnTotal(100)
|
||||||
.setMaxConnPerRoute(50)
|
.setMaxConnPerRoute(50)
|
||||||
.build();
|
.build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> IMResult<T> httpGet(String path, Class<T> clazz) throws Exception {
|
public static <T> IMResult<T> httpGet(String path, Class<T> clazz) throws Exception {
|
||||||
if (isNullOrEmpty(adminUrl) || isNullOrEmpty(adminSecret)) {
|
if (isNullOrEmpty(adminUrl) || isNullOrEmpty(adminSecret)) {
|
||||||
LOG.error("野火IM Server SDK必须先初始化才能使用,是不是忘记初始化了!!!!");
|
LOG.error("野火IM Server SDK必须先初始化才能使用,是不是忘记初始化了!请调用AdminConfig.initAdmin(AdminUrl, AdminSecret);进行初始化");
|
||||||
throw new Exception("SDK没有初始化");
|
throw new Exception("SDK没有初始化,请调用AdminConfig.initAdmin(AdminUrl, AdminSecret);进行初始化");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNullOrEmpty(path)) {
|
if (isNullOrEmpty(path)) {
|
||||||
@@ -114,8 +116,8 @@ public class AdminHttpUtils extends JsonUtils {
|
|||||||
|
|
||||||
public static <T> IMResult<T> httpJsonPost(String path, Object object, Class<T> clazz) throws Exception {
|
public static <T> IMResult<T> httpJsonPost(String path, Object object, Class<T> clazz) throws Exception {
|
||||||
if (isNullOrEmpty(adminUrl) || isNullOrEmpty(adminSecret)) {
|
if (isNullOrEmpty(adminUrl) || isNullOrEmpty(adminSecret)) {
|
||||||
LOG.error("野火IM Server SDK必须先初始化才能使用,是不是忘记初始化了!!!!");
|
LOG.error("野火IM Server SDK必须先初始化才能使用,是不是忘记初始化了!请调用AdminConfig.initAdmin(AdminUrl, AdminSecret);进行初始化");
|
||||||
throw new Exception("SDK没有初始化");
|
throw new Exception("SDK没有初始化,请调用AdminConfig.initAdmin(AdminUrl, AdminSecret);进行初始化");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNullOrEmpty(path)) {
|
if (isNullOrEmpty(path)) {
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
import java.io.Closeable;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
@@ -28,7 +30,7 @@ import java.nio.charset.Charset;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
|
||||||
public class ChannelHttpUtils extends JsonUtils {
|
public class ChannelHttpUtils extends JsonUtils implements Closeable {
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(ChannelHttpUtils.class);
|
private static final Logger LOG = LoggerFactory.getLogger(ChannelHttpUtils.class);
|
||||||
public static final Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
public static final Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
||||||
|
|
||||||
@@ -40,7 +42,7 @@ public class ChannelHttpUtils extends JsonUtils {
|
|||||||
private final int port;
|
private final int port;
|
||||||
|
|
||||||
private void checkPort() {
|
private void checkPort() {
|
||||||
if (port != 80 && port != 443) {
|
if (port != 80 && port != 443 && port != -1) {
|
||||||
if (port == 18080) {
|
if (port == 18080) {
|
||||||
LOG.warn("您传入的频道API地址中的端口是18080,18080端口默认为管理API端口,频道API端口应该为IM服务的HTTP端口,默认为80,请确认是否使用错误!");
|
LOG.warn("您传入的频道API地址中的端口是18080,18080端口默认为管理API端口,频道API端口应该为IM服务的HTTP端口,默认为80,请确认是否使用错误!");
|
||||||
} else {
|
} else {
|
||||||
@@ -54,8 +56,12 @@ public class ChannelHttpUtils extends JsonUtils {
|
|||||||
this.channelId = channelId.trim();
|
this.channelId = channelId.trim();
|
||||||
this.channelSecret = secret.trim();
|
this.channelSecret = secret.trim();
|
||||||
try {
|
try {
|
||||||
URL url = new URL(this.imurl);
|
URL u = new URL(this.imurl);
|
||||||
this.port = url.getPort();
|
int port = u.getPort();
|
||||||
|
if(port == -1) {
|
||||||
|
port = u.getDefaultPort();
|
||||||
|
}
|
||||||
|
this.port = port;
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
@@ -156,4 +162,9 @@ public class ChannelHttpUtils extends JsonUtils {
|
|||||||
public String getChannelSecret() {
|
public String getChannelSecret() {
|
||||||
return channelSecret;
|
return channelSecret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() throws IOException {
|
||||||
|
httpClient.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,29 +3,35 @@ package cn.wildfirechat.sdk.utilities;
|
|||||||
import cn.wildfirechat.sdk.model.IMResult;
|
import cn.wildfirechat.sdk.model.IMResult;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
|
import ikidou.reflect.TypeBuilder;
|
||||||
import io.netty.util.internal.StringUtil;
|
import io.netty.util.internal.StringUtil;
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.http.HttpStatus;
|
||||||
|
import org.apache.http.client.HttpClient;
|
||||||
import org.apache.http.client.config.RequestConfig;
|
import org.apache.http.client.config.RequestConfig;
|
||||||
import org.apache.http.client.methods.HttpPost;
|
import org.apache.http.client.methods.HttpPost;
|
||||||
import org.apache.http.entity.StringEntity;
|
import org.apache.http.entity.StringEntity;
|
||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
import org.apache.http.impl.client.DefaultHttpRequestRetryHandler;
|
import org.apache.http.impl.client.DefaultHttpRequestRetryHandler;
|
||||||
|
import org.apache.http.impl.client.HttpClientBuilder;
|
||||||
import org.apache.http.impl.client.HttpClients;
|
import org.apache.http.impl.client.HttpClients;
|
||||||
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
import java.io.Closeable;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
|
||||||
public class RobotHttpUtils extends JsonUtils {
|
public class RobotHttpUtils extends JsonUtils implements Closeable {
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(RobotHttpUtils.class);
|
private static final Logger LOG = LoggerFactory.getLogger(RobotHttpUtils.class);
|
||||||
public static final Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
public static final Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
||||||
|
|
||||||
@@ -37,7 +43,7 @@ public class RobotHttpUtils extends JsonUtils {
|
|||||||
private final int port;
|
private final int port;
|
||||||
|
|
||||||
private void checkPort() {
|
private void checkPort() {
|
||||||
if (port != 80 && port != 443) {
|
if (port != 80 && port != 443 && port != -1) {
|
||||||
if (port == 18080) {
|
if (port == 18080) {
|
||||||
LOG.warn("您传入的机器人API地址中的端口是18080,18080端口默认为管理API端口,机器人API端口应该为IM服务的HTTP端口,默认为80,请确认是否使用错误!");
|
LOG.warn("您传入的机器人API地址中的端口是18080,18080端口默认为管理API端口,机器人API端口应该为IM服务的HTTP端口,默认为80,请确认是否使用错误!");
|
||||||
} else {
|
} else {
|
||||||
@@ -52,7 +58,11 @@ public class RobotHttpUtils extends JsonUtils {
|
|||||||
this.robotSecret = robotSecret.trim();
|
this.robotSecret = robotSecret.trim();
|
||||||
try {
|
try {
|
||||||
URL u = new URL(this.url);
|
URL u = new URL(this.url);
|
||||||
this.port = u.getPort();
|
int port = u.getPort();
|
||||||
|
if(port == -1) {
|
||||||
|
port = u.getDefaultPort();
|
||||||
|
}
|
||||||
|
this.port = port;
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
@@ -78,6 +88,7 @@ public class RobotHttpUtils extends JsonUtils {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public <T> IMResult<T> httpJsonPost(String path, Object object, Class<T> clazz) throws Exception{
|
public <T> IMResult<T> httpJsonPost(String path, Object object, Class<T> clazz) throws Exception{
|
||||||
if (isNullOrEmpty(url) || isNullOrEmpty(path)) {
|
if (isNullOrEmpty(url) || isNullOrEmpty(path)) {
|
||||||
LOG.error("Not init IM SDK correctly. Do you forget init it?");
|
LOG.error("Not init IM SDK correctly. Do you forget init it?");
|
||||||
@@ -154,4 +165,9 @@ public class RobotHttpUtils extends JsonUtils {
|
|||||||
public String getRobotSecret() {
|
public String getRobotSecret() {
|
||||||
return robotSecret;
|
return robotSecret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() throws IOException {
|
||||||
|
httpClient.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user