Compare commits

...
26 Commits
Author SHA1 Message Date
heavyrian2012 2918c06a01 version 0.91 2022-08-03 12:41:35 +08:00
heavyrian2012 c3b9b9fccf 群组添加成员时,检查是否已经存在群组成员, fix issue #501 2022-08-03 12:19:03 +08:00
heavyrian2012 8c88d5a13f 添加注释 2022-07-29 20:37:53 +08:00
heavyrian2012 967526f5ec 添加发送消息payload错误时的提醒 2022-07-29 20:33:18 +08:00
heavyrian2012 109078abca 参数有效性检查 2022-07-29 20:24:41 +08:00
heavyrian2012 79a58e99aa 添加配置运行回调消息带上客户端信息 2022-07-27 11:36:04 +08:00
heavyrian2012 a394444c86 创建群组时,检查群组类型的有效性 2022-07-21 22:10:39 +08:00
heavyrian2012 dece1d7a1c sdk 添加获取会话阅读时间和消息送达时间接口 2022-07-20 22:25:46 +08:00
heavyrian2012 2b09a7bf84 version 0.90 2022-07-14 20:25:52 +08:00
heavyrian2012 200a6ebd04 添加注释 2022-07-14 20:22:36 +08:00
heavyrian2012 54db1f3b06 触发限频后多调用了一次callback,去掉无用的调用 2022-07-06 10:05:57 +08:00
heavyrian2012 3b90d145a4 去掉绑定IP地址的配置,防止客户误操作 2022-06-28 08:34:17 +08:00
heavyrain.lee e16a116fe4 Merge pull request #487 from wildfirechat/dependabot/maven/broker/mysql-mysql-connector-java-8.0.28
Bump mysql-connector-java from 8.0.19 to 8.0.28 in /broker
2022-06-26 18:34:33 +08:00
dependabot[bot] 7bd0937069 Bump mysql-connector-java from 8.0.19 to 8.0.28 in /broker
Bumps [mysql-connector-java](https://github.com/mysql/mysql-connector-j) from 8.0.19 to 8.0.28.
- [Release notes](https://github.com/mysql/mysql-connector-j/releases)
- [Changelog](https://github.com/mysql/mysql-connector-j/blob/release/8.0/CHANGES)
- [Commits](https://github.com/mysql/mysql-connector-j/compare/8.0.19...8.0.28)

---
updated-dependencies:
- dependency-name: mysql:mysql-connector-java
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-06-21 00:59:19 +00:00
heavyrian2012 c085057032 修正拼写错误 2022-06-09 15:03:56 +08:00
heavyrian2012 eac6648fc0 version 0.89 2022-06-09 09:42:34 +08:00
heavyrian2012 300f9aa0e6 update readme 2022-06-07 21:12:33 +08:00
heavyrian2012 dd40b72ec4 添加允许pc多端的配置 2022-06-06 09:37:37 +08:00
heavyrian2012 556e6ad2a0 解决某些java版本下反序列化IMResult<Void>失败问题 2022-05-27 13:25:21 +08:00
heavyrian2012 473ae32f57 update readme 2022-05-27 10:14:00 +08:00
heavyrian2012 d57ae2ed58 删除群组时清除相关设置 2022-05-27 08:35:12 +08:00
heavyrian2012 1a6907efd3 log4j version 2.17.2 2022-05-25 10:16:40 +08:00
heavyrain.lee 1624c470d6 Merge pull request #480 from wildfirechat/dependabot/maven/common/com.google.code.gson-gson-2.8.9
Bump gson from 2.8.2 to 2.8.9 in /common
2022-05-25 10:10:17 +08:00
heavyrain.lee 5ea6eefe67 Merge pull request #481 from wildfirechat/dependabot/maven/sdk/com.google.code.gson-gson-2.8.9
Bump gson from 2.8.2 to 2.8.9 in /sdk
2022-05-25 10:10:02 +08:00
dependabot[bot] bf51cb9829 Bump gson from 2.8.2 to 2.8.9 in /sdk
Bumps [gson](https://github.com/google/gson) from 2.8.2 to 2.8.9.
- [Release notes](https://github.com/google/gson/releases)
- [Changelog](https://github.com/google/gson/blob/master/CHANGELOG.md)
- [Commits](https://github.com/google/gson/compare/gson-parent-2.8.2...gson-parent-2.8.9)

---
updated-dependencies:
- dependency-name: com.google.code.gson:gson
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-05-20 21:09:22 +00:00
dependabot[bot] baadcac2c6 Bump gson from 2.8.2 to 2.8.9 in /common
Bumps [gson](https://github.com/google/gson) from 2.8.2 to 2.8.9.
- [Release notes](https://github.com/google/gson/releases)
- [Changelog](https://github.com/google/gson/blob/master/CHANGELOG.md)
- [Commits](https://github.com/google/gson/compare/gson-parent-2.8.2...gson-parent-2.8.9)

---
updated-dependencies:
- dependency-name: com.google.code.gson:gson
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-05-20 21:09:06 +00:00
35 changed files with 401 additions and 102 deletions
+9 -3
View File
@@ -2,7 +2,7 @@
野火IM是专业级的即时通讯和实时音视频整体解决方案,由北京野火无限网络科技有限公司维护和支持。
## 功能特性
* 超低硬件配置要求,IM服务最低128M内存即可运行。
* 极致地硬件利用率,IM服务最低128M内存即可运行,上不封顶。
* 协议先进,采用MQTT+Protobuf组合,流量和性能极致优化。
* 性能强大,专业版IM服务支持百万在线和集群部署。
* 部署运维简单,依赖服务少,稍加配置一键启动。
@@ -16,13 +16,14 @@
* 高级音视频功能强大,支持9人以上的群组视频通话,支持1080P视频,支持会议模式,支持百人以上会议,支持服务器端录制。
* 全私有部署,可不依赖任何第三方服务,完全内网部署。
* 功能齐全,涵盖所有常见即时通讯功能。另外具有强大的可扩展能力。Demo成熟完善,基本可以做到开箱即用,也可把SDK嵌入其它应用。
* 拥有应用开放平台,可以开发和创建自建应用,扩展您的工作台。
* API丰富,方便与其它服务系统的对接。
* 拥有机器人和频道功能。
## 野火开源项目
主要包括一下项目:
主要包括以下项目:
| [GitHub仓库地址(主站)](https://github.com/wildfirechat) | [码云仓库地址(镜像)](https://gitee.com/wfchat) | 说明
| [GitHub仓库地址](https://github.com/wildfirechat) | [码云仓库地址](https://gitee.com/wfchat) | 说明
| ------------------------------------------------------------ | ----------------------------------------------------- | --------------------------------------------------------------------------
| [im-server](https://github.com/wildfirechat/im-server) | [im-server](https://gitee.com/wfchat/im-server) | 野火社区版IM服务,野火IM的核心服务,处理所有IM相关业务。 |
| [app_server](https://github.com/wildfirechat/app_server) | [app_server](https://gitee.com/wfchat/app_server) | Demo应用服务,模拟客户的应用服登陆处理逻辑及部分二次开发示例。 |
@@ -30,11 +31,16 @@
| [push_server](https://github.com/wildfirechat/push_server) | [push_server](https://gitee.com/wfchat/push_server) | 推送服务器,可以对接所有的系统厂商推送服务或者第三方推送服务。 |
| [wf-minio](https://github.com/wildfirechat/WF-minio) | [wf-minio](https://gitee.com/wfchat/WF-minio) | 私有对象存储服务,用来支持野火IM专业版的文件存储。 |
| [wf-janus](https://github.com/wildfirechat/wf-janus ) | [wf-janus](https://gitee.com/wfchat/wf-janus ) | 高级音视频媒体服务。 |
| [open-platform](https://github.com/wildfirechat/open-platform) | [open-platform](https://gitee.com/wfchat/open-platform) | 野火开放平台服务。 |
| [daily-report](https://github.com/wildfirechat/daily-report) | [daily-report](https://github.com/wildfirechat/daily-report) | 野火开放平台日报 demo服务。 |
| [android-chat](https://github.com/wildfirechat/android-chat) | [android-chat](https://gitee.com/wfchat/android-chat) | 野火IM Android SDK源码和App源码。
| [ios-chat](https://github.com/wildfirechat/ios-chat) | [ios-chat](https://gitee.com/wfchat/ios-chat) | 野火IM iOS SDK源码和App源码。
| [pc-chat](https://github.com/wildfirechat/vue-pc-chat) | [pc-chat](https://gitee.com/wfchat/vue-pc-chat) | 基于[Electron](https://electronjs.org/)的PC 端,支持Windows、Mac、Linux(包括国产化linux系统和CPU)。 |
| [web-chat](https://github.com/wildfirechat/vue-chat) | [web-chat](https://gitee.com/wfchat/vue-chat) | 野火IM Web 端, [体验地址](https://web.wildfirechat.cn) |
| [wx-chat](https://github.com/wildfirechat/wx-chat) | [wx-chat](https://gitee.com/wfchat/wx-chat) | 小程序平台的Demo(支持微信、百度、阿里、字节、QQ 等小程序平台) |
| [uni-chat](https://github.com/wildfirechat/uni-chat) | [uni-chat](https://gitee.com/wfchat/uni-chat) | UniApp平台移动端应用(使用原生插件) |
| [uni-wfc-client](https://github.com/wildfirechat/uni-wfc-client) | [uni-wfc-client](https://gitee.com/wfchat/uni-wfc-client) | UniApp平台原生插件 |
| [flutter_imclient](https://github.com/wildfirechat/flutter_imclient) | [flutter_imclient](https://gitee.com/wfchat/flutter_imclient) | Flutter平台原生插件 |
| [docs](https://github.com/wildfirechat/docs) | [docs](https://gitee.com/wfchat/docs) | 野火IM相关文档,包含设计、概念、开发、使用说明,[在线查看](https://docs.wildfirechat.cn/) |
## 野火开发文档
+15 -2
View File
@@ -26,8 +26,8 @@ http.admin.port 18080
##节点ID,当集群部署时,一定不能有重复。
node_id 1
##绑定IP,保持不变即可
host 0.0.0.0
##绑定IP,不要打开,除非有特殊需求才可以打开
#host 0.0.0.0
##本地绑定端口
local_port 80
@@ -38,6 +38,7 @@ embed.db 1
## 是否自动清理历史消息记录,当为true时,IM服务会定时扫描t_messages_x和t_user_messages_x表,清除掉3年前的历史消息。
## 如果不开启自动清理,需要手动清理t_messages_x和t_user_messages_x表内的历史数据,保存数据不能超过3年。
## 如果需要消息保存更长时间,可以把临近销毁的消息转储到别的数据库,客户端在拉取不到服务器消息时,再去转储的数据库拉取。
## 使用mongodb时次开关无效(因为mongodb设置了消息过期时间,会自动清理,仅专业版支持mongodb)。
db.auto_clean_history_messages true
@@ -108,6 +109,15 @@ message.global_mute_exception_types 401,402,403,404,405,407,408,410,411
## 当为true时,不转发server api发送的消息;当为false时,转发server api发送的消息。
message.no_forward_admin_message false
## 消息转发功能开启时,转发信息是否带上用户clientId和平台类型。
message.forward_with_client_info false
## 机器人回调信息是否带上用户clientId和平台类型。
robot.callback_with_client_info false
## 频道回调信息是否带上用户clientId和平台类型。
channel.callback_with_client_info false
##禁止搜索用户
friend.disable_search false
@@ -237,6 +247,9 @@ local.media.storage.root media
# 建议使用false
server.multi_endpoint false
## 是否支持PC多端登陆,当server.multi_endpoint为true时,此开关无意义,当为false时,可以单独打开PC端多端登录。
server.multi_pc_endpoint false
# 多平台连接状态通知(仅当multi_endpoint为false时有效),true时移动端可以收到pc或web端登录的通知。
server.multi_platform_notification true
+5 -5
View File
@@ -5,7 +5,7 @@
<relativePath>../</relativePath>
<artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId>
<version>0.88</version>
<version>0.91</version>
</parent>
<artifactId>moquette-broker</artifactId>
@@ -27,18 +27,18 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.17.1</version>
<version>2.17.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.17.1</version>
<version>2.17.2</version>
</dependency>
<!--用于与slf4j保持桥接-->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.17.1</version>
<version>2.17.2</version>
</dependency>
<!-- slf4j核心包-->
<dependency>
@@ -56,7 +56,7 @@
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.19</version>
<version>8.0.28</version>
</dependency>
<dependency>
@@ -125,6 +125,7 @@ public final class BrokerConstants {
public static final String SERVER_MULTI_ENDPOINT = "server.multi_endpoint";
public static final String SERVER_MULTI_PC_ENDPOINT = "server.multi_pc_endpoint";
public static final String SERVER_MULTI_PLATFROM_NOTIFICATION = "server.multi_platform_notification";
public static final String SERVER_MOBILE_DEFAULT_SILENT_WHEN_PC_ONLINE = "server.mobile_default_silent_when_pc_online";
public static final String SERVER_CLIENT_SUPPORT_KICKOFF_EVENT = "server.client_support_kickoff_event";
@@ -141,6 +142,10 @@ public final class BrokerConstants {
public static final String MESSAGE_NO_Forward_Admin_Message = "message.no_forward_admin_message";
public static final String MESSAGE_Forward_With_Client_Info = "message.forward_with_client_info";
public static final String ROBOT_Callback_With_Client_Info = "robot.callback_with_client_info";
public static final String CHANNEL_Callback_With_Client_Info = "channel.callback_with_client_info";
public static final String FRIEND_Disable_Search = "friend.disable_search";
public static final String FRIEND_Disable_NickName_Search = "friend.disable_nick_name_search";
public static final String FRIEND_Disable_Friend_Request = "friend.disable_friend_request";
@@ -21,6 +21,9 @@ import win.liyufan.im.IMTopic;
public class CreateGroupHandler extends GroupHandler<WFCMessage.CreateGroupRequest> {
@Override
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, ProtoConstants.RequestSourceType requestSourceType, WFCMessage.CreateGroupRequest request, Qos1PublishHandler.IMCallback callback) {
if(request.getGroup().getGroupInfo().getType() < 0 || request.getGroup().getGroupInfo().getType() > 2) {
return ErrorCode.ERROR_CODE_INVALID_DATA;
}
if (!StringUtil.isNullOrEmpty(request.getGroup().getGroupInfo().getTargetId())) {
WFCMessage.GroupInfo existGroupInfo = m_messagesStore.getGroupInfo(request.getGroup().getGroupInfo().getTargetId());
@@ -166,14 +166,6 @@ abstract public class IMHandler<T> {
public ErrorCode preAction(String clientID, String fromUser, String topic, Qos1PublishHandler.IMCallback callback, ProtoConstants.RequestSourceType requestSourceType) {
LOG.info("imHandler fromUser={}, clientId={}, topic={}", fromUser, clientID, topic);
if(requestSourceType == ProtoConstants.RequestSourceType.Request_From_User && !mLimitCounter.isGranted(clientID + fromUser + topic)) {
ByteBuf ackPayload = Unpooled.buffer();
ackPayload.ensureWritable(1).writeByte(ERROR_CODE_OVER_FREQUENCY.getCode());
try {
callback.onIMHandled(ERROR_CODE_OVER_FREQUENCY, ackPayload);
} catch (Exception e) {
e.printStackTrace();
Utility.printExecption(LOG, e);
}
return ErrorCode.ERROR_CODE_OVER_FREQUENCY;
}
return ErrorCode.ERROR_CODE_SUCCESS;
@@ -9,11 +9,13 @@
package io.moquette.imhandler;
import cn.wildfirechat.pojos.MessagePayload;
import cn.wildfirechat.pojos.OutputClient;
import cn.wildfirechat.proto.ProtoConstants;
import cn.wildfirechat.proto.WFCMessage;
import com.google.gson.Gson;
import com.hazelcast.util.StringUtil;
import io.moquette.BrokerConstants;
import io.moquette.persistence.MemorySessionStore;
import io.moquette.spi.impl.Qos1PublishHandler;
import io.netty.buffer.ByteBuf;
import cn.wildfirechat.common.ErrorCode;
@@ -171,12 +173,20 @@ public class SendMessageHandler extends IMHandler<WFCMessage.Message> {
}
message = message.toBuilder().setFromUser(fromUser).setMessageId(messageId).setServerTimestamp(timestamp).build();
OutputClient outputClient = null;
if(m_messagesStore.isForwardMessageWithClientInfo() && requestSourceType == ProtoConstants.RequestSourceType.Request_From_User && !StringUtil.isNullOrEmpty(clientID)) {
MemorySessionStore.Session session = m_sessionsStore.getSession(clientID);
if(session != null && session.getUsername().equals(fromUser)) {
outputClient = new OutputClient(session.getPlatform(), clientID);
}
}
if (!StringUtil.isNullOrEmpty(mForwardUrl) && (mForwardMessageTypes.isEmpty() || mForwardMessageTypes.contains(message.getContent().getType())) && !(isAdmin && mNoForwardAdminMessage)) {
publisher.forwardMessage(message, mForwardUrl);
publisher.forwardMessage(message, mForwardUrl, outputClient);
}
if(!StringUtil.isNullOrEmpty(mMentionForwardUrl) && message.hasContent() && message.getContent().getMentionedType() != 0 && !(isAdmin && mNoForwardAdminMessage)) {
publisher.forwardMessage(message, mMentionForwardUrl);
publisher.forwardMessage(message, mMentionForwardUrl, outputClient);
}
if (!isAdmin) {
@@ -994,7 +994,7 @@ public class DatabaseStore {
}
sb.append(")");
sb.append(" and _scope = 6 and _key = ?");
sb.append(" and _scope in (5,6,26) and _key = ?");
statement = connection.prepareStatement(sb.toString());
int index = 1;
@@ -167,6 +167,10 @@ public class MemoryMessagesStore implements IMessagesStore {
private int mSyncDataPartSize = 0;
private boolean keepDisplayNameWhenDestroyUser = true;
private boolean mForwardMessageWithClientInfo = false;
private boolean mRobotCallbackWithClientInfo = false;
private boolean mChannelCallbackWithClientInfo = false;
private Set<Integer> mUserHideProperties = new HashSet<>();
MemoryMessagesStore(Server server, DatabaseStore databaseStore) {
@@ -446,6 +450,23 @@ public class MemoryMessagesStore implements IMessagesStore {
} catch (NumberFormatException e) {
e.printStackTrace();
}
try {
mForwardMessageWithClientInfo = Boolean.parseBoolean(server.getConfig().getProperty(BrokerConstants.MESSAGE_Forward_With_Client_Info, "false"));
} catch (Exception e) {
}
try {
mRobotCallbackWithClientInfo = Boolean.parseBoolean(server.getConfig().getProperty(BrokerConstants.ROBOT_Callback_With_Client_Info, "false"));
} catch (Exception e) {
}
try {
mChannelCallbackWithClientInfo = Boolean.parseBoolean(server.getConfig().getProperty(BrokerConstants.CHANNEL_Callback_With_Client_Info, "false"));
} catch (Exception e) {
}
}
private void printMissConfigLog(String config, String defaultValue) {
@@ -1279,11 +1300,31 @@ public class MemoryMessagesStore implements IMessagesStore {
}
}
MultiMap<String, WFCMessage.GroupMember> groupMembers = hzInstance.getMultiMap(GROUP_MEMBERS);
Collection<WFCMessage.GroupMember> members = groupMembers.get(groupId);
if (members == null || members.size() == 0) {
members = loadGroupMemberFromDB(hzInstance, groupId);
}
ArrayList<String> existMemberIds = new ArrayList<>();
for (WFCMessage.GroupMember member : members) {
if (member.getType() != GroupMemberType_Removed) {
existMemberIds.add(member.getMemberId());
}
}
long updateDt = System.currentTimeMillis();
List<WFCMessage.GroupMember> tmp = new ArrayList<>();
ArrayList<String> newInviteUsers = new ArrayList<>();
int newMemberCount = 0;
for (WFCMessage.GroupMember member : memberList) {
if (existMemberIds.contains(member.getMemberId()) && member.getType() != GroupMemberType_Removed) {
if(!isAdmin)
continue;
} else {
newMemberCount++;
}
WFCMessage.GroupMember.Builder builder = member.toBuilder();
builder.setUpdateDt(updateDt).setCreateDt(updateDt);
if (member.getMemberId().equals(groupInfo.getOwner())) {
@@ -1303,29 +1344,23 @@ public class MemoryMessagesStore implements IMessagesStore {
}
member = builder.build();
tmp.add(member);
newInviteUsers.add(member.getMemberId());
updateDt++;
}
memberList = tmp;
MultiMap<String, WFCMessage.GroupMember> groupMembers = hzInstance.getMultiMap(GROUP_MEMBERS);
Collection<WFCMessage.GroupMember> members = groupMembers.get(groupId);
if (members == null || members.size() == 0) {
members = loadGroupMemberFromDB(hzInstance, groupId);
}
if (maxCount != Integer.MAX_VALUE) {
int existCount = 0;
for (WFCMessage.GroupMember member : members) {
if (member.getType() != GroupMemberType_Removed) {
existCount++;
}
if (memberList.size() == 0) {
if (!isAdmin) {
return ErrorCode.ERROR_CODE_ALREADY_IN_GROUP;
} else {
return ErrorCode.ERROR_CODE_SUCCESS;
}
if (existCount + newInviteUsers.size() > maxCount) {
} else {
if (existMemberIds.size() + newMemberCount > maxCount) {
return ErrorCode.ERROR_CODE_GROUP_EXCEED_MAX_MEMBER_COUNT;
}
}
databaseStore.persistGroupMember(groupId, memberList, true);
databaseStore.updateGroupMemberCountDt(groupId);
@@ -4066,6 +4101,20 @@ public class MemoryMessagesStore implements IMessagesStore {
return mGroupVisibleQuitKickoffNotification;
}
@Override
public boolean isForwardMessageWithClientInfo() {
return mForwardMessageWithClientInfo;
}
@Override
public boolean isRobotCallbackWithClientInfo() {
return mRobotCallbackWithClientInfo;
}
@Override
public boolean isChannelCallbackWithClientInfo() {
return mChannelCallbackWithClientInfo;
}
@Override
public List<Integer> getClientForbiddenSendTypes() {
@@ -39,6 +39,7 @@ public class MemorySessionStore implements ISessionsStore {
private static final Logger LOG = LoggerFactory.getLogger(MemorySessionStore.class);
private boolean supportMultiEndpoint = false;
private boolean supportMultiPCEndpoint = false;
private boolean clientSupportKickoff = false;
public static class Session implements Comparable<Session>{
@@ -287,6 +288,11 @@ public class MemorySessionStore implements ISessionsStore {
Utility.printExecption(LOG, e);
}
try {
supportMultiPCEndpoint = Boolean.parseBoolean(server.getConfig().getProperty(BrokerConstants.SERVER_MULTI_PC_ENDPOINT, "false"));
} catch (Exception e) {
}
try {
clientSupportKickoff = Boolean.parseBoolean(server.getConfig().getProperty(BrokerConstants.SERVER_CLIENT_SUPPORT_KICKOFF_EVENT, "false"));
} catch (Exception e) {
@@ -385,7 +391,12 @@ public class MemorySessionStore implements ISessionsStore {
}
databaseStore.clearMultiUser(username, clientID);
if (!supportMultiEndpoint && platform > 0) {
if (!supportMultiEndpoint
&& platform > 0
&& !(platform == ProtoConstants.Platform.Platform_Windows && supportMultiPCEndpoint)
&& !(platform == ProtoConstants.Platform.Platform_LINUX && supportMultiPCEndpoint)
&& !(platform == ProtoConstants.Platform.Platform_OSX && supportMultiPCEndpoint)
) {
databaseStore.clearMultiEndpoint(username, clientID, platform);
if (userSessions.get(username) != null) {
Iterator<String> it = userSessions.get(username).iterator();
@@ -160,7 +160,7 @@ public class NettyAcceptor implements ServerAcceptor {
IConfig props) throws IOException {
LOG.info("Configuring TCP MQTT transport");
final MoquetteIdleTimeoutHandler timeoutHandler = new MoquetteIdleTimeoutHandler();
String host = props.getProperty(BrokerConstants.HOST_PROPERTY_NAME);
String host = props.getProperty(BrokerConstants.HOST_PROPERTY_NAME, "0.0.0.0");
String tcpPortProp = props.getProperty(PORT_PROPERTY_NAME, DISABLED_PORT_BIND);
if (DISABLED_PORT_BIND.equals(tcpPortProp)) {
LOG.info("Property {} has been set to {}. TCP MQTT will be disabled", BrokerConstants.PORT_PROPERTY_NAME,
@@ -233,6 +233,10 @@ public interface IMessagesStore {
boolean isAllowRobotCustomGroupNotification();
int getVisibleQuitKickoffNotification();
boolean isForwardMessageWithClientInfo();
boolean isRobotCallbackWithClientInfo();
boolean isChannelCallbackWithClientInfo();
List<Integer> getClientForbiddenSendTypes();
List<Integer> getBlackListExceptionTypes();
List<Integer> getGroupMuteExceptionTypes();
@@ -16,6 +16,7 @@
package io.moquette.spi.impl;
import cn.wildfirechat.pojos.OutputClient;
import cn.wildfirechat.pojos.OutputMessageData;
import cn.wildfirechat.proto.ProtoConstants;
import cn.wildfirechat.proto.WFCMessage;
@@ -175,10 +176,19 @@ public class MessagesPublisher {
if (message == null) {
message = m_messagesStore.getMessage(messageId);
}
OutputClient outputClient = null;
if(m_messagesStore.isRobotCallbackWithClientInfo() && !StringUtil.isNullOrEmpty(exceptClientId)) {
Session session = m_sessionsStore.getSession(exceptClientId);
if(session != null && session.getUsername().equals(sender)) {
outputClient = new OutputClient(session.getPlatform(), exceptClientId);
}
}
final WFCMessage.Message finalMsg = message;
OutputClient finalOutputClient = outputClient;
Server.getServer().getCallbackScheduler().execute(() -> {
try {
HttpUtils.httpJsonPost(robot.getCallback(), new Gson().toJson(OutputMessageData.fromProtoMessage(finalMsg), OutputMessageData.class), HttpUtils.HttpPostType.POST_TYPE_Robot_Message_Callback);
HttpUtils.httpJsonPost(robot.getCallback(), new Gson().toJson(OutputMessageData.fromProtoMessage(finalMsg, finalOutputClient), OutputMessageData.class), HttpUtils.HttpPostType.POST_TYPE_Robot_Message_Callback);
} catch (Exception e) {
e.printStackTrace();
Utility.printExecption(LOG, e, EVENT_CALLBACK_Exception);
@@ -595,9 +605,18 @@ public class MessagesPublisher {
if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Channel) {
WFCMessage.ChannelInfo channelInfo = m_messagesStore.getChannelInfo(message.getConversation().getTarget());
if (channelInfo != null && !StringUtil.isNullOrEmpty(channelInfo.getCallback())) {
OutputClient outputClient = null;
if(m_messagesStore.isChannelCallbackWithClientInfo() && !StringUtil.isNullOrEmpty(exceptClientId)) {
Session session = m_sessionsStore.getSession(exceptClientId);
if(session != null && session.getUsername().equals(message.getFromUser())) {
outputClient = new OutputClient(session.getPlatform(), exceptClientId);
}
}
OutputClient finalOutputClient = outputClient;
Server.getServer().getCallbackScheduler().execute(() -> {
try {
HttpUtils.httpJsonPost(channelInfo.getCallback() + "/message", new Gson().toJson(OutputMessageData.fromProtoMessage(message), OutputMessageData.class), HttpUtils.HttpPostType.POST_TYPE_Channel_Message_Callback);
HttpUtils.httpJsonPost(channelInfo.getCallback() + "/message", new Gson().toJson(OutputMessageData.fromProtoMessage(message, finalOutputClient), OutputMessageData.class), HttpUtils.HttpPostType.POST_TYPE_Channel_Message_Callback);
} catch (Exception e) {
e.printStackTrace();
Utility.printExecption(LOG, e, EVENT_CALLBACK_Exception);
@@ -647,10 +666,10 @@ public class MessagesPublisher {
}
public void forwardMessage(final WFCMessage.Message message, String forwardUrl) {
public void forwardMessage(final WFCMessage.Message message, String forwardUrl, OutputClient outputClient) {
Server.getServer().getCallbackScheduler().execute(() -> {
try {
HttpUtils.httpJsonPost(forwardUrl, new Gson().toJson(OutputMessageData.fromProtoMessage(message), OutputMessageData.class), HttpUtils.HttpPostType.POST_TYPE_Forward_Message_Callback);
HttpUtils.httpJsonPost(forwardUrl, new Gson().toJson(OutputMessageData.fromProtoMessage(message, outputClient), OutputMessageData.class), HttpUtils.HttpPostType.POST_TYPE_Forward_Message_Callback);
} catch (Exception e) {
e.printStackTrace();
Utility.printExecption(LOG, e, EVENT_CALLBACK_Exception);
+2 -2
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId>
<version>0.88</version>
<version>0.91</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -29,7 +29,7 @@
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.2</version>
<version>2.8.9</version>
</dependency>
<dependency>
@@ -57,6 +57,8 @@ public interface APIPath {
String Msg_Multicast = "/admin/message/multicast";
String Msg_RecallBroadCast = "/admin/message/recall_broadcast";
String Msg_RecallMultiCast = "/admin/message/recall_multicast";
String Msg_ConvRead = "/admin/message/conv_read";
String Msg_Delivery = "/admin/message/delivery";
String Create_Group = "/admin/group/create";
String Group_Dismiss = "/admin/group/del";
@@ -29,6 +29,7 @@ public enum ErrorCode {
//Group error
ERROR_CODE_GROUP_ALREADY_EXIST(11, "group already exist"),
ERROR_CODE_ALREADY_IN_GROUP(12, "member already in group"),
//user error
ERROR_CODE_FRIEND_ALREADY_REQUEST(16, "already send request"),
@@ -13,6 +13,15 @@ public class Conversation {
private String target;
private int line;
public Conversation() {
}
public Conversation(int type, String target, int line) {
this.type = type;
this.target = target;
this.line = line;
}
public int getType() {
return type;
}
@@ -67,16 +67,18 @@ public class InputCreateGroup extends InputGroupBase {
}
groupBuilder.setGroupInfo(groupInfoBuilder);
for (PojoGroupMember pojoGroupMember : group.getMembers()) {
WFCMessage.GroupMember.Builder groupMemberBuilder = WFCMessage.GroupMember.newBuilder().setMemberId(pojoGroupMember.getMember_id());
if (!StringUtil.isNullOrEmpty(pojoGroupMember.getAlias())) {
groupMemberBuilder.setAlias(pojoGroupMember.getAlias());
if(group.getMembers() != null) {
for (PojoGroupMember pojoGroupMember : group.getMembers()) {
WFCMessage.GroupMember.Builder groupMemberBuilder = WFCMessage.GroupMember.newBuilder().setMemberId(pojoGroupMember.getMember_id());
if (!StringUtil.isNullOrEmpty(pojoGroupMember.getAlias())) {
groupMemberBuilder.setAlias(pojoGroupMember.getAlias());
}
groupMemberBuilder.setType(pojoGroupMember.getType());
if (!StringUtil.isNullOrEmpty(pojoGroupMember.getExtra())) {
groupMemberBuilder.setExtra(pojoGroupMember.extra);
}
groupBuilder.addMembers(groupMemberBuilder);
}
groupMemberBuilder.setType(pojoGroupMember.getType());
if(!StringUtil.isNullOrEmpty(pojoGroupMember.getExtra())) {
groupMemberBuilder.setExtra(pojoGroupMember.extra);
}
groupBuilder.addMembers(groupMemberBuilder);
}
WFCMessage.CreateGroupRequest.Builder createGroupReqBuilder = WFCMessage.CreateGroupRequest.newBuilder();
@@ -0,0 +1,58 @@
/*
* 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;
public class InputGetConvReadTime {
private String userId;
private int conversationType;
private String target;
private int line;
public InputGetConvReadTime() {
}
public InputGetConvReadTime(String userId, int conversationType, String target, int line) {
this.userId = userId;
this.conversationType = conversationType;
this.target = target;
this.line = line;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public int getConversationType() {
return conversationType;
}
public void setConversationType(int conversationType) {
this.conversationType = conversationType;
}
public String getTarget() {
return target;
}
public void setTarget(String target) {
this.target = target;
}
public int getLine() {
return line;
}
public void setLine(int line) {
this.line = line;
}
}
@@ -11,6 +11,13 @@ package cn.wildfirechat.pojos;
public class InputUserId {
private String userId;
public InputUserId() {
}
public InputUserId(String userId) {
this.userId = userId;
}
public String getUserId() {
return userId;
}
@@ -0,0 +1,40 @@
/*
* 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 OutputClient {
private int platform;
private String clientId;
public OutputClient() {
}
public OutputClient(int platform, String clientId) {
this.platform = platform;
this.clientId = clientId;
}
public int getPlatform() {
return platform;
}
public void setPlatform(int platform) {
this.platform = platform;
}
public String getClientId() {
return clientId;
}
public void setClientId(String clientId) {
this.clientId = clientId;
}
}
@@ -20,6 +20,7 @@ public class OutputMessageData {
private MessagePayload payload;
private List<String> toUsers;
private long timestamp;
private OutputClient client;
public String getSender() {
return sender;
@@ -69,7 +70,19 @@ public class OutputMessageData {
this.timestamp = timestamp;
}
public OutputClient getClient() {
return client;
}
public void setClient(OutputClient client) {
this.client = client;
}
public static OutputMessageData fromProtoMessage(WFCMessage.Message protoMessage) {
return fromProtoMessage(protoMessage, null);
}
public static OutputMessageData fromProtoMessage(WFCMessage.Message protoMessage, OutputClient fromClient) {
OutputMessageData data = new OutputMessageData();
data.messageId = protoMessage.getMessageId();
data.sender = protoMessage.getFromUser();
@@ -80,6 +93,7 @@ public class OutputMessageData {
data.payload = MessagePayload.fromProtoMessageContent(protoMessage.getContent());
data.timestamp = protoMessage.getServerTimestamp();
data.toUsers = protoMessage.getToList();
data.client = fromClient;
return data;
}
}
@@ -0,0 +1,28 @@
/*
* 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;
public class OutputTimestamp {
private long timestamp;
public OutputTimestamp() {
}
public OutputTimestamp(long timestamp) {
this.timestamp = timestamp;
}
public long getTimestamp() {
return timestamp;
}
public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}
}
+1 -1
View File
@@ -6,7 +6,7 @@
<!--<relativePath>../pom.xml</relativePath>-->
<artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId>
<version>0.88</version>
<version>0.91</version>
</parent>
<artifactId>distribution</artifactId>
@@ -10,10 +10,11 @@
#(如果您部署云服务器上或者具有独立公网出口的服务器上,请改为对应的公网IP;如果您部署在在内网环境下,在内网使用,这个地方改成内网地址)
server.ip 0.0.0.0
##原生客户端长链接端口。如果使用4层的反向代理或者类似组件,需要设置长链接保持时间为10分钟。
##原生客户端长链接端口。如果使用4层的反向代理或者类似组件,需要设置长链接保持时间为10分钟。不支持7层代理。
port 1883
##客户端短链接端口,客户端固定使用80端口,不要修改此端口。
##客户端短链接端口,客户端固定使用80端口不能修改。
##如果是国企事业单位等因为政策原因无法使用80端口,可以联系野火解决。
http_port 80
#管理端口
@@ -22,8 +23,8 @@ http.admin.port 18080
##节点ID,当集群部署时,一定不能有重复。
node_id 1
##绑定IP,保持不变即可
host 0.0.0.0
##绑定IP,不要打开,除非有特殊需求才可以打开
#host 0.0.0.0
##本地绑定端口
local_port 80
@@ -34,6 +35,7 @@ embed.db 1
## 是否自动清理历史消息记录,当为true时,IM服务会定时扫描t_messages_x和t_user_messages_x表,清除掉3年前的历史消息。
## 如果不开启自动清理,需要手动清理t_messages_x和t_user_messages_x表内的历史数据,保存数据不能超过3年。
## 如果需要消息保存更长时间,可以把临近销毁的消息转储到别的数据库,客户端在拉取不到服务器消息时,再去转储的数据库拉取。
## 使用mongodb时次开关无效(因为mongodb设置了消息过期时间,会自动清理,仅专业版支持mongodb)。
db.auto_clean_history_messages true
@@ -103,6 +105,15 @@ message.global_mute_exception_types 401,402,403,404,405,407,408,410,411
## 当为true时,不转发server api发送的消息;当为false时,转发server api发送的消息。
message.no_forward_admin_message false
## 消息转发功能开启时,转发信息是否带上用户clientId和平台类型。
message.forward_with_client_info false
## 机器人回调信息是否带上用户clientId和平台类型。
robot.callback_with_client_info false
## 频道回调信息是否带上用户clientId和平台类型。
channel.callback_with_client_info false
##禁止搜索用户
friend.disable_search false
@@ -232,6 +243,9 @@ local.media.storage.root ./media
# 建议使用false
server.multi_endpoint false
## 是否支持PC多端登陆,当server.multi_endpoint为true时,此开关无意义,当为false时,可以单独打开PC端多端登录。
server.multi_pc_endpoint false
# 多平台连接状态通知(仅当multi_endpoint为false时有效),true时移动端可以收到pc或web端登录的通知。
server.multi_platform_notification true
+1 -1
View File
@@ -12,7 +12,7 @@
<artifactId>wildfirechat-parent</artifactId>
<packaging>pom</packaging>
<version>0.88</version>
<version>0.91</version>
<name>Wildfire Chat</name>
<description>Wildfire Chat Server</description>
<inceptionYear>2019</inceptionYear>
+2 -2
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId>
<version>0.88</version>
<version>0.91</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -15,7 +15,7 @@
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.2</version>
<version>2.8.9</version>
</dependency>
<dependency>
+1 -1
View File
@@ -9,7 +9,7 @@
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.2</version>
<version>2.8.9</version>
</dependency>
<dependency>
@@ -750,6 +750,20 @@ public class Main {
} else {
System.out.println("failure");
}
IMResult<OutputTimestamp> timestampResult = MessageAdmin.getConversationReadTimestamp("57gqmws2k", new Conversation(0, "admin", 0));
if(timestampResult != null && timestampResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
System.out.println("Get conversation read time success");
} else {
System.out.println("Get conversation read time failure");
}
timestampResult = MessageAdmin.getMessageDelivery("57gqmws2k");
if(timestampResult != null && timestampResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
System.out.println("Get message delivery success");
} else {
System.out.println("Get message delivery failure");
}
}
List<String> multicastReceivers = Arrays.asList("user2", "user3", "user4");
@@ -19,6 +19,9 @@ public class MessageAdmin {
messageData.setConv(conversation);
messageData.setPayload(payload);
messageData.setToUsers(toUsers);
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的实现方法!");
}
return AdminHttpUtils.httpJsonPost(path, messageData, SendMessageResult.class);
}
@@ -103,4 +106,16 @@ public class MessageAdmin {
messageData.setPayload(payload);
return AdminHttpUtils.httpJsonPost(path, messageData, MultiMessageResult.class);
}
public static IMResult<OutputTimestamp> getConversationReadTimestamp(String userId, Conversation conversation) throws Exception {
String path = APIPath.Msg_ConvRead;
InputGetConvReadTime input = new InputGetConvReadTime(userId, conversation.getType(), conversation.getTarget(), conversation.getLine());
return AdminHttpUtils.httpJsonPost(path, input, OutputTimestamp.class);
}
public static IMResult<OutputTimestamp> getMessageDelivery(String userId) throws Exception {
String path = APIPath.Msg_Delivery;
InputUserId input = new InputUserId(userId);
return AdminHttpUtils.httpJsonPost(path, input, OutputTimestamp.class);
}
}
@@ -22,7 +22,7 @@ import java.lang.reflect.Type;
import java.nio.charset.Charset;
public class AdminHttpUtils {
public class AdminHttpUtils extends JsonUtils {
private static final Logger LOG = LoggerFactory.getLogger(AdminHttpUtils.class);
private static String adminUrl;
@@ -152,17 +152,4 @@ public class AdminHttpUtils {
}
}
}
private static <T> IMResult<T> fromJsonObject(String content, Class<T> clazz) {
Type type = TypeBuilder
.newInstance(IMResult.class)
.addTypeParam(clazz)
.build();
return new Gson().fromJson(content, type);
}
private static boolean isNullOrEmpty(String str) {
return str == null || str.isEmpty();
}
}
@@ -21,7 +21,7 @@ import java.lang.reflect.Type;
import java.nio.charset.Charset;
public class ChannelHttpUtils {
public class ChannelHttpUtils extends JsonUtils {
private static final Logger LOG = LoggerFactory.getLogger(ChannelHttpUtils.class);
private String imurl;
@@ -103,18 +103,6 @@ public class ChannelHttpUtils {
}
}
private static <T> IMResult<T> fromJsonObject(String content, Class<T> clazz) {
Type type = TypeBuilder
.newInstance(IMResult.class)
.addTypeParam(clazz)
.build();
return new Gson().fromJson(content, type);
}
private static boolean isNullOrEmpty(String str) {
return str == null || str.isEmpty();
}
public String getChannelId() {
return channelId;
}
@@ -0,0 +1,20 @@
package cn.wildfirechat.sdk.utilities;
import cn.wildfirechat.sdk.model.IMResult;
import com.google.gson.Gson;
import ikidou.reflect.TypeBuilder;
public class JsonUtils {
public static <T> IMResult<T> fromJsonObject(String content, Class<T> clazz) {
TypeBuilder builder = TypeBuilder.newInstance(IMResult.class);
if (!clazz.equals(Void.class)) {
builder.addTypeParam(clazz);
}
return new Gson().fromJson(content, builder.build());
}
public static boolean isNullOrEmpty(String str) {
return str == null || str.isEmpty();
}
}
@@ -22,7 +22,7 @@ import java.lang.reflect.Type;
import java.nio.charset.Charset;
public class RobotHttpUtils {
public class RobotHttpUtils extends JsonUtils {
private static final Logger LOG = LoggerFactory.getLogger(RobotHttpUtils.class);
private final String url;
@@ -106,18 +106,6 @@ public class RobotHttpUtils {
}
}
private static <T> IMResult<T> fromJsonObject(String content, Class<T> clazz) {
Type type = TypeBuilder
.newInstance(IMResult.class)
.addTypeParam(clazz)
.build();
return new Gson().fromJson(content, type);
}
private static boolean isNullOrEmpty(String str) {
return str == null || str.isEmpty();
}
public String getRobotId() {
return robotId;
}