Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c4a764d81d | ||
|
|
2c5ae2bd86 | ||
|
|
b11d609ea0 | ||
|
|
b8170c4757 | ||
|
|
e42d6f8e4f | ||
|
|
e0c95bace9 | ||
|
|
8623223991 | ||
|
|
efdcc24067 | ||
|
|
ec18e40eb0 | ||
|
|
f9d970c730 | ||
|
|
590b02cc8e | ||
|
|
f2f75d3048 | ||
|
|
94466139f6 | ||
|
|
70aeff9ac5 | ||
|
|
7e56fe2ee0 | ||
|
|
599547d627 | ||
|
|
28600ea7f9 | ||
|
|
a73507c673 | ||
|
|
84b8d4cd09 | ||
|
|
b66aa3d634 | ||
|
|
508beaf62c | ||
|
|
e914afedf4 | ||
|
|
49c32d7fa1 | ||
|
|
aac106d37e | ||
|
|
8bd17a8093 | ||
|
|
b1f07f49ff | ||
|
|
86dddfd85f | ||
|
|
db733efc44 | ||
|
|
69f28bd35b |
@@ -43,11 +43,6 @@
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
#### 加入野火官方体验交流群
|
|
||||||
使用野火IM移动客户端扫码下面二维码(不是使用微信扫码),和野火IM的爱好者一起畅谈野火IM的问题和经验:
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
#### 应用截图
|
#### 应用截图
|
||||||

|

|
||||||
|
|
||||||
@@ -73,12 +68,11 @@
|
|||||||
|
|
||||||
## 编译
|
## 编译
|
||||||
在安装JDK1.8以上及maven的前提下,在命令行中执行```mvn clean compile package```,生成的目标文件在```./distribution/target/distribution-xxxx-bundle-tar.tar.gz```
|
在安装JDK1.8以上及maven的前提下,在命令行中执行```mvn clean compile package```,生成的目标文件在```./distribution/target/distribution-xxxx-bundle-tar.tar.gz```
|
||||||
|
> 由于使用了一个git的maven插件,如果本地没有git信息就会编译出错,请使用```git clone```的方法下载代码,或者下载压缩包解压后在根目录创建```.git```的空目录。建议用```git clone```的方式下载代码。
|
||||||
|
|
||||||
## 捐赠者名单
|
## 升级说明
|
||||||
|
1. 从0.42 版本增加了群成员数限制,默认为2000。如果您从之前的版本升级到这个版本或以后,需要注意到群成员数的限制。升级之后超出限制的群不受影响,但不能继续加人,如果您想修改默认值,可以在升级版本之后,修改t_setting表,把默认的大小改为您期望的人数。另外修改t_group表,把已经存在的群组max_member_count改成您期望的,然后重启。
|
||||||
|
|
||||||
| 捐赠者 | 商标 | 金额 | 简介 |
|
|
||||||
| ----- | ---- | -------- | --- |
|
|
||||||
| [SAMOS](http://samos.io) |  | 保密 | 一站式区块链解决方案服务商(http://samos.io) |
|
|
||||||
|
|
||||||
## 特别感谢
|
## 特别感谢
|
||||||
1. [moquette](https://github.com/moquette-io/moquette) 本项目是基于此项目二次开发而来,处理MQTT相关业务。
|
1. [moquette](https://github.com/moquette-io/moquette) 本项目是基于此项目二次开发而来,处理MQTT相关业务。
|
||||||
|
|||||||
@@ -55,10 +55,12 @@ token.key testim
|
|||||||
##token的过期时间,单位为毫秒,默认为无限期。如果需要设置无限期,客户端上一定需要加上token过期的处理。token过期的处理请参考文档的常见问题
|
##token的过期时间,单位为毫秒,默认为无限期。如果需要设置无限期,客户端上一定需要加上token过期的处理。token过期的处理请参考文档的常见问题
|
||||||
##token.expire_time 2592000000
|
##token.expire_time 2592000000
|
||||||
|
|
||||||
##首次登录,是否接收之前的历史消息。0 不接收;1接收。
|
##首次登录,是否接收之前的历史消息。
|
||||||
|
##0 不接收历史消息,只接收5分钟以内的消息,由于服务器没有保存已经收取记录,所以如果有超过5分钟之前未收取的消息也不会收取下拉;
|
||||||
|
##1接收,会接收 message.max_queue 配置的条数的历史消息
|
||||||
message.roaming 0
|
message.roaming 0
|
||||||
|
|
||||||
##是否开启拉取远程历史消息
|
##是否开启拉取远程历史消息。如果为1,客户端在会话内如果本地消息读取完了,可以下拉继续加载在服务器上的该会话的消息;如果为0则不能。
|
||||||
message.remote_history_message 0
|
message.remote_history_message 0
|
||||||
|
|
||||||
##服务器为每个用户缓存的消息数量。这个值改得太大,拉取消息时间变长,另外会占用大量内存。
|
##服务器为每个用户缓存的消息数量。这个值改得太大,拉取消息时间变长,另外会占用大量内存。
|
||||||
@@ -92,6 +94,12 @@ friend.reject_request_duration 2592000000
|
|||||||
##好友请求过期时间,单位是毫秒,默认是7天,0为不限制
|
##好友请求过期时间,单位是毫秒,默认是7天,0为不限制
|
||||||
friend.request_expiration_duration 604800000
|
friend.request_expiration_duration 604800000
|
||||||
|
|
||||||
|
##添加好友后会发送欢迎消息,比如"你们已经是好友了,可以聊天了"。这个开关控制是用旧的方式还是用新的方式。
|
||||||
|
##旧的方式会发送notification消息(contenttype是80),内容会根据好友接收者的语言选择对应的语言,如果双方语言不一致会导致另外一方看到的不是本地语言。
|
||||||
|
##新的方式会发送添加好友消息(contenttype是93)和欢迎消息(contenttype是92),需要客户端实现这两种消息。
|
||||||
|
##如果客户端已经实现这两种消息可以打开这个开关
|
||||||
|
friend.new_welcome_message false
|
||||||
|
|
||||||
## 聊天室观众空闲退出时间,单位为毫秒,默认为15分钟,0为永远不退出
|
## 聊天室观众空闲退出时间,单位为毫秒,默认为15分钟,0为永远不退出
|
||||||
chatroom.participant_idle_time 900000
|
chatroom.participant_idle_time 900000
|
||||||
|
|
||||||
@@ -174,6 +182,8 @@ push.ios.server.address http://localhost:8085/ios/push
|
|||||||
#mongodb.client_uri mongodb://host1:27017,host2:27017,host3:27017/wfchat?replicaSet=myReplicaSet
|
#mongodb.client_uri mongodb://host1:27017,host2:27017,host3:27017/wfchat?replicaSet=myReplicaSet
|
||||||
mongodb.client_uri mongodb://wfc:123456@localhost:27017/wfchat
|
mongodb.client_uri mongodb://wfc:123456@localhost:27017/wfchat
|
||||||
mongodb.database wfchat
|
mongodb.database wfchat
|
||||||
|
#仅在第一次启动时会设置消息数据的过期时间,如果之后再修改将不生效。
|
||||||
|
#如果需要修改过期时间,请修改t_messages_x和t_user_message_x的索引过期时间,修改方法请行百度
|
||||||
mongodb.data_expire_days 1096
|
mongodb.data_expire_days 1096
|
||||||
|
|
||||||
#*********************************************************************
|
#*********************************************************************
|
||||||
|
|||||||
+42
@@ -0,0 +1,42 @@
|
|||||||
|
|
||||||
|
DROP TABLE IF EXISTS `t_read_report`;
|
||||||
|
CREATE TABLE `t_read_report` (
|
||||||
|
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||||
|
`_uid` varchar(64) NULL,
|
||||||
|
`_type` tinyint NULL,
|
||||||
|
`_line` int(11) NULL,
|
||||||
|
`_target` varchar(64) NULL,
|
||||||
|
`_dt` bigint(20) NOT NULL DEFAULT 0,
|
||||||
|
INDEX `read_report_index` (`_uid`, `_type`, `_line`, `_target`)
|
||||||
|
);
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `t_user_read_report`;
|
||||||
|
CREATE TABLE `t_user_read_report` (
|
||||||
|
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||||
|
`_rid` int(11) NOT NULL,
|
||||||
|
`_uid` varchar(64) NOT NULL,
|
||||||
|
`_seq` bigint(20) NOT NULL,
|
||||||
|
`_dt` DATETIME NOT NULL DEFAULT NOW(),
|
||||||
|
INDEX `user_read_report_index` (`_uid` DESC, `_seq` DESC),
|
||||||
|
UNIQUE INDEX `user_read_report_index2` (`_uid` DESC, `_rid` DESC)
|
||||||
|
);
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `t_delivery_report`;
|
||||||
|
CREATE TABLE `t_delivery_report` (
|
||||||
|
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||||
|
`_uid` varchar(64) NOT NULL,
|
||||||
|
`_dt` bigint(20) NOT NULL,
|
||||||
|
UNIQUE INDEX `delivery_index` (`_uid`)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `t_user_delivery_report`;
|
||||||
|
CREATE TABLE `t_user_delivery_report` (
|
||||||
|
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||||
|
`_rid` varchar(64) NOT NULL,
|
||||||
|
`_uid` varchar(64) NOT NULL,
|
||||||
|
`_seq` bigint(20) NOT NULL,
|
||||||
|
`_dt` DATETIME NOT NULL DEFAULT NOW(),
|
||||||
|
INDEX `user_delivery_index` (`_uid` DESC, `_seq` DESC),
|
||||||
|
UNIQUE INDEX `user_delivery_index2` (`_uid` DESC, `_rid` DESC)
|
||||||
|
);
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
alter table t_group_member add column `_create_dt` bigint(20) DEFAULT 0;
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
alter table `t_group` add column `_history_message` tinyint NOT NULL DEFAULT 0;
|
||||||
|
alter table `t_group` add column `_max_member_count` int(11) NOT NULL DEFAULT 2000;
|
||||||
+54
@@ -0,0 +1,54 @@
|
|||||||
|
|
||||||
|
DROP TABLE IF EXISTS `t_read_report`;
|
||||||
|
CREATE TABLE `t_read_report` (
|
||||||
|
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||||
|
`_uid` varchar(64) NULL,
|
||||||
|
`_type` tinyint NULL,
|
||||||
|
`_line` int(11) NULL,
|
||||||
|
`_target` varchar(64) NULL,
|
||||||
|
`_dt` bigint(20) NOT NULL DEFAULT 0,
|
||||||
|
INDEX `read_report_index` (`_uid`, `_type`, `_line`, `_target`)
|
||||||
|
)
|
||||||
|
ENGINE = InnoDB
|
||||||
|
DEFAULT CHARACTER SET = utf8mb4
|
||||||
|
COLLATE = utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `t_user_read_report`;
|
||||||
|
CREATE TABLE `t_user_read_report` (
|
||||||
|
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||||
|
`_rid` int(11) NOT NULL,
|
||||||
|
`_uid` varchar(64) NOT NULL,
|
||||||
|
`_seq` bigint(20) NOT NULL,
|
||||||
|
`_dt` DATETIME NOT NULL DEFAULT NOW(),
|
||||||
|
INDEX `user_read_report_index` (`_uid` DESC, `_seq` DESC),
|
||||||
|
UNIQUE INDEX `user_read_report_index2` (`_uid` DESC, `_rid` DESC)
|
||||||
|
)
|
||||||
|
ENGINE = InnoDB
|
||||||
|
DEFAULT CHARACTER SET = utf8mb4
|
||||||
|
COLLATE = utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `t_delivery_report`;
|
||||||
|
CREATE TABLE `t_delivery_report` (
|
||||||
|
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||||
|
`_uid` varchar(64) NOT NULL,
|
||||||
|
`_dt` bigint(20) NOT NULL,
|
||||||
|
UNIQUE INDEX `delivery_index` (`_uid`)
|
||||||
|
)
|
||||||
|
ENGINE = InnoDB
|
||||||
|
DEFAULT CHARACTER SET = utf8mb4
|
||||||
|
COLLATE = utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `t_user_delivery_report`;
|
||||||
|
CREATE TABLE `t_user_delivery_report` (
|
||||||
|
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||||
|
`_rid` varchar(64) NOT NULL,
|
||||||
|
`_uid` varchar(64) NOT NULL,
|
||||||
|
`_seq` bigint(20) NOT NULL,
|
||||||
|
`_dt` DATETIME NOT NULL DEFAULT NOW(),
|
||||||
|
INDEX `user_delivery_index` (`_uid` DESC, `_seq` DESC),
|
||||||
|
UNIQUE INDEX `user_delivery_index2` (`_uid` DESC, `_rid` DESC)
|
||||||
|
)
|
||||||
|
ENGINE = InnoDB
|
||||||
|
DEFAULT CHARACTER SET = utf8mb4
|
||||||
|
COLLATE = utf8mb4_unicode_ci;
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
alter table t_group_member add column `_create_dt` bigint(20) DEFAULT 0, COMMENT "group member create time";
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
alter table `t_group` add column `_history_message` tinyint NOT NULL DEFAULT 0, COMMENT "new group member can load group history messages";
|
||||||
|
alter table `t_group` add column `_max_member_count` int(11) NOT NULL DEFAULT 2000, COMMENT "max group member count";
|
||||||
+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>0.41</version>
|
<version>0.42</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>moquette-broker</artifactId>
|
<artifactId>moquette-broker</artifactId>
|
||||||
|
|||||||
@@ -109,7 +109,8 @@ public class FileAction extends Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 路径安全检查
|
// 路径安全检查
|
||||||
if (httpPath.contains("/.") || httpPath.contains("./") || httpPath.charAt(0) == '.' || httpPath.charAt(httpPath.length() - 1) == '.' || ReUtil.isMatch(INSECURE_URI, httpPath)) {
|
String path = httpPath.substring(0, httpPath.lastIndexOf("/"));
|
||||||
|
if (path.contains("/.") || path.contains("./") || path.charAt(0) == '.' || path.charAt(path.length() - 1) == '.' || ReUtil.isMatch(INSECURE_URI, path)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import cn.wildfirechat.pojos.InputGetGroup;
|
|||||||
import cn.wildfirechat.pojos.OutputGroupMemberList;
|
import cn.wildfirechat.pojos.OutputGroupMemberList;
|
||||||
import cn.wildfirechat.pojos.PojoGroupInfo;
|
import cn.wildfirechat.pojos.PojoGroupInfo;
|
||||||
import cn.wildfirechat.pojos.PojoGroupMember;
|
import cn.wildfirechat.pojos.PojoGroupMember;
|
||||||
|
import cn.wildfirechat.proto.ProtoConstants;
|
||||||
import cn.wildfirechat.proto.WFCMessage;
|
import cn.wildfirechat.proto.WFCMessage;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.xiaoleilu.loServer.RestResult;
|
import com.xiaoleilu.loServer.RestResult;
|
||||||
@@ -56,6 +57,9 @@ public class GetGroupMembersAction extends AdminAction {
|
|||||||
OutputGroupMemberList out = new OutputGroupMemberList();
|
OutputGroupMemberList out = new OutputGroupMemberList();
|
||||||
out.setMembers(new ArrayList<>());
|
out.setMembers(new ArrayList<>());
|
||||||
for (WFCMessage.GroupMember member : members) {
|
for (WFCMessage.GroupMember member : members) {
|
||||||
|
if (member.getType() == ProtoConstants.GroupMemberType.GroupMemberType_Removed) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
PojoGroupMember pm = new PojoGroupMember();
|
PojoGroupMember pm = new PojoGroupMember();
|
||||||
pm.setMember_id(member.getMemberId());
|
pm.setMember_id(member.getMemberId());
|
||||||
pm.setAlias(member.getAlias());
|
pm.setAlias(member.getAlias());
|
||||||
|
|||||||
@@ -135,6 +135,7 @@ public final class BrokerConstants {
|
|||||||
public static final String FRIEND_Repeat_Request_Duration = "friend.repeat_request_duration";
|
public static final String FRIEND_Repeat_Request_Duration = "friend.repeat_request_duration";
|
||||||
public static final String FRIEND_Reject_Request_Duration = "friend.reject_request_duration";
|
public static final String FRIEND_Reject_Request_Duration = "friend.reject_request_duration";
|
||||||
public static final String FRIEND_Request_Expiration_Duration = "friend.request_expiration_duration";
|
public static final String FRIEND_Request_Expiration_Duration = "friend.request_expiration_duration";
|
||||||
|
public static final String FRIEND_New_Welcome_Message = "friend.new_welcome_message";
|
||||||
|
|
||||||
public static final String CHATROOM_Participant_Idle_Time = "chatroom.participant_idle_time";
|
public static final String CHATROOM_Participant_Idle_Time = "chatroom.participant_idle_time";
|
||||||
public static final String CHATROOM_Rejoin_When_Active = "chatroom.rejoin_when_active";
|
public static final String CHATROOM_Rejoin_When_Active = "chatroom.rejoin_when_active";
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import java.util.List;
|
|||||||
|
|
||||||
abstract public class GroupHandler<T> extends IMHandler<T> {
|
abstract public class GroupHandler<T> extends IMHandler<T> {
|
||||||
protected void sendGroupNotification(String fromUser, String targetId, List<Integer> lines, WFCMessage.MessageContent content) {
|
protected void sendGroupNotification(String fromUser, String targetId, List<Integer> lines, WFCMessage.MessageContent content) {
|
||||||
if (lines != null) {
|
if (lines == null) {
|
||||||
lines = new ArrayList<>();
|
lines = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,12 @@ public class HandleFriendRequestHandler extends IMHandler<WFCMessage.HandleFrien
|
|||||||
if (session != null && !StringUtil.isNullOrEmpty(session.getLanguage())) {
|
if (session != null && !StringUtil.isNullOrEmpty(session.getLanguage())) {
|
||||||
language = session.getLanguage();
|
language = session.getLanguage();
|
||||||
}
|
}
|
||||||
WFCMessage.MessageContent.Builder contentBuilder = WFCMessage.MessageContent.newBuilder().setType(90).setContent(I18n.getString(language, "Above_Greeting_Message"));
|
WFCMessage.MessageContent.Builder contentBuilder = WFCMessage.MessageContent.newBuilder();
|
||||||
|
if (m_messagesStore.isNewFriendWelcomeMessage()) {
|
||||||
|
contentBuilder.setType(92);
|
||||||
|
} else {
|
||||||
|
contentBuilder.setType(90).setContent(I18n.getString(language, "Above_Greeting_Message"));
|
||||||
|
}
|
||||||
|
|
||||||
builder = WFCMessage.Message.newBuilder();
|
builder = WFCMessage.Message.newBuilder();
|
||||||
builder.setFromUser(request.getTargetUid());
|
builder.setFromUser(request.getTargetUid());
|
||||||
@@ -56,7 +61,12 @@ public class HandleFriendRequestHandler extends IMHandler<WFCMessage.HandleFrien
|
|||||||
builder.setMessageId(messageId);
|
builder.setMessageId(messageId);
|
||||||
saveAndPublish(request.getTargetUid(), null, builder.build(), false);
|
saveAndPublish(request.getTargetUid(), null, builder.build(), false);
|
||||||
|
|
||||||
contentBuilder.setContent(I18n.getString(language, "Friend_Can_Start_Chat"));
|
if (m_messagesStore.isNewFriendWelcomeMessage()) {
|
||||||
|
contentBuilder.setType(93);
|
||||||
|
} else {
|
||||||
|
contentBuilder.setContent(I18n.getString(language, "Friend_Can_Start_Chat"));
|
||||||
|
}
|
||||||
|
|
||||||
builder.setContent(contentBuilder);
|
builder.setContent(contentBuilder);
|
||||||
messageId = MessageShardingUtil.generateId();
|
messageId = MessageShardingUtil.generateId();
|
||||||
builder.setMessageId(messageId);
|
builder.setMessageId(messageId);
|
||||||
|
|||||||
@@ -331,7 +331,7 @@ public class DatabaseStore {
|
|||||||
String sql = "select `_mid`" +
|
String sql = "select `_mid`" +
|
||||||
", `_alias`" +
|
", `_alias`" +
|
||||||
", `_type`" +
|
", `_type`" +
|
||||||
", `_dt` from t_group_member where _gid = ?";
|
", `_dt`, `_create_dt` from t_group_member where _gid = ?";
|
||||||
statement = connection.prepareStatement(sql);
|
statement = connection.prepareStatement(sql);
|
||||||
|
|
||||||
statement.setString(1, groupId);
|
statement.setString(1, groupId);
|
||||||
@@ -358,6 +358,9 @@ public class DatabaseStore {
|
|||||||
long longValue = rs.getLong(index++);
|
long longValue = rs.getLong(index++);
|
||||||
builder.setUpdateDt(longValue);
|
builder.setUpdateDt(longValue);
|
||||||
|
|
||||||
|
longValue = rs.getLong(index++);
|
||||||
|
builder.setCreateDt(longValue);
|
||||||
|
|
||||||
WFCMessage.GroupMember member = builder.build();
|
WFCMessage.GroupMember member = builder.build();
|
||||||
groupMembers.put(groupId, member);
|
groupMembers.put(groupId, member);
|
||||||
}
|
}
|
||||||
@@ -1338,7 +1341,6 @@ public class DatabaseStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void updateSessionDeleted(String uid, String cid, int deleted) {
|
void updateSessionDeleted(String uid, String cid, int deleted) {
|
||||||
mScheduler.execute(()->{
|
|
||||||
Connection connection = null;
|
Connection connection = null;
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
|
|
||||||
@@ -1363,11 +1365,9 @@ public class DatabaseStore {
|
|||||||
} finally {
|
} finally {
|
||||||
DBUtil.closeDB(connection, statement);
|
DBUtil.closeDB(connection, statement);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateSessionPlatform(String uid, String cid, int platform) {
|
void updateSessionPlatform(String uid, String cid, int platform) {
|
||||||
mScheduler.execute(()->{
|
|
||||||
Connection connection = null;
|
Connection connection = null;
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
|
|
||||||
@@ -1392,7 +1392,6 @@ public class DatabaseStore {
|
|||||||
} finally {
|
} finally {
|
||||||
DBUtil.closeDB(connection, statement);
|
DBUtil.closeDB(connection, statement);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean strEqual(String left, String right) {
|
private boolean strEqual(String left, String right) {
|
||||||
@@ -1652,7 +1651,7 @@ public class DatabaseStore {
|
|||||||
", `_mid`" +
|
", `_mid`" +
|
||||||
", `_alias`" +
|
", `_alias`" +
|
||||||
", `_type`" +
|
", `_type`" +
|
||||||
", `_dt`) values(?, ?, ?, ?, ?)" +
|
", `_dt`, `_create_dt`) values(?, ?, ?, ?, ?, ?)" +
|
||||||
" ON DUPLICATE KEY UPDATE " +
|
" ON DUPLICATE KEY UPDATE " +
|
||||||
"`_alias` = ?," +
|
"`_alias` = ?," +
|
||||||
"`_type` = ?," +
|
"`_type` = ?," +
|
||||||
@@ -1673,6 +1672,7 @@ public class DatabaseStore {
|
|||||||
statement.setString(index++, member.getAlias());
|
statement.setString(index++, member.getAlias());
|
||||||
statement.setInt(index++, member.getType());
|
statement.setInt(index++, member.getType());
|
||||||
statement.setLong(index++, dt);
|
statement.setLong(index++, dt);
|
||||||
|
statement.setLong(index++, member.getCreateDt());
|
||||||
statement.setString(index++, member.getAlias());
|
statement.setString(index++, member.getAlias());
|
||||||
statement.setInt(index++, member.getType());
|
statement.setInt(index++, member.getType());
|
||||||
statement.setLong(index++, dt);
|
statement.setLong(index++, dt);
|
||||||
|
|||||||
@@ -127,6 +127,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
private long mFriendRequestDuration = 7 * 24 * 60 * 60 * 1000;
|
private long mFriendRequestDuration = 7 * 24 * 60 * 60 * 1000;
|
||||||
private long mFriendRejectDuration = 30 * 24 * 60 * 60 * 1000;
|
private long mFriendRejectDuration = 30 * 24 * 60 * 60 * 1000;
|
||||||
private long mFriendRequestExpiration = 7 * 24 * 60 * 60 * 1000;
|
private long mFriendRequestExpiration = 7 * 24 * 60 * 60 * 1000;
|
||||||
|
private boolean mFriendNewWelcomeMessage = false;
|
||||||
|
|
||||||
private boolean mMultiPlatformNotification = false;
|
private boolean mMultiPlatformNotification = false;
|
||||||
private boolean mDisableStrangerChat = false;
|
private boolean mDisableStrangerChat = false;
|
||||||
@@ -204,6 +205,15 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
printMissConfigLog(FRIEND_Request_Expiration_Duration, mFriendRequestExpiration + "");
|
printMissConfigLog(FRIEND_Request_Expiration_Duration, mFriendRequestExpiration + "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
mFriendNewWelcomeMessage = Boolean.parseBoolean(m_Server.getConfig().getProperty(FRIEND_New_Welcome_Message));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Utility.printExecption(LOG, e);
|
||||||
|
printMissConfigLog(FRIEND_New_Welcome_Message, mFriendNewWelcomeMessage + "");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mChatroomRejoinWhenActive = Boolean.parseBoolean(m_Server.getConfig().getProperty(BrokerConstants.CHATROOM_Rejoin_When_Active));
|
mChatroomRejoinWhenActive = Boolean.parseBoolean(m_Server.getConfig().getProperty(BrokerConstants.CHATROOM_Rejoin_When_Active));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -781,9 +791,9 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
List<WFCMessage.GroupMember> updatedMemberList = new ArrayList<>();
|
List<WFCMessage.GroupMember> updatedMemberList = new ArrayList<>();
|
||||||
for (WFCMessage.GroupMember member : memberList) {
|
for (WFCMessage.GroupMember member : memberList) {
|
||||||
if (member.getMemberId().equals(groupInfo.getOwner())) {
|
if (member.getMemberId().equals(groupInfo.getOwner())) {
|
||||||
member = member.toBuilder().setUpdateDt(dt).setType(ProtoConstants.GroupMemberType.GroupMemberType_Owner).build();
|
member = member.toBuilder().setUpdateDt(dt).setCreateDt(dt).setType(ProtoConstants.GroupMemberType.GroupMemberType_Owner).build();
|
||||||
} else {
|
} else {
|
||||||
member = member.toBuilder().setUpdateDt(dt).build();
|
member = member.toBuilder().setUpdateDt(dt).setCreateDt(dt).build();
|
||||||
}
|
}
|
||||||
groupMembers.put(groupId, member);
|
groupMembers.put(groupId, member);
|
||||||
updatedMemberList.add(member);
|
updatedMemberList.add(member);
|
||||||
@@ -806,6 +816,8 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int maxCount = Integer.MAX_VALUE;
|
||||||
|
|
||||||
if (!isAdmin) {
|
if (!isAdmin) {
|
||||||
boolean isMember = false;
|
boolean isMember = false;
|
||||||
boolean isManager = false;
|
boolean isManager = false;
|
||||||
@@ -835,6 +847,15 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
if (!isMember && !(memberList.size() == 1 && operator.equals(memberList.get(0).getMemberId()))) {
|
if (!isMember && !(memberList.size() == 1 && operator.equals(memberList.get(0).getMemberId()))) {
|
||||||
return ErrorCode.ERROR_CODE_NOT_IN_GROUP;
|
return ErrorCode.ERROR_CODE_NOT_IN_GROUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SystemSettingPojo maxMemberSetting = databaseStore.getSystemSetting(ProtoConstants.SystemSettingType.Group_Max_Member_Count);
|
||||||
|
if (maxMemberSetting != null) {
|
||||||
|
try {
|
||||||
|
maxCount = Integer.parseInt(maxMemberSetting.value);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
long updateDt = System.currentTimeMillis();
|
long updateDt = System.currentTimeMillis();
|
||||||
@@ -843,9 +864,9 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
ArrayList<String> newInviteUsers = new ArrayList<>();
|
ArrayList<String> newInviteUsers = new ArrayList<>();
|
||||||
for (WFCMessage.GroupMember member : memberList) {
|
for (WFCMessage.GroupMember member : memberList) {
|
||||||
if (member.getMemberId().equals(groupInfo.getOwner())) {
|
if (member.getMemberId().equals(groupInfo.getOwner())) {
|
||||||
member = member.toBuilder().setType(GroupMemberType_Owner).setUpdateDt(updateDt).setAlias("").build();
|
member = member.toBuilder().setType(GroupMemberType_Owner).setUpdateDt(updateDt).setCreateDt(updateDt).setAlias("").build();
|
||||||
} else {
|
} else {
|
||||||
member = member.toBuilder().setType(GroupMemberType_Normal).setUpdateDt(updateDt).setAlias("").build();
|
member = member.toBuilder().setType(GroupMemberType_Normal).setUpdateDt(updateDt).setCreateDt(updateDt).setAlias("").build();
|
||||||
}
|
}
|
||||||
tmp.add(member);
|
tmp.add(member);
|
||||||
newInviteUsers.add(member.getMemberId());
|
newInviteUsers.add(member.getMemberId());
|
||||||
@@ -858,6 +879,18 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
members = loadGroupMemberFromDB(hzInstance, groupId);
|
members = loadGroupMemberFromDB(hzInstance, groupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (maxCount != Integer.MAX_VALUE) {
|
||||||
|
int existCount = 0;
|
||||||
|
for (WFCMessage.GroupMember member : members) {
|
||||||
|
if (member.getType() != GroupMemberType_Removed) {
|
||||||
|
existCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (existCount + newInviteUsers.size() > maxCount) {
|
||||||
|
return ErrorCode.ERROR_CODE_GROUP_EXCEED_MAX_MEMBER_COUNT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (WFCMessage.GroupMember member : members) {
|
for (WFCMessage.GroupMember member : members) {
|
||||||
if (newInviteUsers.contains(member.getMemberId())) {
|
if (newInviteUsers.contains(member.getMemberId())) {
|
||||||
groupMembers.remove(groupId, member);
|
groupMembers.remove(groupId, member);
|
||||||
@@ -1063,15 +1096,23 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (oldInfo.getType() == ProtoConstants.GroupType.GroupType_Normal) {
|
if (oldInfo.getType() == ProtoConstants.GroupType.GroupType_Normal) {
|
||||||
if (oldInfo.getOwner() == null) {
|
if (!operator.equals(oldInfo.getOwner())) {
|
||||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
WFCMessage.GroupMember gm = getGroupMember(groupId, operator);
|
||||||
}
|
boolean isManager = false;
|
||||||
if (!oldInfo.getOwner().equals(operator)) {
|
if (gm != null && gm.getType() == GroupMemberType_Manager) {
|
||||||
if (modifyType == Modify_Group_Extra) {
|
isManager = true;
|
||||||
|
}
|
||||||
|
if (!isManager && modifyType != Modify_Group_Name && modifyType != Modify_Group_Portrait && modifyType != Modify_Group_Extra) {
|
||||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (oldInfo.getType() == ProtoConstants.GroupType.GroupType_Free) {
|
||||||
|
if (modifyType != Modify_Group_Name && modifyType != Modify_Group_Portrait && modifyType != Modify_Group_Extra) {
|
||||||
|
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2147,6 +2188,25 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
public ErrorCode handleFriendRequest(String userId, WFCMessage.HandleFriendRequest request, WFCMessage.Message.Builder msgBuilder, long[] heads, boolean isAdmin) {
|
public ErrorCode handleFriendRequest(String userId, WFCMessage.HandleFriendRequest request, WFCMessage.Message.Builder msgBuilder, long[] heads, boolean isAdmin) {
|
||||||
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
||||||
|
|
||||||
|
if(request.getStatus() == ProtoConstants.FriendRequestStatus.RequestStatus_Accepted) {
|
||||||
|
MultiMap<String, FriendData> friendsMap = hzInstance.getMultiMap(USER_FRIENDS);
|
||||||
|
|
||||||
|
Collection<FriendData> friends = friendsMap.get(userId);
|
||||||
|
if (friends == null || friends.size() == 0) {
|
||||||
|
friends = loadFriend(friendsMap, userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (FriendData fd : friends) {
|
||||||
|
if (fd.getFriendUid().equals(request.getTargetUid())) {
|
||||||
|
if (fd.getState() == 0) {
|
||||||
|
return ErrorCode.ERROR_CODE_ALREADY_FRIENDS;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isAdmin) {
|
if (isAdmin) {
|
||||||
MultiMap<String, FriendData> friendsMap = hzInstance.getMultiMap(USER_FRIENDS);
|
MultiMap<String, FriendData> friendsMap = hzInstance.getMultiMap(USER_FRIENDS);
|
||||||
|
|
||||||
@@ -2252,10 +2312,12 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ErrorCode blackUserRequest(String fromUser, String targetUserId, int state, long[] heads) {
|
public ErrorCode blackUserRequest(String fromUser, String targetUserId, int state, long[] heads) {
|
||||||
|
if(state != 0 && state != 1 && state != 2){
|
||||||
|
return ErrorCode.INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
if (state == 2) {
|
if (state == 2) {
|
||||||
state = 1;
|
state = 1;
|
||||||
} else {
|
|
||||||
state = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
||||||
@@ -2384,6 +2446,11 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isNewFriendWelcomeMessage() {
|
||||||
|
return mFriendNewWelcomeMessage;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ErrorCode deleteFriend(String userId, String friendUid, long[] head) {
|
public ErrorCode deleteFriend(String userId, String friendUid, long[] head) {
|
||||||
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
||||||
|
|||||||
@@ -167,6 +167,7 @@ public interface IMessagesStore {
|
|||||||
|
|
||||||
ErrorCode saveAddFriendRequest(String userId, WFCMessage.AddFriendRequest request, long[] head);
|
ErrorCode saveAddFriendRequest(String userId, WFCMessage.AddFriendRequest request, long[] head);
|
||||||
ErrorCode handleFriendRequest(String userId, WFCMessage.HandleFriendRequest request, WFCMessage.Message.Builder msgBuilder, long[] heads, boolean isAdmin);
|
ErrorCode handleFriendRequest(String userId, WFCMessage.HandleFriendRequest request, WFCMessage.Message.Builder msgBuilder, long[] heads, boolean isAdmin);
|
||||||
|
boolean isNewFriendWelcomeMessage();
|
||||||
ErrorCode deleteFriend(String userId, String friendUid, long[] head);
|
ErrorCode deleteFriend(String userId, String friendUid, long[] head);
|
||||||
ErrorCode blackUserRequest(String fromUser, String targetUserId, int status, long[] head);
|
ErrorCode blackUserRequest(String fromUser, String targetUserId, int status, long[] head);
|
||||||
FriendData getFriendData(String fromUser, String targetUserId);
|
FriendData getFriendData(String fromUser, String targetUserId);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package io.moquette.spi.impl;
|
package io.moquette.spi.impl;
|
||||||
|
|
||||||
|
import cn.wildfirechat.pojos.OutputMessageData;
|
||||||
import cn.wildfirechat.proto.ProtoConstants;
|
import cn.wildfirechat.proto.ProtoConstants;
|
||||||
import cn.wildfirechat.proto.WFCMessage;
|
import cn.wildfirechat.proto.WFCMessage;
|
||||||
import cn.wildfirechat.push.PushServer;
|
import cn.wildfirechat.push.PushServer;
|
||||||
@@ -252,7 +253,7 @@ public class MessagesPublisher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!StringUtil.isNullOrEmpty(pushContent) || messageContentType == 400 || messageContentType == 402) {
|
if (!StringUtil.isNullOrEmpty(pushContent) || messageContentType == 400) {
|
||||||
if (!isSlient) {
|
if (!isSlient) {
|
||||||
targetSession.setUnReceivedMsgs(targetSession.getUnReceivedMsgs() + 1);
|
targetSession.setUnReceivedMsgs(targetSession.getUnReceivedMsgs() + 1);
|
||||||
}
|
}
|
||||||
@@ -549,7 +550,7 @@ public class MessagesPublisher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void forwardMessage(final WFCMessage.Message message, String forwardUrl) {
|
public void forwardMessage(final WFCMessage.Message message, String forwardUrl) {
|
||||||
executorCallback.execute(() -> HttpUtils.httpJsonPost(forwardUrl, new Gson().toJson(SendMessageData.fromProtoMessage(message), SendMessageData.class)));
|
executorCallback.execute(() -> HttpUtils.httpJsonPost(forwardUrl, new Gson().toJson(OutputMessageData.fromProtoMessage(message), OutputMessageData.class)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void notifyChannelListenStatusChanged(WFCMessage.ChannelInfo channelInfo, String user, boolean listen) {
|
public void notifyChannelListenStatusChanged(WFCMessage.ChannelInfo channelInfo, String user, boolean listen) {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import java.util.Date;
|
|||||||
|
|
||||||
public class MessageShardingUtil {
|
public class MessageShardingUtil {
|
||||||
private static SpinLock mLock = new SpinLock();
|
private static SpinLock mLock = new SpinLock();
|
||||||
private static int rotateId = 0;
|
private static volatile int rotateId = 0;
|
||||||
private static int nodeId = 0;
|
private static int nodeId = 0;
|
||||||
|
|
||||||
private static int rotateIdWidth = 15;
|
private static int rotateIdWidth = 15;
|
||||||
|
|||||||
+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>0.41</version>
|
<version>0.42</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ public interface APIPath {
|
|||||||
String Group_Member_Kickoff = "/admin/group/member/del";
|
String Group_Member_Kickoff = "/admin/group/member/del";
|
||||||
String Group_Member_Quit = "/admin/group/member/quit";
|
String Group_Member_Quit = "/admin/group/member/quit";
|
||||||
String Group_Set_Manager = "/admin/group/manager/set";
|
String Group_Set_Manager = "/admin/group/manager/set";
|
||||||
|
String Group_Mute_Member = "/admin/group/manager/mute";
|
||||||
String Get_User_Groups = "/admin/group/of_user";
|
String Get_User_Groups = "/admin/group/of_user";
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,9 @@ public enum ErrorCode {
|
|||||||
|
|
||||||
ERROR_CODE_NOT_IN_CHANNEL(21, "not in channel"),
|
ERROR_CODE_NOT_IN_CHANNEL(21, "not in channel"),
|
||||||
|
|
||||||
|
ERROR_CODE_ALREADY_FRIENDS(23, "already friends"),
|
||||||
|
|
||||||
|
ERROR_CODE_GROUP_EXCEED_MAX_MEMBER_COUNT(240, "group exceed max member count"),
|
||||||
ERROR_CODE_GROUP_MUTED(241, "group is muted"),
|
ERROR_CODE_GROUP_MUTED(241, "group is muted"),
|
||||||
ERROR_CODE_SENSITIVE_MATCHED(242, "sensitive matched"),
|
ERROR_CODE_SENSITIVE_MATCHED(242, "sensitive matched"),
|
||||||
ERROR_CODE_SIGN_EXPIRED(243, "sign expired"),
|
ERROR_CODE_SIGN_EXPIRED(243, "sign expired"),
|
||||||
|
|||||||
@@ -145,6 +145,8 @@ public class GroupNotificationBinaryContent {
|
|||||||
return getGroupNotifyContent(ProtoConstants.MESSAGE_CONTENT_TYPE_SET_MANAGER);
|
return getGroupNotifyContent(ProtoConstants.MESSAGE_CONTENT_TYPE_SET_MANAGER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WFCMessage.MessageContent getMuteGroupMemberNotifyContent() {
|
||||||
|
return getGroupNotifyContent(ProtoConstants.MESSAGE_CONTENT_TYPE_MUTE_MEMBER);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* 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 InputMuteGroupMember extends InputGroupBase {
|
||||||
|
private String group_id;
|
||||||
|
private List<String> members;
|
||||||
|
private boolean is_manager;
|
||||||
|
|
||||||
|
public String getGroup_id() {
|
||||||
|
return group_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroup_id(String group_id) {
|
||||||
|
this.group_id = group_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getMembers() {
|
||||||
|
return members;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMembers(List<String> members) {
|
||||||
|
this.members = members;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isIs_manager() {
|
||||||
|
return is_manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIs_manager(boolean is_manager) {
|
||||||
|
this.is_manager = is_manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isValide() {
|
||||||
|
if (StringUtil.isNullOrEmpty(operator) || StringUtil.isNullOrEmpty(group_id) || members == null || members.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WFCMessage.SetGroupManagerRequest toProtoGroupRequest() {
|
||||||
|
WFCMessage.SetGroupManagerRequest.Builder addGroupBuilder = WFCMessage.SetGroupManagerRequest.newBuilder();
|
||||||
|
addGroupBuilder.setGroupId(group_id);
|
||||||
|
addGroupBuilder.addAllUserId(members);
|
||||||
|
addGroupBuilder.setType(is_manager ? 1 : 0);
|
||||||
|
|
||||||
|
if (to_lines != null) {
|
||||||
|
for (Integer line : to_lines
|
||||||
|
) {
|
||||||
|
addGroupBuilder.addToLine(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (notify_message != null) {
|
||||||
|
addGroupBuilder.setNotifyContent(notify_message.toProtoMessageContent());
|
||||||
|
}
|
||||||
|
return addGroupBuilder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -28,6 +28,8 @@ public class MessagePayload {
|
|||||||
private int expireDuration;
|
private int expireDuration;
|
||||||
private int mentionedType;
|
private int mentionedType;
|
||||||
private List<String> mentionedTarget;
|
private List<String> mentionedTarget;
|
||||||
|
private String extra;
|
||||||
|
|
||||||
|
|
||||||
public int getType() {
|
public int getType() {
|
||||||
return type;
|
return type;
|
||||||
@@ -117,6 +119,14 @@ public class MessagePayload {
|
|||||||
this.mentionedTarget = mentionedTarget;
|
this.mentionedTarget = mentionedTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getExtra() {
|
||||||
|
return extra;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExtra(String extra) {
|
||||||
|
this.extra = extra;
|
||||||
|
}
|
||||||
|
|
||||||
public WFCMessage.MessageContent toProtoMessageContent() {
|
public WFCMessage.MessageContent toProtoMessageContent() {
|
||||||
WFCMessage.MessageContent.Builder builder = WFCMessage.MessageContent.newBuilder()
|
WFCMessage.MessageContent.Builder builder = WFCMessage.MessageContent.newBuilder()
|
||||||
.setType(type)
|
.setType(type)
|
||||||
@@ -137,6 +147,8 @@ public class MessagePayload {
|
|||||||
builder.setRemoteMediaUrl(remoteMediaUrl);
|
builder.setRemoteMediaUrl(remoteMediaUrl);
|
||||||
if (mentionedTarget != null && mentionedTarget.size() > 0)
|
if (mentionedTarget != null && mentionedTarget.size() > 0)
|
||||||
builder.addAllMentionedTarget(mentionedTarget);
|
builder.addAllMentionedTarget(mentionedTarget);
|
||||||
|
if (!StringUtil.isNullOrEmpty(extra))
|
||||||
|
builder.setExtra(extra);
|
||||||
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
@@ -159,6 +171,7 @@ public class MessagePayload {
|
|||||||
payload.mentionedType = protoContent.getMentionedType();
|
payload.mentionedType = protoContent.getMentionedType();
|
||||||
payload.mentionedTarget = new ArrayList<>();
|
payload.mentionedTarget = new ArrayList<>();
|
||||||
payload.mentionedTarget.addAll(protoContent.getMentionedTargetList());
|
payload.mentionedTarget.addAll(protoContent.getMentionedTargetList());
|
||||||
|
payload.extra = protoContent.getExtra();
|
||||||
return payload;
|
return payload;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
* 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 OutputMessageData {
|
||||||
|
private long messageId;
|
||||||
|
private String sender;
|
||||||
|
private Conversation conv;
|
||||||
|
private MessagePayload payload;
|
||||||
|
private List<String> toUsers;
|
||||||
|
private long timestamp;
|
||||||
|
|
||||||
|
public String getSender() {
|
||||||
|
return sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSender(String sender) {
|
||||||
|
this.sender = sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Conversation getConv() {
|
||||||
|
return conv;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConv(Conversation conv) {
|
||||||
|
this.conv = conv;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessagePayload getPayload() {
|
||||||
|
return payload;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPayload(MessagePayload payload) {
|
||||||
|
this.payload = payload;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getToUsers() {
|
||||||
|
return toUsers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setToUsers(List<String> toUsers) {
|
||||||
|
this.toUsers = toUsers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getMessageId() {
|
||||||
|
return messageId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessageId(long messageId) {
|
||||||
|
this.messageId = messageId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTimestamp() {
|
||||||
|
return timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimestamp(long timestamp) {
|
||||||
|
this.timestamp = timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static OutputMessageData fromProtoMessage(WFCMessage.Message protoMessage) {
|
||||||
|
OutputMessageData data = new OutputMessageData();
|
||||||
|
data.messageId = protoMessage.getMessageId();
|
||||||
|
data.sender = protoMessage.getFromUser();
|
||||||
|
data.conv = new Conversation();
|
||||||
|
data.conv.setTarget(protoMessage.getConversation().getTarget());
|
||||||
|
data.conv.setType(protoMessage.getConversation().getType());
|
||||||
|
data.conv.setLine(protoMessage.getConversation().getLine());
|
||||||
|
data.payload = MessagePayload.fromProtoMessageContent(protoMessage.getContent());
|
||||||
|
data.timestamp = protoMessage.getServerTimestamp();
|
||||||
|
data.toUsers = protoMessage.getToList();
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -181,5 +181,6 @@ public class ProtoConstants {
|
|||||||
public static final int MESSAGE_CONTENT_TYPE_CHANGE_SEARCHABLE = 116;
|
public static final int MESSAGE_CONTENT_TYPE_CHANGE_SEARCHABLE = 116;
|
||||||
|
|
||||||
public static final int MESSAGE_CONTENT_TYPE_SET_MANAGER = 117;
|
public static final int MESSAGE_CONTENT_TYPE_SET_MANAGER = 117;
|
||||||
|
public static final int MESSAGE_CONTENT_TYPE_MUTE_MEMBER = 118;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -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>0.41</version>
|
<version>0.42</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>distribution</artifactId>
|
<artifactId>distribution</artifactId>
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
<!--关闭连接时,是否提交未提交的事务,默认为false,即关闭连接,回滚未提交的事务 -->
|
<!--关闭连接时,是否提交未提交的事务,默认为false,即关闭连接,回滚未提交的事务 -->
|
||||||
<property name="autoCommitOnClose">false</property>
|
<property name="autoCommitOnClose">false</property>
|
||||||
<!--c3p0将建一张名为Test的空表,并使用其自带的查询语句进行测试。如果定义了这个参数那么属性preferredTestQuery将被忽略。你不能在这张Test表上进行任何操作,它将只供c3p0测试使用。默认值: null -->
|
<!--c3p0将建一张名为Test的空表,并使用其自带的查询语句进行测试。如果定义了这个参数那么属性preferredTestQuery将被忽略。你不能在这张Test表上进行任何操作,它将只供c3p0测试使用。默认值: null -->
|
||||||
<property name="automaticTestTable">Test</property>
|
<!-- <property name="automaticTestTable">Test</property>-->
|
||||||
<!--如果为false,则获取连接失败将会引起所有等待连接池来获取连接的线程抛出异常,但是数据源仍有效保留,并在下次调用getConnection()的时候继续尝试获取连接。如果设为true,那么在尝试获取连接失败后该数据源将申明已断开并永久关闭。默认: false-->
|
<!--如果为false,则获取连接失败将会引起所有等待连接池来获取连接的线程抛出异常,但是数据源仍有效保留,并在下次调用getConnection()的时候继续尝试获取连接。如果设为true,那么在尝试获取连接失败后该数据源将申明已断开并永久关闭。默认: false-->
|
||||||
<property name="breakAfterAcquireFailure">false</property>
|
<property name="breakAfterAcquireFailure">false</property>
|
||||||
<!--每60秒检查所有连接池中的空闲连接。默认值: 0,不检查 -->
|
<!--每60秒检查所有连接池中的空闲连接。默认值: 0,不检查 -->
|
||||||
|
|||||||
@@ -46,10 +46,12 @@ token.key testim
|
|||||||
##token的过期时间,单位为毫秒,默认为无限期。如果需要设置无限期,客户端上一定需要加上token过期的处理。token过期的处理请参考文档的常见问题
|
##token的过期时间,单位为毫秒,默认为无限期。如果需要设置无限期,客户端上一定需要加上token过期的处理。token过期的处理请参考文档的常见问题
|
||||||
##token.expire_time 2592000000
|
##token.expire_time 2592000000
|
||||||
|
|
||||||
##首次登录,是否接收之前的历史消息。0 不接收;1接收。
|
##首次登录,是否接收之前的历史消息。
|
||||||
|
##0 不接收历史消息,只接收5分钟以内的消息,由于服务器没有保存已经收取记录,所以如果有超过5分钟之前未收取的消息也不会收取下拉;
|
||||||
|
##1接收,会接收 message.max_queue 配置的条数的历史消息
|
||||||
message.roaming 0
|
message.roaming 0
|
||||||
|
|
||||||
##是否开启拉取远程历史消息
|
##是否开启拉取远程历史消息。如果为1,客户端在会话内如果本地消息读取完了,可以下拉继续加载在服务器上的该会话的消息;如果为0则不能。
|
||||||
message.remote_history_message 0
|
message.remote_history_message 0
|
||||||
|
|
||||||
##服务器为每个用户缓存的消息数量。这个值改得太大,拉取消息时间变长,另外会占用大量内存。
|
##服务器为每个用户缓存的消息数量。这个值改得太大,拉取消息时间变长,另外会占用大量内存。
|
||||||
@@ -83,6 +85,12 @@ friend.reject_request_duration 2592000000
|
|||||||
##好友请求过期时间,单位是毫秒,默认是7天,0为不限制
|
##好友请求过期时间,单位是毫秒,默认是7天,0为不限制
|
||||||
friend.request_expiration_duration 604800000
|
friend.request_expiration_duration 604800000
|
||||||
|
|
||||||
|
##添加好友后会发送欢迎消息,比如"你们已经是好友了,可以聊天了"。这个开关控制是用旧的方式还是用新的方式。
|
||||||
|
##旧的方式会发送notification消息(contenttype是80),内容会根据好友接收者的语言选择对应的语言,如果双方语言不一致会导致另外一方看到的不是本地语言。
|
||||||
|
##新的方式会发送添加好友消息(contenttype是93)和欢迎消息(contenttype是92),需要客户端实现这两种消息。
|
||||||
|
##如果客户端已经实现这两种消息可以打开这个开关
|
||||||
|
friend.new_welcome_message false
|
||||||
|
|
||||||
## 聊天室观众空闲退出时间,单位为毫秒,默认为15分钟,0为永远不退出
|
## 聊天室观众空闲退出时间,单位为毫秒,默认为15分钟,0为永远不退出
|
||||||
chatroom.participant_idle_time 900000
|
chatroom.participant_idle_time 900000
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
<artifactId>wildfirechat-parent</artifactId>
|
<artifactId>wildfirechat-parent</artifactId>
|
||||||
|
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<version>0.41</version>
|
<version>0.42</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>
|
||||||
|
|||||||
+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>0.41</version>
|
<version>0.42</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class GroupAdmin {
|
|||||||
return AdminHttpUtils.httpJsonPost(path, transferGroup, Void.class);
|
return AdminHttpUtils.httpJsonPost(path, transferGroup, Void.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IMResult<Void> modifyGroupInfo(String operator, String groupId, int type, String value, List<Integer> to_lines) throws Exception {
|
public static IMResult<Void> modifyGroupInfo(String operator, String groupId, /*ModifyGroupInfoType*/int type, String value, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||||
String path = APIPath.Group_Modify_Info;
|
String path = APIPath.Group_Modify_Info;
|
||||||
InputModifyGroupInfo modifyGroupInfo = new InputModifyGroupInfo();
|
InputModifyGroupInfo modifyGroupInfo = new InputModifyGroupInfo();
|
||||||
modifyGroupInfo.setGroup_id(groupId);
|
modifyGroupInfo.setGroup_id(groupId);
|
||||||
@@ -60,6 +60,7 @@ public class GroupAdmin {
|
|||||||
modifyGroupInfo.setTo_lines(to_lines);
|
modifyGroupInfo.setTo_lines(to_lines);
|
||||||
modifyGroupInfo.setType(type);
|
modifyGroupInfo.setType(type);
|
||||||
modifyGroupInfo.setValue(value);
|
modifyGroupInfo.setValue(value);
|
||||||
|
modifyGroupInfo.setNotify_message(notify_message);
|
||||||
return AdminHttpUtils.httpJsonPost(path, modifyGroupInfo, Void.class);
|
return AdminHttpUtils.httpJsonPost(path, modifyGroupInfo, Void.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +101,17 @@ public class GroupAdmin {
|
|||||||
return AdminHttpUtils.httpJsonPost(path, addGroupMember, Void.class);
|
return AdminHttpUtils.httpJsonPost(path, addGroupMember, Void.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IMResult<Void> muteGroupMemeber(String operator, String groupId, List<String> groupMemberIds, boolean isManager, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||||
|
String path = APIPath.Group_Mute_Member;
|
||||||
|
InputMuteGroupMember addGroupMember = new InputMuteGroupMember();
|
||||||
|
addGroupMember.setGroup_id(groupId);
|
||||||
|
addGroupMember.setMembers(groupMemberIds);
|
||||||
|
addGroupMember.setIs_manager(isManager);
|
||||||
|
addGroupMember.setOperator(operator);
|
||||||
|
addGroupMember.setTo_lines(to_lines);
|
||||||
|
addGroupMember.setNotify_message(notify_message);
|
||||||
|
return AdminHttpUtils.httpJsonPost(path, addGroupMember, Void.class);
|
||||||
|
}
|
||||||
|
|
||||||
public static IMResult<Void> kickoffGroupMembers(String operator, String groupId, List<String> groupMemberIds, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
public static IMResult<Void> kickoffGroupMembers(String operator, String groupId, List<String> groupMemberIds, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||||
String path = APIPath.Group_Member_Kickoff;
|
String path = APIPath.Group_Member_Kickoff;
|
||||||
@@ -130,5 +141,4 @@ public class GroupAdmin {
|
|||||||
return AdminHttpUtils.httpJsonPost(path, inputUserId, OutputGroupIds.class);
|
return AdminHttpUtils.httpJsonPost(path, inputUserId, OutputGroupIds.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ public class Main {
|
|||||||
testChatroom();
|
testChatroom();
|
||||||
testMessage();
|
testMessage();
|
||||||
testGeneralApi();
|
testGeneralApi();
|
||||||
|
testDevice();
|
||||||
|
|
||||||
System.out.println("Congratulation, all admin test case passed!!!!!!!");
|
System.out.println("Congratulation, all admin test case passed!!!!!!!");
|
||||||
}
|
}
|
||||||
@@ -351,7 +352,7 @@ public class Main {
|
|||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
voidIMResult = GroupAdmin.modifyGroupInfo(groupInfo.getOwner(), groupInfo.getTarget_id(), ProtoConstants.ModifyGroupInfoType.Modify_Group_Name,"HelloWorld", null);
|
voidIMResult = GroupAdmin.modifyGroupInfo(groupInfo.getOwner(), groupInfo.getTarget_id(), ProtoConstants.ModifyGroupInfoType.Modify_Group_Name,"HelloWorld", null, null);
|
||||||
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
System.out.println("transfer success");
|
System.out.println("transfer success");
|
||||||
} else {
|
} else {
|
||||||
@@ -413,6 +414,23 @@ public class Main {
|
|||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
voidIMResult = GroupAdmin.muteGroupMemeber("user1", groupInfo.getTarget_id(), Arrays.asList("user4", "user5"), true, null, null);
|
||||||
|
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
|
System.out.println("mute group member success");
|
||||||
|
} else {
|
||||||
|
System.out.println("mute group member failure");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
voidIMResult = GroupAdmin.muteGroupMemeber("user1", groupInfo.getTarget_id(), Arrays.asList("user4", "user5"), false, null, null);
|
||||||
|
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
|
System.out.println("unmute group member success");
|
||||||
|
} else {
|
||||||
|
System.out.println("unmute group member failure");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
voidIMResult = GroupAdmin.quitGroup("user4", groupInfo.getTarget_id(), null, null);
|
voidIMResult = GroupAdmin.quitGroup("user4", groupInfo.getTarget_id(), null, null);
|
||||||
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
|
|||||||
Reference in New Issue
Block a user