Compare commits

..
48 Commits
Author SHA1 Message Date
imhao183 069770c411 version 0.42 -> 0.43 2020-08-01 18:54:55 +08:00
imhao183 1f5f7eb572 修正推送数据中unread message count不准确的问题 2020-08-01 09:25:24 +08:00
imhao183 405ad6c121 fix build error 2020-07-27 16:10:58 +08:00
imhao183 ff6e94cee7 remove useless errorcode 2020-07-22 11:53:15 +08:00
imhao183 db6f273cba fix build error 2020-07-21 22:13:11 +08:00
imhao183 df3bace44b 创建群组时添加更多的参数 2020-07-21 22:07:50 +08:00
heavyrain.lee 3f9a8be02c Update ISSUE_TEMPLATE.md 2020-07-17 12:03:42 +08:00
imhao183 39eb08e3f2 消息过期错误修改 2020-07-16 17:55:34 +08:00
imhao183 22a4ef4f42 修正撤回消息时异常信息问题 2020-07-16 15:22:21 +08:00
imhao183 da0d2e22cc message content add push attribute 2020-07-15 08:15:54 +08:00
imhao183 a80ef20da3 message content add push data attribute 2020-07-15 08:12:00 +08:00
imhao183 45fd11f641 修正黑名单问题 2020-07-13 21:21:37 +08:00
imhao183 cdc731a23b update 2020-07-10 11:34:32 +08:00
imhao183 68a968a94c 避免数据库表中的列名与某些数据库关键字冲突 2020-07-09 16:48:45 +08:00
imhao183 8604f4edf3 添加注释 2020-07-09 16:48:15 +08:00
imndx b1484b0c95 fix recall message issue 2020-07-06 16:02:11 +08:00
imhao183 631986f7a2 更新说明 2020-07-06 12:36:28 +08:00
imhao183 db27e77303 添加说明 2020-07-03 20:47:44 +08:00
imhao183 5177779066 fix server api group operation failure issue 2020-07-01 14:20:04 +08:00
imhao183 c4a764d81d update 2020-07-01 11:22:20 +08:00
imhao183 2c5ae2bd86 update version to 0.42 2020-07-01 11:04:42 +08:00
imhao183 b11d609ea0 update 2020-07-01 11:04:10 +08:00
imhao183 b8170c4757 修改好友欢迎提示方式,默认为关,需要在客户端上实现后打开 2020-06-30 17:15:53 +08:00
imhao183 e42d6f8e4f fix sql error 2020-06-25 16:07:49 +08:00
imhao183 e0c95bace9 数据库group表添加2个字段 2020-06-25 16:00:08 +08:00
imhao183 8623223991 添加群成员时,检查系统群最大成员数 2020-06-24 11:57:15 +08:00
heavyrain.lee efdcc24067 Update README.md 2020-06-24 09:26:46 +08:00
imhao183 ec18e40eb0 normal 类型的群组群成员可以修改群名称头像和extra,群主和群管理可以修改所有信息 2020-06-22 21:50:17 +08:00
heavyrain2012 f9d970c730 server api 发送接口添加extra字段 2020-06-18 17:22:45 +08:00
imhao183 590b02cc8e session修改成同步操作 2020-06-16 17:01:59 +08:00
imhao183 f2f75d3048 计数问题修正 2020-06-12 07:54:28 +08:00
imhao183 94466139f6 群成员增加加入时间字段 2020-06-11 20:58:24 +08:00
imhao183 70aeff9ac5 更新协议,在群成员数据结构中添加创建时间属性 2020-06-11 15:47:40 +08:00
imndx 7e56fe2ee0 参数校验 2020-06-09 17:11:48 +08:00
imndx 599547d627 修复黑名单问题. fix #213, fix #212 2020-06-09 16:53:24 +08:00
imhao183 28600ea7f9 修正文件名中带有&字符错误问题 2020-06-08 21:43:12 +08:00
heavyrain2012 a73507c673 解决群组通知line错误问题 2020-06-08 19:10:13 +08:00
imhao183 84b8d4cd09 fix build error 2020-06-04 07:47:11 +08:00
imhao183 b66aa3d634 消息转发时带上消息ID和时间戳 2020-06-04 07:44:11 +08:00
imhao183 508beaf62c SDK增加群内成员禁言功能 2020-05-24 19:02:39 +08:00
imhao183 e914afedf4 同步专业版数据库 2020-05-23 17:25:52 +08:00
heavyrain.lee 49c32d7fa1 Update README.md 2020-05-20 07:02:32 +08:00
imhao183 aac106d37e 更新注释 2020-05-15 09:51:31 +08:00
imhao183 8bd17a8093 更新注释 2020-05-13 19:16:15 +08:00
imhao183 b1f07f49ff api接口获取群成员信息时,过滤掉已删除成员 2020-05-11 12:12:51 +08:00
imhao183 86dddfd85f fix build error 2020-05-11 08:33:09 +08:00
imhao183 db733efc44 解决SDK中修改群信息的接口缺少自定义消息的问题 2020-05-06 21:00:41 +08:00
imhao183 69f28bd35b 当接受好友邀请时,如果已经是好友,返回“已经是好友”的错误码 2020-05-06 20:50:15 +08:00
43 changed files with 1038 additions and 2119 deletions
+12 -8
View File
@@ -1,13 +1,17 @@
### Expected behavior
## 提issue小提示
为了尽快定位问题,需要提供足够的信息,请按照我们的要求格式来提问。***如果您不按照格式提问,我们将无法回复您的问题***
### Actual behavior
#### 操作说明
详细说明操作那个界面,每一步骤都要说得详细,如果是SDK或者api使用问题,需要详细说明调用的那个函数,参数都是什么。
### Steps to reproduce
#### 表现现象
描述一下什么现象,比如说函数返回error,errorcode是多少,或者界面上是什么状态,比如发送消息显示发送失败的红点。不要笼统的说功能有问题,不起作用。
### Minimal yet complete reproducer code (or URL to code) or complete log file
#### 预期结果
你认为正确的表现应该是什么样的。
### Moquette MQTT version
#### 补充条件
是否是毕现的,还是偶现的?是否只有在特殊的网络/设备/平台上出现,还是所有的都出现。还有您用的版本是什么时候的,是不是最新版
### JVM version (e.g. `java -version`)
### OS version (e.g. `uname -a`)
#### demo对比结果
请用demo对比测试,demo上是什么状态。
+3 -9
View File
@@ -43,11 +43,6 @@
![野火IM](http://static.wildfirechat.cn/download_qrcode.png)
#### 加入野火官方体验交流群
使用野火IM移动客户端扫码下面二维码(不是使用微信扫码),和野火IM的爱好者一起畅谈野火IM的问题和经验:
![野火IM官方交流群](http://static.wildfirechat.cn/wildfirechat_official_group.jpeg)
#### 应用截图
![ios-demo](http://static.wildfirechat.cn/ios-demo.gif)
@@ -73,12 +68,11 @@
## 编译
在安装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) | ![SAMOS](http://static.wildfirechat.cn/SAMOS.png) | 保密 | 一站式区块链解决方案服务商(http://samos.io) |
## 特别感谢
1. [moquette](https://github.com/moquette-io/moquette) 本项目是基于此项目二次开发而来,处理MQTT相关业务。
+14 -4
View File
@@ -55,10 +55,12 @@ token.key testim
##token的过期时间,单位为毫秒,默认为无限期。如果需要设置无限期,客户端上一定需要加上token过期的处理。token过期的处理请参考文档的常见问题
##token.expire_time 2592000000
##首次登录,是否接收之前的历史消息。0 不接收;1接收。
##首次登录,是否接收之前的历史消息。
##0 不接收历史消息,只接收5分钟以内的消息,由于服务器没有保存已经收取记录,所以如果有超过5分钟之前未收取的消息也不会收取下拉;
##1接收,会接收 message.max_queue 配置的条数的历史消息
message.roaming 0
##是否开启拉取远程历史消息
##是否开启拉取远程历史消息。如果为1,客户端在会话内如果本地消息读取完了,可以下拉继续加载在服务器上的该会话的消息;如果为0则不能。
message.remote_history_message 0
##服务器为每个用户缓存的消息数量。这个值改得太大,拉取消息时间变长,另外会占用大量内存。
@@ -92,6 +94,12 @@ friend.reject_request_duration 2592000000
##好友请求过期时间,单位是毫秒,默认是7天,0为不限制
friend.request_expiration_duration 604800000
##添加好友后会发送欢迎消息,比如"你们已经是好友了,可以聊天了"。这个开关控制是用旧的方式还是用新的方式。
##旧的方式会发送notification消息(contenttype是80),内容会根据好友接收者的语言选择对应的语言,如果双方语言不一致会导致另外一方看到的不是本地语言。
##新的方式会发送添加好友消息(contenttype是93)和欢迎消息(contenttype是92),需要客户端实现这两种消息。
##如果客户端已经实现这两种消息可以打开这个开关
friend.new_welcome_message false
## 聊天室观众空闲退出时间,单位为毫秒,默认为15分钟,0为永远不退出
chatroom.participant_idle_time 900000
@@ -146,10 +154,10 @@ qiniu.bucket_favorite_domain http://cdn2.wildfirechat.cn
# 本地媒体服务器配置。
local.media.storage.root media
# 是否支持多端登陆
# 是否支持多端登陆,为true时支持任意平台任意多个客户端同时登录;为false时每个平台只支持一个端登录,但不同平台可以同时登录。
server.multi_endpoint false
# 多平台连接状态通知(仅当multi_endpoint为false时有效)
# 多平台连接状态通知(仅当multi_endpoint为false时有效),true时移动端可以收到pc或web端登录的通知。
server.multi_platform_notification false
#*********************************************************************
@@ -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://wfc:123456@localhost:27017/wfchat
mongodb.database wfchat
#仅在第一次启动时会设置消息数据的过期时间,如果之后再修改将不生效。
#如果需要修改过期时间,请修改t_messages_x和t_user_message_x的索引过期时间,修改方法请行百度
mongodb.data_expire_days 1096
#*********************************************************************
+42
View File
@@ -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)
);
+1
View File
@@ -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;
+2
View File
@@ -0,0 +1,2 @@
alter table `t_settings` change column `value` `_value` varchar(64) NOT NULL;
alter table `t_settings` change column `desc` `_desc` varchar(64) NOT NULL;
+54
View File
@@ -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;
+1
View File
@@ -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";
+2
View File
@@ -0,0 +1,2 @@
alter table `t_settings` change column `value` `_value` varchar(64) NOT NULL;
alter table `t_settings` change column `desc` `_desc` varchar(64) NOT NULL;
@@ -0,0 +1,6 @@
程序会自动创建数据库和执行migrate里的数据库,不需要手动创建库和执行sql语句。
数据库版本管理使用了flyway,flyway进行数据库升级时会校验数据库脚本的有效性,如果修改过这里的脚本,下次升级时就会失败。
强烈不建议修改数据库表结构,如果有内容(比如默认用户或者默认机器人的属性)需要修改,可以等数据库升级完成后,通过命令行或者数据库客户端进行修改。
由于服务具有缓存,一般修改过数据库内容后要重启后才能生效。
+1 -1
View File
@@ -5,7 +5,7 @@
<relativePath>../</relativePath>
<artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId>
<version>0.41</version>
<version>0.43</version>
</parent>
<artifactId>moquette-broker</artifactId>
@@ -23,6 +23,7 @@ public class PushMessage {
//推送类型,android推送分为小米/华为/魅族等。ios分别为开发和发布。
public int pushType;
public String pushContent;
public String pushData;
public int unReceivedMsg;
public int mentionedType;
public String packageName;
@@ -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;
}
@@ -14,6 +14,7 @@ import cn.wildfirechat.pojos.InputGetGroup;
import cn.wildfirechat.pojos.OutputGroupMemberList;
import cn.wildfirechat.pojos.PojoGroupInfo;
import cn.wildfirechat.pojos.PojoGroupMember;
import cn.wildfirechat.proto.ProtoConstants;
import cn.wildfirechat.proto.WFCMessage;
import com.google.gson.Gson;
import com.xiaoleilu.loServer.RestResult;
@@ -56,6 +57,9 @@ public class GetGroupMembersAction extends AdminAction {
OutputGroupMemberList out = new OutputGroupMemberList();
out.setMembers(new ArrayList<>());
for (WFCMessage.GroupMember member : members) {
if (member.getType() == ProtoConstants.GroupMemberType.GroupMemberType_Removed) {
continue;
}
PojoGroupMember pm = new PojoGroupMember();
pm.setMember_id(member.getMemberId());
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_Reject_Request_Duration = "friend.reject_request_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_Rejoin_When_Active = "chatroom.rejoin_when_active";
@@ -17,8 +17,10 @@ import java.util.List;
abstract public class GroupHandler<T> extends IMHandler<T> {
protected void sendGroupNotification(String fromUser, String targetId, List<Integer> lines, WFCMessage.MessageContent content) {
if (lines != null) {
if (lines == null) {
lines = new ArrayList<>();
} else {
lines = new ArrayList<>(lines);
}
if (lines.isEmpty()) {
@@ -43,7 +43,12 @@ public class HandleFriendRequestHandler extends IMHandler<WFCMessage.HandleFrien
if (session != null && !StringUtil.isNullOrEmpty(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.setFromUser(request.getTargetUid());
@@ -56,7 +61,12 @@ public class HandleFriendRequestHandler extends IMHandler<WFCMessage.HandleFrien
builder.setMessageId(messageId);
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);
messageId = MessageShardingUtil.generateId();
builder.setMessageId(messageId);
@@ -86,10 +86,10 @@ public class DatabaseStore {
try {
connection = DBUtil.getConnection();
String sql = "insert into t_settings " +
" (`id`, `value`, `desc`) values(?, ?, ?)" +
" (`id`, `_value`, `_desc`) values(?, ?, ?)" +
" ON DUPLICATE KEY UPDATE " +
"`value` = ?," +
"`desc` = ?";
"`_value` = ?," +
"`_desc` = ?";
statement = connection.prepareStatement(sql);
@@ -120,7 +120,7 @@ public class DatabaseStore {
try {
connection = DBUtil.getConnection();
String sql = "select `value`, `desc` from t_settings where `id` = ?";
String sql = "select `_value`, `_desc` from t_settings where `id` = ?";
statement = connection.prepareStatement(sql);
int index = 1;
@@ -331,7 +331,7 @@ public class DatabaseStore {
String sql = "select `_mid`" +
", `_alias`" +
", `_type`" +
", `_dt` from t_group_member where _gid = ?";
", `_dt`, `_create_dt` from t_group_member where _gid = ?";
statement = connection.prepareStatement(sql);
statement.setString(1, groupId);
@@ -358,6 +358,9 @@ public class DatabaseStore {
long longValue = rs.getLong(index++);
builder.setUpdateDt(longValue);
longValue = rs.getLong(index++);
builder.setCreateDt(longValue);
WFCMessage.GroupMember member = builder.build();
groupMembers.put(groupId, member);
}
@@ -823,7 +826,16 @@ public class DatabaseStore {
}
}
WFCMessage.Message message = builder.build();
messages.add(message);
boolean expired = false;
if (message.getContent().getExpireDuration() > 0) {
if (System.currentTimeMillis() > message.getServerTimestamp() + message.getContent().getExpireDuration()*1000) {
expired = true;
}
}
if (!expired) {
messages.add(message);
}
}
if (count == 0) {
@@ -1338,7 +1350,6 @@ public class DatabaseStore {
}
void updateSessionDeleted(String uid, String cid, int deleted) {
mScheduler.execute(()->{
Connection connection = null;
PreparedStatement statement = null;
@@ -1363,11 +1374,9 @@ public class DatabaseStore {
} finally {
DBUtil.closeDB(connection, statement);
}
});
}
void updateSessionPlatform(String uid, String cid, int platform) {
mScheduler.execute(()->{
Connection connection = null;
PreparedStatement statement = null;
@@ -1392,7 +1401,6 @@ public class DatabaseStore {
} finally {
DBUtil.closeDB(connection, statement);
}
});
}
private boolean strEqual(String left, String right) {
@@ -1652,7 +1660,7 @@ public class DatabaseStore {
", `_mid`" +
", `_alias`" +
", `_type`" +
", `_dt`) values(?, ?, ?, ?, ?)" +
", `_dt`, `_create_dt`) values(?, ?, ?, ?, ?, ?)" +
" ON DUPLICATE KEY UPDATE " +
"`_alias` = ?," +
"`_type` = ?," +
@@ -1673,6 +1681,7 @@ public class DatabaseStore {
statement.setString(index++, member.getAlias());
statement.setInt(index++, member.getType());
statement.setLong(index++, dt);
statement.setLong(index++, member.getCreateDt());
statement.setString(index++, member.getAlias());
statement.setInt(index++, member.getType());
statement.setLong(index++, dt);
@@ -34,6 +34,7 @@ import io.moquette.spi.IMessagesStore;
import io.moquette.spi.security.Tokenor;
import io.moquette.spi.impl.subscriptions.Topic;
import io.netty.handler.codec.mqtt.MqttVersion;
import org.json.simple.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import win.liyufan.im.*;
@@ -127,6 +128,7 @@ public class MemoryMessagesStore implements IMessagesStore {
private long mFriendRequestDuration = 7 * 24 * 60 * 60 * 1000;
private long mFriendRejectDuration = 30 * 24 * 60 * 60 * 1000;
private long mFriendRequestExpiration = 7 * 24 * 60 * 60 * 1000;
private boolean mFriendNewWelcomeMessage = false;
private boolean mMultiPlatformNotification = false;
private boolean mDisableStrangerChat = false;
@@ -204,6 +206,15 @@ public class MemoryMessagesStore implements IMessagesStore {
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 {
mChatroomRejoinWhenActive = Boolean.parseBoolean(m_Server.getConfig().getProperty(BrokerConstants.CHATROOM_Rejoin_When_Active));
} catch (Exception e) {
@@ -482,7 +493,7 @@ public class MemoryMessagesStore implements IMessagesStore {
}
if (bundle.getMessage().getContent().getExpireDuration() > 0) {
if (System.currentTimeMillis() < bundle.getMessage().getServerTimestamp() + bundle.getMessage().getContent().getExpireDuration()) {
if (System.currentTimeMillis() > bundle.getMessage().getServerTimestamp() + bundle.getMessage().getContent().getExpireDuration()*1000) {
continue;
}
}
@@ -576,6 +587,12 @@ public class MemoryMessagesStore implements IMessagesStore {
MessageBundle bundle = mIMap.get(targetMessageId);
if (bundle != null) {
if (exceptClientId == null || !exceptClientId.equals(bundle.getFromClientId()) || !fromUser.equals(bundle.getFromUser())) {
if (bundle.getMessage().getContent().getExpireDuration() > 0) {
if (System.currentTimeMillis() > bundle.getMessage().getServerTimestamp() + bundle.getMessage().getContent().getExpireDuration() * 1000) {
continue;
}
}
size += bundle.getMessage().getSerializedSize();
if (size >= 3 * 1024 * 1024) { //3M
break;
@@ -781,9 +798,9 @@ public class MemoryMessagesStore implements IMessagesStore {
List<WFCMessage.GroupMember> updatedMemberList = new ArrayList<>();
for (WFCMessage.GroupMember member : memberList) {
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 {
member = member.toBuilder().setUpdateDt(dt).build();
member = member.toBuilder().setUpdateDt(dt).setCreateDt(dt).build();
}
groupMembers.put(groupId, member);
updatedMemberList.add(member);
@@ -806,6 +823,8 @@ public class MemoryMessagesStore implements IMessagesStore {
}
int maxCount = Integer.MAX_VALUE;
if (!isAdmin) {
boolean isMember = false;
boolean isManager = false;
@@ -835,6 +854,15 @@ public class MemoryMessagesStore implements IMessagesStore {
if (!isMember && !(memberList.size() == 1 && operator.equals(memberList.get(0).getMemberId()))) {
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();
@@ -843,9 +871,9 @@ public class MemoryMessagesStore implements IMessagesStore {
ArrayList<String> newInviteUsers = new ArrayList<>();
for (WFCMessage.GroupMember member : memberList) {
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 {
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);
newInviteUsers.add(member.getMemberId());
@@ -858,6 +886,18 @@ public class MemoryMessagesStore implements IMessagesStore {
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) {
if (newInviteUsers.contains(member.getMemberId())) {
groupMembers.remove(groupId, member);
@@ -1063,15 +1103,23 @@ public class MemoryMessagesStore implements IMessagesStore {
}
if (oldInfo.getType() == ProtoConstants.GroupType.GroupType_Normal) {
if (oldInfo.getOwner() == null) {
return ErrorCode.ERROR_CODE_NOT_RIGHT;
}
if (!oldInfo.getOwner().equals(operator)) {
if (modifyType == Modify_Group_Extra) {
if (!operator.equals(oldInfo.getOwner())) {
WFCMessage.GroupMember gm = getGroupMember(groupId, operator);
boolean isManager = false;
if (gm != null && gm.getType() == GroupMemberType_Manager) {
isManager = true;
}
if (!isManager && modifyType != Modify_Group_Name && modifyType != Modify_Group_Portrait && modifyType != Modify_Group_Extra) {
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;
}
}
}
@@ -1428,9 +1476,16 @@ public class MemoryMessagesStore implements IMessagesStore {
}
String searchContent = message.getContent().getSearchableContent() == null ? "" : message.getContent().getSearchableContent();
String cont = message.getContent().getContent() == null ? "" : message.getContent().getContent();
String extra = message.getContent().getExtra() == null ? "" : message.getContent().getExtra();
String recalledContent = "{\"s\":\"" + message.getFromUser() + "\",\"ts\":" + message.getServerTimestamp() + ",\"t\":" + message.getContent().getType() + ",\"sc\":\"" + searchContent + "\",\"c\":\"" + cont + "\",\"e\":\"" + extra + "\"}";
String cont = message.getContent().getContent() == null ? "" : message.getContent().getContent().replace("\"", "\\\"");
String extra = message.getContent().getExtra() == null ? "" : message.getContent().getExtra().replace("\"", "\\\"");
JSONObject json = new JSONObject();
json.put("s", message.getFromUser());
json.put("ts", message.getServerTimestamp());
json.put("t", message.getContent().getType());
json.put("sc", message.getContent().getSearchableContent());
json.put("c", message.getContent().getContent());
json.put("e", message.getContent().getExtra());
String recalledContent = json.toJSONString();
message = message.toBuilder().setContent(message.getContent().toBuilder().setContent(operatorId).setType(80).clearSearchableContent().setData(ByteString.copyFrom(String.valueOf(messageUid).getBytes())).setExtra(recalledContent).build()).build();
messageBundle.setMessage(message);
@@ -1900,60 +1955,6 @@ public class MemoryMessagesStore implements IMessagesStore {
return ErrorCode.ERROR_CODE_SUCCESS;
}
@Override
public ErrorCode login(String name, String password, List<String> userIdRet) {
Connection connection = null;
PreparedStatement statement = null;
ResultSet rs = null;
try {
connection = DBUtil.getConnection();
String sql = "select `_uid`, `_passwd_md5` from t_user where `_name` = ?";
statement = connection.prepareStatement(sql);
int index = 1;
statement.setString(index++, name);
rs = statement.executeQuery();
if (rs.next()) {
String uid = rs.getString(1);
int status = getUserStatus(uid);
if (status == 1) {
return ErrorCode.ERROR_CODE_USER_FORBIDDEN;
}
String pwd_md5 = rs.getString(2);
try {
MessageDigest md5 = MessageDigest.getInstance("MD5");
String passwdMd5 = Base64.getEncoder().encodeToString(md5.digest(password.getBytes("utf-8")));
if (passwdMd5.equals(pwd_md5)) {
LOG.info("login success userName={}, userId={}", name, uid);
userIdRet.add(uid);
return ErrorCode.ERROR_CODE_SUCCESS;
} else {
LOG.info("login failure incorrect password, userName={}, userId={}", name, uid);
return ErrorCode.ERROR_CODE_PASSWORD_INCORRECT;
}
} catch (Exception e) {
e.printStackTrace();
Utility.printExecption(LOG, e);
LOG.info("login failure execption password, userName={}", name);
return ErrorCode.ERROR_CODE_PASSWORD_INCORRECT;
}
} else {
LOG.info("login failure user not exist, userName={}", name);
return ErrorCode.ERROR_CODE_NOT_EXIST;
}
} catch (SQLException e) {
e.printStackTrace();
Utility.printExecption(LOG, e);
LOG.info("login failure db execption, userName={}", name);
return ErrorCode.ERROR_CODE_SERVER_ERROR;
} finally {
DBUtil.closeDB(connection, statement, rs);
}
}
synchronized Collection<FriendData> loadFriend(MultiMap<String, FriendData> friendsMap, String userId) {
Collection<FriendData> friends = databaseStore.getPersistFriends(userId);
if (friends != null) {
@@ -2147,6 +2148,25 @@ public class MemoryMessagesStore implements IMessagesStore {
public ErrorCode handleFriendRequest(String userId, WFCMessage.HandleFriendRequest request, WFCMessage.Message.Builder msgBuilder, long[] heads, boolean isAdmin) {
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) {
MultiMap<String, FriendData> friendsMap = hzInstance.getMultiMap(USER_FRIENDS);
@@ -2252,6 +2272,10 @@ public class MemoryMessagesStore implements IMessagesStore {
@Override
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) {
state = 1;
} else {
@@ -2384,6 +2408,11 @@ public class MemoryMessagesStore implements IMessagesStore {
return true;
}
@Override
public boolean isNewFriendWelcomeMessage() {
return mFriendNewWelcomeMessage;
}
@Override
public ErrorCode deleteFriend(String userId, String friendUid, long[] head) {
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
@@ -159,7 +159,6 @@ public interface IMessagesStore {
WFCMessage.PullMessageResult fetchChatroomMessage(String fromUser, String chatroomId, String exceptClientId, long fromMessageId);
ErrorCode verifyToken(String userId, String token, List<String> serverIPs, List<Integer> ports);
ErrorCode login(String name, String password, List<String> userIdRet);
List<FriendData> getFriendList(String userId, String clientId, long version);
void clearUserFriend(String userId);
@@ -167,6 +166,7 @@ public interface IMessagesStore {
ErrorCode saveAddFriendRequest(String userId, WFCMessage.AddFriendRequest request, long[] head);
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 blackUserRequest(String fromUser, String targetUserId, int status, long[] head);
FriendData getFriendData(String fromUser, String targetUserId);
@@ -16,6 +16,7 @@
package io.moquette.spi.impl;
import cn.wildfirechat.pojos.OutputMessageData;
import cn.wildfirechat.proto.ProtoConstants;
import cn.wildfirechat.proto.WFCMessage;
import cn.wildfirechat.push.PushServer;
@@ -158,7 +159,7 @@ public class MessagesPublisher {
}
}
private void publish2Receivers(String sender, int conversationType, String target, int line, long messageHead, Collection<String> receivers, String pushContent, String exceptClientId, int pullType, int messageContentType, long serverTime, int mentionType, List<String> mentionTargets, int persistFlag) {
private void publish2Receivers(String sender, int conversationType, String target, int line, long messageHead, Collection<String> receivers, String pushContent, String pushData, String exceptClientId, int pullType, int messageContentType, long serverTime, int mentionType, List<String> mentionTargets, int persistFlag) {
if (persistFlag == Transparent) {
publishTransparentMessage2Receivers(messageHead, receivers, pullType);
return;
@@ -252,8 +253,8 @@ public class MessagesPublisher {
}
}
if (!StringUtil.isNullOrEmpty(pushContent) || messageContentType == 400 || messageContentType == 402) {
if (!isSlient) {
if (!StringUtil.isNullOrEmpty(pushContent) || messageContentType == 400) {
if (!isSlient && (persistFlag & 0x02) > 0) {
targetSession.setUnReceivedMsgs(targetSession.getUnReceivedMsgs() + 1);
}
}
@@ -331,7 +332,7 @@ public class MessagesPublisher {
name = fd.getAlias();
}
}
this.messageSender.sendPush(sender, conversationType, target, line, messageHead, targetSession.getClientID(), pushContent, messageContentType, serverTime, name, targetName, targetSession.getUnReceivedMsgs(), curMentionType, isHiddenDetail, targetSession.getLanguage());
this.messageSender.sendPush(sender, conversationType, target, line, messageHead, targetSession.getClientID(), pushContent, pushData, messageContentType, serverTime, name, targetName, targetSession.getUnReceivedMsgs(), curMentionType, isHiddenDetail, targetSession.getLanguage());
}
}
@@ -544,12 +545,12 @@ public class MessagesPublisher {
message.getConversation().getType(), message.getConversation().getTarget(), message.getConversation().getLine(),
messageId,
receivers,
pushContent, exceptClientId, pullType, message.getContent().getType(), message.getServerTimestamp(), message.getContent().getMentionedType(), message.getContent().getMentionedTargetList(), message.getContent().getPersistFlag());
pushContent, message.getContent().getPushData(), exceptClientId, pullType, message.getContent().getType(), message.getServerTimestamp(), message.getContent().getMentionedType(), message.getContent().getMentionedTargetList(), message.getContent().getPersistFlag());
}
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) {
@@ -37,10 +37,11 @@ class PersistentQueueMessageSender {
this.connectionDescriptorStore = connectionDescriptorStore;
}
void sendPush(String sender, int conversationType, String target, int line, long messageHead, String deviceId, String pushContent, int messageContentType, long serverTime, String senderName, String targetName, int unReceivedMsg, int mentionType, boolean isHiddenDetail, String language) {
void sendPush(String sender, int conversationType, String target, int line, long messageHead, String deviceId, String pushContent, String pushData, int messageContentType, long serverTime, String senderName, String targetName, int unReceivedMsg, int mentionType, boolean isHiddenDetail, String language) {
LOG.info("Send push to {}, message from {}", deviceId, sender);
PushMessage pushMessage = new PushMessage(sender, conversationType, target, line, messageContentType, serverTime, senderName, targetName, unReceivedMsg, mentionType, isHiddenDetail, language);
pushMessage.pushContent = pushContent;
pushMessage.pushData = pushData;
PushServer.getServer().pushMessage(pushMessage, deviceId, pushContent);
}
@@ -13,7 +13,7 @@ import java.util.Date;
public class MessageShardingUtil {
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 rotateIdWidth = 15;
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId>
<version>0.41</version>
<version>0.43</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -53,6 +53,7 @@ public interface APIPath {
String Group_Member_Kickoff = "/admin/group/member/del";
String Group_Member_Quit = "/admin/group/member/quit";
String Group_Set_Manager = "/admin/group/manager/set";
String Group_Mute_Member = "/admin/group/manager/mute";
String Get_User_Groups = "/admin/group/of_user";
@@ -29,10 +29,6 @@ public enum ErrorCode {
//Group error
ERROR_CODE_GROUP_ALREADY_EXIST(11, "group aleady exist"),
//user error
ERROR_CODE_PASSWORD_INCORRECT(15, "password incorrect"),
//user error
ERROR_CODE_FRIEND_ALREADY_REQUEST(16, "already send request"),
ERROR_CODE_FRIEND_REQUEST_BLOCKED(18, "friend request blocked"),
@@ -42,6 +38,9 @@ public enum ErrorCode {
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_SENSITIVE_MATCHED(242, "sensitive matched"),
ERROR_CODE_SIGN_EXPIRED(243, "sign expired"),
@@ -145,6 +145,8 @@ public class GroupNotificationBinaryContent {
return getGroupNotifyContent(ProtoConstants.MESSAGE_CONTENT_TYPE_SET_MANAGER);
}
public WFCMessage.MessageContent getMuteGroupMemberNotifyContent() {
return getGroupNotifyContent(ProtoConstants.MESSAGE_CONTENT_TYPE_MUTE_MEMBER);
}
}
@@ -24,27 +24,41 @@ public class InputCreateGroup extends InputGroupBase {
public WFCMessage.CreateGroupRequest toProtoGroupRequest() {
WFCMessage.Group.Builder groupBuilder = WFCMessage.Group.newBuilder();
WFCMessage.GroupInfo.Builder groupInfoBuilder = WFCMessage.GroupInfo.newBuilder();
if (!StringUtil.isNullOrEmpty(group.getGroup_info().target_id)) {
groupInfoBuilder.setTargetId(group.getGroup_info().getTarget_id());
PojoGroupInfo group_info = group.getGroup_info();
if (!StringUtil.isNullOrEmpty(group_info.target_id)) {
groupInfoBuilder.setTargetId(group_info.getTarget_id());
}
if (!StringUtil.isNullOrEmpty(group.getGroup_info().name)) {
groupInfoBuilder.setName(group.getGroup_info().getName());
if (!StringUtil.isNullOrEmpty(group_info.name)) {
groupInfoBuilder.setName(group_info.getName());
}
if (!StringUtil.isNullOrEmpty(group.getGroup_info().portrait)) {
groupInfoBuilder.setPortrait(group.getGroup_info().getPortrait());
if (!StringUtil.isNullOrEmpty(group_info.portrait)) {
groupInfoBuilder.setPortrait(group_info.getPortrait());
}
if (!StringUtil.isNullOrEmpty(group.getGroup_info().owner)) {
groupInfoBuilder.setOwner(group.getGroup_info().getOwner());
if (!StringUtil.isNullOrEmpty(group_info.owner)) {
groupInfoBuilder.setOwner(group_info.getOwner());
}
groupInfoBuilder.setType(group.getGroup_info().getType());
groupInfoBuilder.setType(group_info.getType());
if (!StringUtil.isNullOrEmpty(group.getGroup_info().extra)) {
groupInfoBuilder.setExtra(group.getGroup_info().getExtra());
if (!StringUtil.isNullOrEmpty(group_info.extra)) {
groupInfoBuilder.setExtra(group_info.getExtra());
}
if (group_info.join_type > 0 && group_info.join_type < 128) {
groupInfoBuilder.setJoinType(group_info.join_type);
}
if (group_info.mute > 0 && group_info.mute < 128) {
groupInfoBuilder.setMute(group_info.mute);
}
if (group_info.private_chat > 0 && group_info.private_chat < 128) {
groupInfoBuilder.setPrivateChat(group_info.private_chat);
}
if (group_info.searchable > 0) {
groupInfoBuilder.setSearchable(group_info.searchable);
}
groupBuilder.setGroupInfo(groupInfoBuilder);
for (PojoGroupMember pojoGroupMember : group.getMembers()) {
@@ -0,0 +1,72 @@
/*
* This file is part of the Wildfire Chat package.
* (c) Heavyrain2012 <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
package 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();
}
}
@@ -20,6 +20,7 @@ public class MessagePayload {
private int type;
private String searchableContent;
private String pushContent;
private String pushData;
private String content;
private String base64edData;
private int mediaType;
@@ -28,6 +29,8 @@ public class MessagePayload {
private int expireDuration;
private int mentionedType;
private List<String> mentionedTarget;
private String extra;
public int getType() {
return type;
@@ -117,6 +120,22 @@ public class MessagePayload {
this.mentionedTarget = mentionedTarget;
}
public String getExtra() {
return extra;
}
public void setExtra(String extra) {
this.extra = extra;
}
public String getPushData() {
return pushData;
}
public void setPushData(String pushData) {
this.pushData = pushData;
}
public WFCMessage.MessageContent toProtoMessageContent() {
WFCMessage.MessageContent.Builder builder = WFCMessage.MessageContent.newBuilder()
.setType(type)
@@ -137,6 +156,10 @@ public class MessagePayload {
builder.setRemoteMediaUrl(remoteMediaUrl);
if (mentionedTarget != null && mentionedTarget.size() > 0)
builder.addAllMentionedTarget(mentionedTarget);
if (!StringUtil.isNullOrEmpty(extra))
builder.setExtra(extra);
if (!StringUtil.isNullOrEmpty(pushData))
builder.setPushData(pushData);
return builder.build();
}
@@ -159,6 +182,8 @@ public class MessagePayload {
payload.mentionedType = protoContent.getMentionedType();
payload.mentionedTarget = new ArrayList<>();
payload.mentionedTarget.addAll(protoContent.getMentionedTargetList());
payload.extra = protoContent.getExtra();
payload.pushData = protoContent.getPushData();
return payload;
}
}
@@ -0,0 +1,85 @@
/*
* This file is part of the Wildfire Chat package.
* (c) Heavyrain2012 <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
package 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;
}
}
@@ -15,6 +15,12 @@ public class PojoGroupInfo {
String owner;
int type;
String extra;
int mute;
int join_type;
int private_chat;
int searchable;
int max_member_count;
int history_message;
public String getTarget_id() {
return target_id;
@@ -63,4 +69,52 @@ public class PojoGroupInfo {
public void setExtra(String extra) {
this.extra = extra;
}
public int getMax_member_count() {
return max_member_count;
}
public void setMax_member_count(int max_member_count) {
this.max_member_count = max_member_count;
}
public int getMute() {
return mute;
}
public void setMute(int mute) {
this.mute = mute;
}
public int getJoin_type() {
return join_type;
}
public void setJoin_type(int join_type) {
this.join_type = join_type;
}
public int getPrivate_chat() {
return private_chat;
}
public void setPrivate_chat(int private_chat) {
this.private_chat = private_chat;
}
public int getSearchable() {
return searchable;
}
public void setSearchable(int searchable) {
this.searchable = searchable;
}
public int getHistory_message() {
return history_message;
}
public void setHistory_message(int history_message) {
this.history_message = history_message;
}
}
@@ -181,5 +181,6 @@ public class ProtoConstants {
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_MUTE_MEMBER = 118;
}
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -6,7 +6,7 @@
<!--<relativePath>../pom.xml</relativePath>-->
<artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId>
<version>0.41</version>
<version>0.43</version>
</parent>
<artifactId>distribution</artifactId>
@@ -41,7 +41,7 @@
<!--关闭连接时,是否提交未提交的事务,默认为false,即关闭连接,回滚未提交的事务 -->
<property name="autoCommitOnClose">false</property>
<!--c3p0将建一张名为Test的空表,并使用其自带的查询语句进行测试。如果定义了这个参数那么属性preferredTestQuery将被忽略。你不能在这张Test表上进行任何操作,它将只供c3p0测试使用。默认值: null -->
<property name="automaticTestTable">Test</property>
<!-- <property name="automaticTestTable">Test</property>-->
<!--如果为false,则获取连接失败将会引起所有等待连接池来获取连接的线程抛出异常,但是数据源仍有效保留,并在下次调用getConnection()的时候继续尝试获取连接。如果设为true,那么在尝试获取连接失败后该数据源将申明已断开并永久关闭。默认: false-->
<property name="breakAfterAcquireFailure">false</property>
<!--每60秒检查所有连接池中的空闲连接。默认值: 0,不检查 -->
@@ -46,10 +46,12 @@ token.key testim
##token的过期时间,单位为毫秒,默认为无限期。如果需要设置无限期,客户端上一定需要加上token过期的处理。token过期的处理请参考文档的常见问题
##token.expire_time 2592000000
##首次登录,是否接收之前的历史消息。0 不接收;1接收。
##首次登录,是否接收之前的历史消息。
##0 不接收历史消息,只接收5分钟以内的消息,由于服务器没有保存已经收取记录,所以如果有超过5分钟之前未收取的消息也不会收取下拉;
##1接收,会接收 message.max_queue 配置的条数的历史消息
message.roaming 0
##是否开启拉取远程历史消息
##是否开启拉取远程历史消息。如果为1,客户端在会话内如果本地消息读取完了,可以下拉继续加载在服务器上的该会话的消息;如果为0则不能。
message.remote_history_message 0
##服务器为每个用户缓存的消息数量。这个值改得太大,拉取消息时间变长,另外会占用大量内存。
@@ -83,6 +85,12 @@ friend.reject_request_duration 2592000000
##好友请求过期时间,单位是毫秒,默认是7天,0为不限制
friend.request_expiration_duration 604800000
##添加好友后会发送欢迎消息,比如"你们已经是好友了,可以聊天了"。这个开关控制是用旧的方式还是用新的方式。
##旧的方式会发送notification消息(contenttype是80),内容会根据好友接收者的语言选择对应的语言,如果双方语言不一致会导致另外一方看到的不是本地语言。
##新的方式会发送添加好友消息(contenttype是93)和欢迎消息(contenttype是92),需要客户端实现这两种消息。
##如果客户端已经实现这两种消息可以打开这个开关
friend.new_welcome_message false
## 聊天室观众空闲退出时间,单位为毫秒,默认为15分钟,0为永远不退出
chatroom.participant_idle_time 900000
@@ -140,10 +148,10 @@ qiniu.bucket_favorite_domain http://cdn2.wildfirechat.cn
local.media.storage.root ./media
# 是否支持多端登陆
# 是否支持多端登陆,为true时支持任意平台任意多个客户端同时登录;为false时每个平台只支持一个端登录,但不同平台可以同时登录。
server.multi_endpoint false
# 多平台连接状态通知(仅当multi_endpoint为false时有效)
# 多平台连接状态通知(仅当multi_endpoint为false时有效),true时移动端可以收到pc或web端登录的通知。
server.multi_platform_notification false
#*********************************************************************
+1 -1
View File
@@ -12,7 +12,7 @@
<artifactId>wildfirechat-parent</artifactId>
<packaging>pom</packaging>
<version>0.41</version>
<version>0.43</version>
<name>Wildfire Chat</name>
<description>Wildfire Chat Server</description>
<inceptionYear>2019</inceptionYear>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId>
<version>0.41</version>
<version>0.43</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -52,7 +52,7 @@ public class GroupAdmin {
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;
InputModifyGroupInfo modifyGroupInfo = new InputModifyGroupInfo();
modifyGroupInfo.setGroup_id(groupId);
@@ -60,6 +60,7 @@ public class GroupAdmin {
modifyGroupInfo.setTo_lines(to_lines);
modifyGroupInfo.setType(type);
modifyGroupInfo.setValue(value);
modifyGroupInfo.setNotify_message(notify_message);
return AdminHttpUtils.httpJsonPost(path, modifyGroupInfo, Void.class);
}
@@ -100,7 +101,17 @@ public class GroupAdmin {
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 {
String path = APIPath.Group_Member_Kickoff;
@@ -130,5 +141,4 @@ public class GroupAdmin {
return AdminHttpUtils.httpJsonPost(path, inputUserId, OutputGroupIds.class);
}
}
@@ -37,6 +37,7 @@ public class Main {
testChatroom();
testMessage();
testGeneralApi();
testDevice();
System.out.println("Congratulation, all admin test case passed!!!!!!!");
}
@@ -351,7 +352,7 @@ public class Main {
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) {
System.out.println("transfer success");
} else {
@@ -413,6 +414,23 @@ public class Main {
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);
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
@@ -556,7 +574,7 @@ public class Main {
System.out.println("chatroom info incorrect");
System.exit(-1);
} else {
System.out.println("chatroom info incorrect");
System.out.println("chatroom info correct");
}
} else {
System.out.println("get chatroom info failure");