Compare commits

...
10 Commits
27 changed files with 195 additions and 91 deletions
+1 -1
View File
@@ -111,7 +111,7 @@ message.disable_remote_search false
##如果要避免数据库中明文存储消息内容,请打开这个开关和message.disable_remote_search开关
message.encrypt_message_content false
##允许客户端撤回用户自己发送的消息时限,单位是秒。
##允许客户端撤回用户自己发送的消息时限,单位是秒。0是不允许撤回;-1是无限制撤回。
##Server API不受此限制,可以撤回任意时限内的消息
##群组管理员或群主撤回群成员消息不受此限制,可以撤回任意时限内的消息。但管理员或群主撤回自己的消息还是需要准守此时间限制。
##修改此参数需要同步修改客户端UI,客户端UI代码有判断撤回是否显示的逻辑。
+1
View File
@@ -0,0 +1 @@
CREATE INDEX `user_gid_mid_dt_index` ON `t_group_member` (`_gid`, `_mid`, `_dt`);
+1
View File
@@ -0,0 +1 @@
CREATE INDEX `user_gid_mid_dt_index` ON `t_group_member` (`_gid`, `_mid`, `_dt`);
+1 -1
View File
@@ -5,7 +5,7 @@
<relativePath>../</relativePath>
<artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId>
<version>1.3.5</version>
<version>1.3.6</version>
</parent>
<artifactId>moquette-broker</artifactId>
@@ -51,14 +51,7 @@ public class AliasPutAction extends AdminAction {
ByteBuf byteBuf = Unpooled.buffer();
byteBuf.writeBytes(result);
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
byte[] data = new byte[byteBuf.readableBytes()];
byteBuf.readBytes(data);
String channelId = new String(data);
return new Result(ErrorCode.ERROR_CODE_SUCCESS, new OutputCreateChannel(channelId));
} else {
return new Result(errorCode);
}
return new Result(errorCode);
});
return false;
} else {
@@ -53,8 +53,11 @@ public class CreateChannelAction extends AdminAction {
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
byte[] data = new byte[byteBuf.readableBytes()];
byteBuf.readBytes(data);
String channelId = new String(data);
return new Result(ErrorCode.ERROR_CODE_SUCCESS, new OutputCreateChannel(channelId));
String str = new String(data);
String[] ss = str.split("\\|");
String channelId = ss[0];
String secret = ss[1];
return new Result(ErrorCode.ERROR_CODE_SUCCESS, new OutputCreateChannel(channelId, secret));
} else {
return new Result(errorCode);
}
@@ -20,6 +20,7 @@ import io.netty.handler.codec.http.FullHttpRequest;
import cn.wildfirechat.common.ErrorCode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import win.liyufan.im.GitRepositoryState;
import win.liyufan.im.IMTopic;
import java.util.Base64;
@@ -53,7 +54,7 @@ public class GetIMTokenAction extends AdminAction {
LOG.info("get im token success {},{},{}", userId, input.getClientId(), token.substring(0, Math.min(10, token.length())));
return new Result(errorCode1, new OutputGetIMTokenData(userId, token));
return new Result(errorCode1, new OutputGetIMTokenData(userId, token, GitRepositoryState.globalLabel));
} else {
return new Result(errorCode1);
}
@@ -16,6 +16,7 @@ import io.netty.buffer.ByteBuf;
import cn.wildfirechat.common.ErrorCode;
import win.liyufan.im.IMTopic;
import static cn.wildfirechat.proto.ProtoConstants.RequestSourceType.Request_From_Admin;
import static win.liyufan.im.IMTopic.PutUserSettingTopic;
import static win.liyufan.im.UserSettingScope.kUserSettingMyChannels;
@@ -42,7 +43,13 @@ public class CreateChannelHandler extends GroupHandler<WFCMessage.ChannelInfo> {
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
WFCMessage.ModifyUserSettingReq modifyUserSettingReq = WFCMessage.ModifyUserSettingReq.newBuilder().setScope(kUserSettingMyChannels).setKey(request.getTargetId()).setValue("1").build();
mServer.onApiMessage(fromUser, null, modifyUserSettingReq.toByteArray(), 0, fromUser, PutUserSettingTopic, requestSourceType);
byte[] data = request.getTargetId().getBytes();
byte[] data;
if (requestSourceType == Request_From_Admin) {
//When server api create channel, need return channelId and secret together.
data = (request.getTargetId() + "|" + request.getSecret()).getBytes();
} else {
data = request.getTargetId().getBytes();
}
ackPayload.ensureWritable(data.length).writeBytes(data);
return ErrorCode.ERROR_CODE_SUCCESS;
} else {
@@ -255,7 +255,7 @@ public class SendMessageHandler extends IMHandler<WFCMessage.Message> {
} else {
if(mRemoteSensitiveMessageTypes.contains(message.getContent().getType())) {
final WFCMessage.Message finalMsg = message;
publisher.forwardMessageWithCallback(message, mRemoteSensitiveServerUrl, clientID, new HttpUtils.HttpCallback() {
publisher.forwardMessageWithCallback(message, clientID, mRemoteSensitiveServerUrl, new HttpUtils.HttpCallback() {
@Override
public void onSuccess(String content) {
if(StringUtil.isNullOrEmpty(content)) {
@@ -1963,6 +1963,14 @@ public class MemoryMessagesStore implements IMessagesStore {
newInfoBuilder.setPrivateChat(Integer.parseInt(value));
else if(modifyType == Modify_Group_Searchable)
newInfoBuilder.setSearchable(Integer.parseInt(value));
else if(modifyType == Modify_Group_Type) {
int newType = Integer.parseInt(value);
if(newType < 0 || newType > ProtoConstants.GroupType.GroupType_Organization) {
LOG.error("modify group type failure, invalid group type {}", newType);
return ErrorCode.INVALID_PARAMETER;
}
newInfoBuilder.setType(newType);
}
else
return ErrorCode.INVALID_PARAMETER;
@@ -2480,7 +2488,7 @@ public class MemoryMessagesStore implements IMessagesStore {
}
boolean isExpired = false;
if (!canRecall && message.getFromUser().equals(operatorId)) {
if (mRecallTimeLimit > 0 && now - message.getServerTimestamp() > mRecallTimeLimit * 1000) {
if (mRecallTimeLimit >= 0 && now - message.getServerTimestamp() > mRecallTimeLimit * 1000) {
isExpired = true;
} else {
canRecall = true;
@@ -4484,7 +4492,7 @@ public class MemoryMessagesStore implements IMessagesStore {
} else if(modifyType == Modify_Channel_Menu) {
OutputGetChannelInfo.OutputMenuList outputMenuButtons = GsonUtil.gson.fromJson(value, OutputGetChannelInfo.OutputMenuList.class);
if (!outputMenuButtons.isEmpty()) {
for (OutputGetChannelInfo.OutputMenu outputMenuButton : outputMenuButtons) {
for (PojoChannelMenu outputMenuButton : outputMenuButtons) {
newInfoBuilder.addMenu(outputMenuButton.toPbInfo());
}
}
@@ -12,6 +12,7 @@ import io.moquette.server.Server;
import java.io.*;
import java.util.Properties;
import java.util.UUID;
public class GitRepositoryState {
public final String tags;
@@ -28,6 +29,8 @@ public class GitRepositoryState {
public final String commitMessageFull;
public final String commitMessageShort;
public final String commitTime;
public static final String globalLabel = UUID.randomUUID().toString();
public String label;
public final String closestTagName;
public final String closestTagCommitCount;
@@ -63,6 +66,7 @@ public class GitRepositoryState {
this.buildHost = String.valueOf(properties.get("git.build.host"));
this.buildVersion = String.valueOf(properties.get("git.build.version"));
this.runTime = Server.getServer().getRunTime();
this.label = globalLabel;
}
public static GitRepositoryState getGitRepositoryState() throws IOException {
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId>
<version>1.3.5</version>
<version>1.3.6</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -12,6 +12,9 @@ package cn.wildfirechat.pojos;
import cn.wildfirechat.proto.WFCMessage;
import io.netty.util.internal.StringUtil;
import java.util.ArrayList;
import java.util.List;
public class InputCreateChannel {
private String owner;
private String name;
@@ -24,6 +27,7 @@ public class InputCreateChannel {
private int state;
private String extra;
private long updateDt;
public List<PojoChannelMenu> menus;
public WFCMessage.ChannelInfo toProtoChannelInfo() {
WFCMessage.ChannelInfo.Builder builder = WFCMessage.ChannelInfo.newBuilder().setOwner(owner);
@@ -48,6 +52,12 @@ public class InputCreateChannel {
else
builder = builder.setUpdateDt(System.currentTimeMillis());
if (menus != null && !menus.isEmpty()) {
for (PojoChannelMenu menu : menus) {
builder.addMenu(menu.toPbInfo());
}
}
return builder.build();
}
@@ -13,9 +13,11 @@ import cn.wildfirechat.proto.WFCMessage;
public class OutputCreateChannel {
private String targetId;
private String secret;
public OutputCreateChannel(String targetId) {
public OutputCreateChannel(String targetId, String secret) {
this.targetId = targetId;
this.secret = secret;
}
public String getTargetId() {
@@ -25,4 +27,12 @@ public class OutputCreateChannel {
public void setTargetId(String targetId) {
this.targetId = targetId;
}
public String getSecret() {
return secret;
}
public void setSecret(String secret) {
this.secret = secret;
}
}
@@ -16,61 +16,7 @@ import java.util.ArrayList;
import java.util.List;
public class OutputGetChannelInfo {
public static class OutputMenu {
public String menuId;
public String type;
public String name;
public String key;
public String url;
public String mediaId;
public String articleId;
public String appId;
public String appPage;
public String extra;
public List<OutputMenu> subMenus;
public static OutputMenu fromPbInfo(WFCMessage.ChannelMenu channelMenuMenu) {
OutputMenu out = new OutputMenu();
out.menuId = channelMenuMenu.getMenuId();
out.type = channelMenuMenu.getType();
out.name = channelMenuMenu.getName();
out.key = channelMenuMenu.getKey();
out.url = channelMenuMenu.getUrl();
out.mediaId = channelMenuMenu.getMediaId();
out.articleId = channelMenuMenu.getArticleId();
out.appId = channelMenuMenu.getAppId();
out.appPage = channelMenuMenu.getAppPage();
out.extra = channelMenuMenu.getExtra();
if (channelMenuMenu.getSubMenuCount() > 0) {
out.subMenus = new ArrayList<>();
for (WFCMessage.ChannelMenu menuMenu : channelMenuMenu.getSubMenuList()) {
out.subMenus.add(fromPbInfo(menuMenu));
}
}
return out;
}
public WFCMessage.ChannelMenu.Builder toPbInfo() {
WFCMessage.ChannelMenu.Builder builder = WFCMessage.ChannelMenu.newBuilder();
builder.setType(type);
builder.setName(name);
if (!StringUtil.isNullOrEmpty(menuId)) builder.setMenuId(menuId);
if (!StringUtil.isNullOrEmpty(key)) builder.setKey(key);
if (!StringUtil.isNullOrEmpty(url)) builder.setUrl(url);
if (!StringUtil.isNullOrEmpty(mediaId)) builder.setMediaId(mediaId);
if (!StringUtil.isNullOrEmpty(articleId)) builder.setArticleId(articleId);
if (!StringUtil.isNullOrEmpty(appId)) builder.setAppId(appId);
if (!StringUtil.isNullOrEmpty(appPage)) builder.setAppPage(appPage);
if (!StringUtil.isNullOrEmpty(extra)) builder.setExtra(extra);
if (subMenus != null && !subMenus.isEmpty()) {
subMenus.forEach(menuMenu -> builder.addSubMenu(menuMenu.toPbInfo()));
}
return builder;
}
}
public static class OutputMenuList extends ArrayList<OutputMenu> {
public static class OutputMenuList extends ArrayList<PojoChannelMenu> {
}
private String channelId;
@@ -85,7 +31,7 @@ public class OutputGetChannelInfo {
private String callback;
private int automatic;
private String secret;
public List<OutputMenu> menus;
public List<PojoChannelMenu> menus;
public String getChannelId() {
return channelId;
@@ -200,7 +146,7 @@ public class OutputGetChannelInfo {
if (channelInfo.getMenuCount() > 0) {
out.menus = new ArrayList<>();
for (WFCMessage.ChannelMenu channelMenuMenu : channelInfo.getMenuList()) {
out.menus.add(OutputMenu.fromPbInfo(channelMenuMenu));
out.menus.add(PojoChannelMenu.fromPbInfo(channelMenuMenu));
}
}
return out;
@@ -3,13 +3,15 @@ package cn.wildfirechat.pojos;
public class OutputGetIMTokenData {
private String userId;
private String token;
private String serverLabel;
public OutputGetIMTokenData() {
}
public OutputGetIMTokenData(String userId, String imToken) {
public OutputGetIMTokenData(String userId, String imToken, String label) {
this.userId = userId;
this.token = imToken;
this.serverLabel = label;
}
public String getUserId() {
@@ -27,4 +29,12 @@ public class OutputGetIMTokenData {
public void setToken(String token) {
this.token = token;
}
public String getServerLabel() {
return serverLabel;
}
public void setServerLabel(String serverLabel) {
this.serverLabel = serverLabel;
}
}
@@ -0,0 +1,60 @@
package cn.wildfirechat.pojos;
import cn.wildfirechat.proto.WFCMessage;
import io.netty.util.internal.StringUtil;
import java.util.ArrayList;
import java.util.List;
public class PojoChannelMenu {
public String menuId;
public String type;
public String name;
public String key;
public String url;
public String mediaId;
public String articleId;
public String appId;
public String appPage;
public String extra;
public List<PojoChannelMenu> subMenus;
public static PojoChannelMenu fromPbInfo(WFCMessage.ChannelMenu channelMenuMenu) {
PojoChannelMenu out = new PojoChannelMenu();
out.menuId = channelMenuMenu.getMenuId();
out.type = channelMenuMenu.getType();
out.name = channelMenuMenu.getName();
out.key = channelMenuMenu.getKey();
out.url = channelMenuMenu.getUrl();
out.mediaId = channelMenuMenu.getMediaId();
out.articleId = channelMenuMenu.getArticleId();
out.appId = channelMenuMenu.getAppId();
out.appPage = channelMenuMenu.getAppPage();
out.extra = channelMenuMenu.getExtra();
if (channelMenuMenu.getSubMenuCount() > 0) {
out.subMenus = new ArrayList<>();
for (WFCMessage.ChannelMenu menuMenu : channelMenuMenu.getSubMenuList()) {
out.subMenus.add(fromPbInfo(menuMenu));
}
}
return out;
}
public WFCMessage.ChannelMenu.Builder toPbInfo() {
WFCMessage.ChannelMenu.Builder builder = WFCMessage.ChannelMenu.newBuilder();
builder.setType(type);
builder.setName(name);
if (!StringUtil.isNullOrEmpty(menuId)) builder.setMenuId(menuId);
if (!StringUtil.isNullOrEmpty(key)) builder.setKey(key);
if (!StringUtil.isNullOrEmpty(url)) builder.setUrl(url);
if (!StringUtil.isNullOrEmpty(mediaId)) builder.setMediaId(mediaId);
if (!StringUtil.isNullOrEmpty(articleId)) builder.setArticleId(articleId);
if (!StringUtil.isNullOrEmpty(appId)) builder.setAppId(appId);
if (!StringUtil.isNullOrEmpty(appPage)) builder.setAppPage(appPage);
if (!StringUtil.isNullOrEmpty(extra)) builder.setExtra(extra);
if (subMenus != null && !subMenus.isEmpty()) {
subMenus.forEach(menuMenu -> builder.addSubMenu(menuMenu.toPbInfo()));
}
return builder;
}
}
@@ -172,6 +172,7 @@ public class ProtoConstants {
int Modify_Group_Max_Member_Count = 8;
//仅专业版的server api支持
int Modify_Group_Super_Group = 9;
int Modify_Group_Type = 10;
}
//ModifyGroupInfoRequest -> type
+1 -1
View File
@@ -6,7 +6,7 @@
<!--<relativePath>../pom.xml</relativePath>-->
<artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId>
<version>1.3.5</version>
<version>1.3.6</version>
</parent>
<artifactId>distribution</artifactId>
@@ -33,6 +33,8 @@ local_port 80
## MySQL需要把事物隔离级别改成"Read committed",使用命令来修改"set global transaction_isolation='read-committed';",其他数据库默认已经是这个级别不用修改
## 如果使用MySQL,请在c3p0.xml文件中配置JDBC信息。
## 如果是MySQL5.7,需要开启长索引的支持,在数据库中执行命令:"set global innodb_large_prefix=on;"。其他版本默认支持,不用修改。
## 如果使用MySQL 8.0.30以上版本,有个特性是创建表时如果没有主键将会自动创建一个主键"my_key_id",如果此功能打开,在执行mysql脚本V19__add_id_for_sensitive_word.sql时将会报错,提示不能2个主键。
## 解决办法就是运行出错后删除掉系统自动创建的主键"my_key_id",然后继续执行。
embed.db 1
## 是否自动清理历史消息记录,当为true时,IM服务会定时扫描t_messages_x和t_user_messages_x表,清除掉3年前的历史消息。
@@ -106,7 +108,7 @@ message.disable_remote_search false
##如果要避免数据库中明文存储消息内容,请打开这个开关和message.disable_remote_search开关
message.encrypt_message_content false
##允许客户端撤回用户自己发送的消息时限,单位是秒。
##允许客户端撤回用户自己发送的消息时限,单位是秒。0是不允许撤回;-1是无限制撤回。
##Server API不受此限制,可以撤回任意时限内的消息
##群组管理员或群主撤回群成员消息不受此限制,可以撤回任意时限内的消息。但管理员或群主撤回自己的消息还是需要准守此时间限制。
##修改此参数需要同步修改客户端UI,客户端UI代码有判断撤回是否显示的逻辑。
+1 -1
View File
@@ -12,7 +12,7 @@
<artifactId>wildfirechat-parent</artifactId>
<packaging>pom</packaging>
<version>1.3.5</version>
<version>1.3.6</version>
<name>Wildfire Chat</name>
<description>Wildfire Chat Server</description>
<inceptionYear>2019</inceptionYear>
+8
View File
@@ -12,6 +12,14 @@
# 更新记录
--------------
Release note 1.3.6:
1. Server API创建频道时,返回频道ID和频道密钥。
2. 解决外置审核替换内容没有成功的问题。
3. 修改撤回消息限制,可以运行不限制撤回。
4. 创建/更新频道接口可以传菜单参数。
5. Server API支持修改群组类型。
--------------
Release note 1.3.5:
1. 转发消息回调中可以配置带上发送者和目标信息。
+1 -1
View File
@@ -3,7 +3,7 @@
<parent>
<artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId>
<version>1.3.5</version>
<version>1.3.6</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -51,7 +51,7 @@ public class ChannelServiceApi {
return channelHttpUtils.httpJsonPost(path, null, OutputGetChannelInfo.class);
}
public IMResult<Void> modifyChannelMenu(List<OutputGetChannelInfo.OutputMenu> menus) throws Exception {
public IMResult<Void> modifyChannelMenu(List<PojoChannelMenu> menus) throws Exception {
String menuStr = new Gson().toJson(menus);
return modifyChannelInfo(ProtoConstants.ModifyChannelInfoType.Modify_Channel_Menu, menuStr);
}
@@ -1974,8 +1974,8 @@ public class Main {
System.exit(-1);
}
List<OutputGetChannelInfo.OutputMenu> menus = new ArrayList<>();
OutputGetChannelInfo.OutputMenu menu1 = new OutputGetChannelInfo.OutputMenu();
List<PojoChannelMenu> menus = new ArrayList<>();
PojoChannelMenu menu1 = new PojoChannelMenu();
menu1.menuId = UUID.randomUUID().toString();
menu1.type = "view";
menu1.name = "一级菜单1";
@@ -1983,7 +1983,7 @@ public class Main {
menu1.url = "http://www.baidu.com";
menus.add(menu1);
OutputGetChannelInfo.OutputMenu menu2 = new OutputGetChannelInfo.OutputMenu();
PojoChannelMenu menu2 = new PojoChannelMenu();
menu2.menuId = UUID.randomUUID().toString();
menu2.type = "view";
menu2.name = "一级菜单2";
@@ -1992,7 +1992,7 @@ public class Main {
menu2.subMenus = new ArrayList<>();
menus.add(menu2);
OutputGetChannelInfo.OutputMenu menu21 = new OutputGetChannelInfo.OutputMenu();
PojoChannelMenu menu21 = new PojoChannelMenu();
menu21.menuId = UUID.randomUUID().toString();
menu21.type = "click";
menu21.name = "二级菜单21";
@@ -22,6 +22,8 @@ import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.concurrent.TimeUnit;
@@ -35,10 +37,29 @@ public class ChannelHttpUtils extends JsonUtils {
private String channelSecret;
private final CloseableHttpClient httpClient;
private final int port;
private void checkPort() {
if (port != 80 && port != 443) {
if (port == 18080) {
LOG.warn("您传入的频道API地址中的端口是18080,18080端口默认为管理API端口,频道API端口应该为IM服务的HTTP端口,默认为80,请确认是否使用错误!");
} else {
LOG.warn("您传入的频道API地址中的端口不是80/443,频道API的端口和客户端使用端口一样,都应该为IM服务的HTTP端口,默认为80,请确实是否正确?如果您定制化了IM服务端口或者使用其他端口反向代理IM服务的HTTP端口请忽略此提示。");
}
}
}
public ChannelHttpUtils(String imurl, String channelId, String secret) {
this.imurl = imurl.trim();
this.channelId = channelId.trim();
this.channelSecret = secret.trim();
try {
URL url = new URL(this.imurl);
this.port = url.getPort();
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
checkPort();
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
cm.setValidateAfterInactivity(1000);
int connectTimeout = 5000; // 连接超时时间
@@ -118,6 +139,7 @@ public class ChannelHttpUtils extends JsonUtils {
return fromJsonObject(content, clazz);
}
} catch (Exception e) {
checkPort();
e.printStackTrace();
throw e;
}finally{
@@ -3,18 +3,15 @@ package cn.wildfirechat.sdk.utilities;
import cn.wildfirechat.sdk.model.IMResult;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import ikidou.reflect.TypeBuilder;
import io.netty.util.internal.StringUtil;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
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.conn.PoolingHttpClientConnectionManager;
import org.slf4j.Logger;
@@ -22,7 +19,8 @@ import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.concurrent.TimeUnit;
@@ -36,10 +34,29 @@ public class RobotHttpUtils extends JsonUtils {
private final String robotSecret;
private final CloseableHttpClient httpClient;
private final int port;
private void checkPort() {
if (port != 80 && port != 443) {
if (port == 18080) {
LOG.warn("您传入的机器人API地址中的端口是18080,18080端口默认为管理API端口,机器人API端口应该为IM服务的HTTP端口,默认为80,请确认是否使用错误!");
} else {
LOG.warn("您传入的机器人API地址中的端口不是80/443,机器人API的端口和客户端使用端口一样,都应该为IM服务的HTTP端口,默认为80,请确实是否正确?如果您定制化了IM服务端口或者使用其他端口反向代理IM服务的HTTP端口请忽略此提示。");
}
}
}
public RobotHttpUtils(String url, String robotId, String robotSecret) {
this.url = url.trim();
this.robotId = robotId.trim();
this.robotSecret = robotSecret.trim();
try {
URL u = new URL(this.url);
this.port = u.getPort();
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
checkPort();
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
cm.setValidateAfterInactivity(1000);
int connectTimeout = 5000; // 连接超时时间
@@ -61,7 +78,6 @@ public class RobotHttpUtils extends JsonUtils {
.build();
}
public <T> IMResult<T> httpJsonPost(String path, Object object, Class<T> clazz) throws Exception{
if (isNullOrEmpty(url) || isNullOrEmpty(path)) {
LOG.error("Not init IM SDK correctly. Do you forget init it?");
@@ -121,6 +137,7 @@ public class RobotHttpUtils extends JsonUtils {
return fromJsonObject(content, clazz);
}
} catch (Exception e) {
checkPort();
e.printStackTrace();
throw e;
}finally{