Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dfb9638a38 | ||
|
|
8452b0675b | ||
|
|
930643706a | ||
|
|
a2eac1f721 | ||
|
|
6e994cd694 | ||
|
|
c82869c631 | ||
|
|
f5a94868c4 | ||
|
|
c5628d613b | ||
|
|
9509b1ffa8 | ||
|
|
c1dac8a21e | ||
|
|
950846df45 | ||
|
|
31d96e2dc6 | ||
|
|
031e96075e | ||
|
|
bf2caeac6c | ||
|
|
12e523b37e | ||
|
|
576c985d8f | ||
|
|
9365807f47 | ||
|
|
25ce10fa61 | ||
|
|
09c333501f | ||
|
|
c51b09ee3a | ||
|
|
4d82eace86 | ||
|
|
385b03a163 | ||
|
|
4b438afa69 | ||
|
|
66961b94da | ||
|
|
39b62e5942 | ||
|
|
5bb8ab3d95 | ||
|
|
8dfc23b61d | ||
|
|
c8769808b5 | ||
|
|
2fc106aa26 | ||
|
|
da0b725ff8 | ||
|
|
15703d66fb | ||
|
|
c68beeaa51 | ||
|
|
5ef8868916 | ||
|
|
24488cc985 | ||
|
|
1c9faaa1e6 | ||
|
|
ac32875b14 | ||
|
|
07c1dd29e0 | ||
|
|
bd93233c34 | ||
|
|
20aec2fbcf | ||
|
|
a149139143 | ||
|
|
c857d1abb7 | ||
|
|
dde9da7006 | ||
|
|
d18a1970e5 | ||
|
|
66b9aeec17 | ||
|
|
ea301a3923 |
@@ -65,7 +65,7 @@
|
||||
|
||||
| 捐赠者 | 商标 | 金额 | 简介 |
|
||||
| ----- | ---- | -------- | --- |
|
||||
| [SAMOS](http://samos.io) |  | 每月2000¥ | 一站式区块链解决方案服务商(http://samos.io) |
|
||||
| [SAMOS](http://samos.io) |  | 保密 | 一站式区块链解决方案服务商(http://samos.io) |
|
||||
|
||||
## 特别感谢
|
||||
1. [moquette](https://github.com/moquette-io/moquette) 本项目是基于此项目二次开发而来,处理MQTT相关业务。
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#*********************************************************************
|
||||
#服务器的接入IP。给客户端提供是${server.ip}和${http_port}。
|
||||
#客户端会从${http_port}端口获取到长链接端口。
|
||||
server.ip 0.0.0.0
|
||||
server.ip 192.168.1.100
|
||||
|
||||
##原生客户端长链接端口
|
||||
port 1883
|
||||
@@ -27,7 +27,7 @@ host 0.0.0.0
|
||||
local_port 80
|
||||
|
||||
##是否使用内置DB。0使用mysql;1使用h2db
|
||||
embed.db 1
|
||||
embed.db 0
|
||||
|
||||
##服务器管理接口密钥
|
||||
http.admin.secret_key 123456
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
|
||||
insert into t_user (`_uid`,`_name`,`_display_name`,`_type`,`_dt`) values ('admin','admin','系统管理员',3,1);
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
ALTER TABLE t_user_session MODIFY _token VARCHAR(240) DEFAULT NULL;
|
||||
@@ -0,0 +1,4 @@
|
||||
alter table `t_group` add column `_mute` tinyint NOT NULL DEFAULT 0;
|
||||
alter table `t_group` add column `_join_type` tinyint NOT NULL DEFAULT 0;
|
||||
alter table `t_group` add column `_private_chat` tinyint NOT NULL DEFAULT 0;
|
||||
alter table `t_group` add column `_searchable` tinyint NOT NULL DEFAULT 0;
|
||||
@@ -0,0 +1,2 @@
|
||||
alter table t_user add column `_createTime` TIMESTAMP default CURRENT_TIMESTAMP;
|
||||
alter table t_group add column `_createTime` TIMESTAMP default CURRENT_TIMESTAMP;
|
||||
@@ -0,0 +1 @@
|
||||
alter table `t_messages` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
|
||||
DROP TABLE IF EXISTS `t_sensitive_messages`;
|
||||
CREATE TABLE `t_sensitive_messages` (
|
||||
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
`_mid` bigint(20) NOT NULL,
|
||||
`_from` varchar(64) NOT NULL,
|
||||
`_type` tinyint NOT NULL DEFAULT 0,
|
||||
`_target` varchar(64) NOT NULL,
|
||||
`_line` int(11) NOT NULL DEFAULT 0,
|
||||
`_data` BLOB NOT NULL,
|
||||
`_searchable_key` TEXT DEFAULT NULL,
|
||||
`_dt` DATETIME NOT NULL DEFAULT NOW(),
|
||||
`_content_type` int(11) NOT NULL DEFAULT 0,
|
||||
UNIQUE INDEX `sensitive_message_uid_index` (`_mid` ASC)
|
||||
);
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
|
||||
insert into t_user (`_uid`,`_name`,`_display_name`,`_type`,`_dt`) values ('admin','admin','系统管理员',3,1);
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
ALTER TABLE t_user_session MODIFY _token VARCHAR(240) DEFAULT NULL;
|
||||
@@ -0,0 +1,4 @@
|
||||
alter table `t_group` add column `_mute` tinyint NOT NULL DEFAULT 0;
|
||||
alter table `t_group` add column `_join_type` tinyint NOT NULL DEFAULT 0;
|
||||
alter table `t_group` add column `_private_chat` tinyint NOT NULL DEFAULT 0;
|
||||
alter table `t_group` add column `_searchable` tinyint NOT NULL DEFAULT 0;
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
|
||||
DROP TABLE IF EXISTS `t_session`;
|
||||
CREATE TABLE `t_session` (
|
||||
`row_id` varchar(50) not null primary key,
|
||||
`del_flag` tinyint(1) default 0 null,
|
||||
`create_time` timestamp null,
|
||||
`update_time` timestamp null,
|
||||
`expire_time` timestamp null,
|
||||
`user_id` int null,
|
||||
constraint `t_session_pk_2` unique (`user_id`, `expire_time`)
|
||||
)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARACTER SET = utf8mb4
|
||||
COLLATE = utf8mb4_unicode_ci;
|
||||
@@ -0,0 +1,2 @@
|
||||
alter table t_user MODIFY column `_createTime` DATETIME NOT NULL DEFAULT NOW();
|
||||
alter table t_group MODIFY column `_createTime` DATETIME NOT NULL DEFAULT NOW();
|
||||
@@ -0,0 +1,4 @@
|
||||
alter table t_session MODIFY column `create_time` DATETIME NOT NULL DEFAULT NOW();
|
||||
alter table t_session MODIFY column `update_time` DATETIME NOT NULL DEFAULT NOW();
|
||||
alter table t_session MODIFY column `expire_time` DATETIME NOT NULL DEFAULT NOW();
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
update t_messages_0 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_1 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_2 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_3 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_4 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_5 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_6 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_7 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_8 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_9 set _dt = date_add(_dt, interval 8 hour);
|
||||
|
||||
update t_messages_10 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_11 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_12 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_13 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_14 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_15 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_16 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_17 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_18 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_19 set _dt = date_add(_dt, interval 8 hour);
|
||||
|
||||
update t_messages_20 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_21 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_22 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_23 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_24 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_25 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_26 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_27 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_28 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_29 set _dt = date_add(_dt, interval 8 hour);
|
||||
|
||||
|
||||
update t_messages_30 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_31 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_32 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_33 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_34 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_35 set _dt = date_add(_dt, interval 8 hour);
|
||||
@@ -0,0 +1,2 @@
|
||||
alter table t_user add column `_createTime` TIMESTAMP default CURRENT_TIMESTAMP;
|
||||
alter table t_group add column `_createTime` TIMESTAMP default CURRENT_TIMESTAMP;
|
||||
@@ -0,0 +1,36 @@
|
||||
alter table `t_messages_0` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_1` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_2` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_3` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_4` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_5` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_6` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_7` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_8` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_9` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_10` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_11` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_12` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_13` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_14` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_15` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_16` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_17` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_18` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_19` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_20` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_21` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_22` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_23` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_24` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_25` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_26` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_27` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_28` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_29` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_30` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_31` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_32` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_33` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_34` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_35` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
|
||||
DROP TABLE IF EXISTS `t_sensitive_messages`;
|
||||
CREATE TABLE `t_sensitive_messages` (
|
||||
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
`_mid` bigint(20) NOT NULL,
|
||||
`_from` varchar(64) NOT NULL,
|
||||
`_type` tinyint NOT NULL DEFAULT 0,
|
||||
`_target` varchar(64) NOT NULL,
|
||||
`_line` int(11) NOT NULL DEFAULT 0,
|
||||
`_data` BLOB NOT NULL,
|
||||
`_searchable_key` TEXT DEFAULT NULL,
|
||||
`_dt` DATETIME NOT NULL,
|
||||
`_content_type` int(11) NOT NULL DEFAULT '0',
|
||||
INDEX `message_uid_index` (`_mid` DESC)
|
||||
)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARACTER SET = utf8mb4
|
||||
COLLATE = utf8mb4_unicode_ci;
|
||||
+1
-7
@@ -5,7 +5,7 @@
|
||||
<relativePath>../</relativePath>
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.22</version>
|
||||
<version>0.24</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>moquette-broker</artifactId>
|
||||
@@ -132,12 +132,6 @@
|
||||
<version>5.1.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.bugsnag</groupId>
|
||||
<artifactId>bugsnag</artifactId>
|
||||
<version>[3.0,4.0)</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
|
||||
@@ -35,12 +35,15 @@ import java.util.concurrent.Executor;
|
||||
@HttpMethod("POST")
|
||||
public class RouteAction extends Action {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(RouteAction.class);
|
||||
|
||||
@Override
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
|
||||
response.setContentType("application/octet-stream");
|
||||
FullHttpRequest fullHttpRequest = (FullHttpRequest)request.getNettyRequest();
|
||||
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||
|
||||
FullHttpRequest fullHttpRequest = (FullHttpRequest) request.getNettyRequest();
|
||||
boolean b = false;
|
||||
if ("web".equalsIgnoreCase(fullHttpRequest.headers().get("p"))) {
|
||||
b = true;
|
||||
@@ -144,10 +147,14 @@ public class RouteAction extends Action {
|
||||
|
||||
private void sendResponse(Response response, ErrorCode errorCode, byte[] contents, boolean base64Response) {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
if(contents == null) {
|
||||
if (contents == null) {
|
||||
ByteBuf ackPayload = Unpooled.buffer();
|
||||
ackPayload.ensureWritable(1).writeByte(errorCode.getCode());
|
||||
response.setContent(ackPayload);
|
||||
contents = ackPayload.array();
|
||||
}
|
||||
if (base64Response) {
|
||||
byte[] base64Data = Base64.getEncoder().encode(contents);
|
||||
response.setContent(base64Data);
|
||||
} else {
|
||||
response.setContent(contents);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class BlockUserAction extends AdminAction {
|
||||
result = RestResult.resultOf(errorCode);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
|
||||
if (inputUserBlock.getStatus() != 0) {
|
||||
if (inputUserBlock.getStatus() == 2) {
|
||||
RPCCenter.getInstance().sendRequest(null, null, RPCCenter.KICKOFF_USER_REQUEST, inputUserBlock.getUserId().getBytes(), inputUserBlock.getUserId(), TargetEntry.Type.TARGET_TYPE_USER, null, true);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ public class KickoffGroupMemberAction extends AdminAction {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputKickoffGroupMember inputKickoffGroupMember = getRequestBody(request.getNettyRequest(), InputKickoffGroupMember.class);
|
||||
if (inputKickoffGroupMember.isValide()) {
|
||||
RPCCenter.getInstance().sendRequest(inputKickoffGroupMember.getOperator(), null, IMTopic.AddGroupMemberTopic, inputKickoffGroupMember.toProtoGroupRequest().toByteArray(), inputKickoffGroupMember.getOperator(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
RPCCenter.getInstance().sendRequest(inputKickoffGroupMember.getOperator(), null, IMTopic.KickoffGroupMemberTopic, inputKickoffGroupMember.toProtoGroupRequest().toByteArray(), inputKickoffGroupMember.getOperator(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Action处理单元
|
||||
*
|
||||
*
|
||||
* @author Looly
|
||||
*/
|
||||
abstract public class ActionHandler extends SimpleChannelInboundHandler<FullHttpRequest> {
|
||||
@@ -45,7 +45,7 @@ abstract public class ActionHandler extends SimpleChannelInboundHandler<FullHttp
|
||||
try {
|
||||
//do filter
|
||||
boolean isPass = this.doFilter(request, response);
|
||||
|
||||
|
||||
if(isPass){
|
||||
//do action
|
||||
this.doAction(ctx, request, response);
|
||||
@@ -64,10 +64,10 @@ abstract public class ActionHandler extends SimpleChannelInboundHandler<FullHttp
|
||||
ctx.fireExceptionCaught(e);
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||
super.exceptionCaught(ctx, cause);
|
||||
@@ -75,7 +75,7 @@ abstract public class ActionHandler extends SimpleChannelInboundHandler<FullHttp
|
||||
Channel channel = ctx.channel();
|
||||
if(channel.isActive())ctx.close();
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------- Private method start
|
||||
/**
|
||||
* 执行过滤
|
||||
@@ -91,7 +91,7 @@ abstract public class ActionHandler extends SimpleChannelInboundHandler<FullHttp
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//自定义Path过滤器
|
||||
filter = ServerSetting.getFilter(request.getPath());
|
||||
if(null != filter){
|
||||
@@ -99,7 +99,7 @@ abstract public class ActionHandler extends SimpleChannelInboundHandler<FullHttp
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -110,6 +110,10 @@ abstract public class ActionHandler extends SimpleChannelInboundHandler<FullHttp
|
||||
* @param response 响应对象
|
||||
*/
|
||||
private void doAction(ChannelHandlerContext ctx, Request request, Response response){
|
||||
if( "/route".equalsIgnoreCase(request.getPath()) && "OPTIONS".equalsIgnoreCase(request.getMethod())){
|
||||
handleOptions(ctx, request, response);
|
||||
return;
|
||||
}
|
||||
Action action;
|
||||
if (isValidePath(request.getPath())) {
|
||||
action = ServerSetting.getAction(request.getPath(), request.getMethod().toUpperCase());
|
||||
@@ -141,4 +145,11 @@ abstract public class ActionHandler extends SimpleChannelInboundHandler<FullHttp
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------------------- Private method start
|
||||
|
||||
|
||||
private void handleOptions(ChannelHandlerContext ctx, Request request, Response response){
|
||||
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||
response.setHeader("Access-Control-Allow-Headers", "*");
|
||||
response.send();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,9 +65,6 @@ public final class BrokerConstants {
|
||||
public static final String METRICS_LIBRATO_TOKEN_PROPERTY_NAME = "metrics.librato.token";
|
||||
public static final String METRICS_LIBRATO_SOURCE_PROPERTY_NAME = "metrics.librato.source";
|
||||
|
||||
public static final String BUGSNAG_ENABLE_PROPERTY_NAME = "use_bugsnag";
|
||||
public static final String BUGSNAG_TOKEN_PROPERTY_NAME = "bugsnag.token";
|
||||
|
||||
public static final String STORAGE_CLASS_NAME = "storage_class";
|
||||
|
||||
public static final String QINIU_SERVER_URL= "qiniu.server_url";
|
||||
|
||||
@@ -22,7 +22,7 @@ public class AddGroupMember extends GroupHandler<WFCMessage.AddGroupMemberReques
|
||||
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.AddGroupMemberRequest request, Qos1PublishHandler.IMCallback callback) {
|
||||
ErrorCode errorCode = m_messagesStore.addGroupMembers(fromUser, request.getGroupId(), request.getAddedMemberList());
|
||||
ErrorCode errorCode = m_messagesStore.addGroupMembers(fromUser, isAdmin, request.getGroupId(), request.getAddedMemberList());
|
||||
if (errorCode == ERROR_CODE_SUCCESS) {
|
||||
if (request.hasNotifyContent() && request.getNotifyContent().getType() > 0) {
|
||||
sendGroupNotification(fromUser, request.getGroupId(), request.getToLineList(), request.getNotifyContent());
|
||||
|
||||
@@ -14,10 +14,18 @@ import io.netty.buffer.ByteBuf;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_SUCCESS;
|
||||
|
||||
@Handler(IMTopic.DeleteFriendTopic)
|
||||
public class DeleteFriendHandler extends IMHandler<WFCMessage.IDBuf> {
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.IDBuf request, Qos1PublishHandler.IMCallback callback) {
|
||||
return m_messagesStore.deleteFriend(fromUser, request.getId());
|
||||
long[] head = new long[2];
|
||||
ErrorCode errorCode = m_messagesStore.deleteFriend(fromUser, request.getId(), head);
|
||||
if (errorCode == ERROR_CODE_SUCCESS) {
|
||||
publisher.publishNotification(IMTopic.NotifyFriendTopic, fromUser, head[0]);
|
||||
publisher.publishNotification(IMTopic.NotifyFriendTopic, request.getId(), head[1]);
|
||||
}
|
||||
return errorCode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
package io.moquette.imhandler;
|
||||
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.hazelcast.util.StringUtil;
|
||||
import com.xiaoleilu.loServer.model.FriendData;
|
||||
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -25,7 +26,11 @@ public class FriendPullHandler extends IMHandler<WFCMessage.Version> {
|
||||
WFCMessage.GetFriendsResult.Builder builder = WFCMessage.GetFriendsResult.newBuilder();
|
||||
for (FriendData data : friendDatas
|
||||
) {
|
||||
builder.addEntry(WFCMessage.Friend.newBuilder().setState(data.getState()).setUid(data.getFriendUid()).setUpdateDt(data.getTimestamp()).setAlias(data.getAlias()).build());
|
||||
WFCMessage.Friend.Builder builder1 = WFCMessage.Friend.newBuilder().setState(data.getState()).setUid(data.getFriendUid()).setUpdateDt(data.getTimestamp());
|
||||
if (!StringUtil.isNullOrEmpty(data.getAlias())) {
|
||||
builder1.setAlias(data.getAlias());
|
||||
}
|
||||
builder.addEntry(builder1.build());
|
||||
}
|
||||
byte[] data = builder.build().toByteArray();
|
||||
ackPayload.ensureWritable(data.length).writeBytes(data);
|
||||
|
||||
@@ -238,8 +238,9 @@ abstract public class IMHandler<T> {
|
||||
Set<String> notifyReceivers = new LinkedHashSet<>();
|
||||
|
||||
message = m_messagesStore.storeMessage(username, clientID, message);
|
||||
int pullType = m_messagesStore.getNotifyReceivers(username, message, notifyReceivers);
|
||||
this.publisher.publish2Receivers(message, notifyReceivers, clientID, pullType);
|
||||
WFCMessage.Message.Builder messageBuilder = message.toBuilder();
|
||||
int pullType = m_messagesStore.getNotifyReceivers(username, messageBuilder, notifyReceivers);
|
||||
this.publisher.publish2Receivers(messageBuilder.build(), notifyReceivers, clientID, pullType);
|
||||
return notifyReceivers.size();
|
||||
}
|
||||
|
||||
|
||||
@@ -24,20 +24,32 @@ public class KickoffGroupMember extends GroupHandler<WFCMessage.RemoveGroupMembe
|
||||
WFCMessage.GroupInfo groupInfo = m_messagesStore.getGroupInfo(request.getGroupId());
|
||||
if (groupInfo == null) {
|
||||
errorCode = ErrorCode.ERROR_CODE_NOT_EXIST;
|
||||
|
||||
} else if ((groupInfo.getType() == ProtoConstants.GroupType.GroupType_Normal || groupInfo.getType() == ProtoConstants.GroupType.GroupType_Restricted)
|
||||
&& groupInfo.getOwner() != null && groupInfo.getOwner().equals(fromUser)) {
|
||||
|
||||
//send notify message first, then kickoff the member
|
||||
if (request.hasNotifyContent() && request.getNotifyContent().getType() > 0) {
|
||||
sendGroupNotification(fromUser, groupInfo.getTargetId(), request.getToLineList(), request.getNotifyContent());
|
||||
} else {
|
||||
WFCMessage.MessageContent content = new GroupNotificationBinaryContent(request.getGroupId(), fromUser, null, request.getRemovedMemberList()).getKickokfMemberGroupNotifyContent();
|
||||
sendGroupNotification(fromUser, request.getGroupId(), request.getToLineList(), content);
|
||||
}
|
||||
errorCode = m_messagesStore.kickoffGroupMembers(fromUser, request.getGroupId(), request.getRemovedMemberList());
|
||||
} else {
|
||||
errorCode = ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
boolean isAllow = isAdmin;
|
||||
if (!isAllow) {
|
||||
if (groupInfo.getOwner() != null && groupInfo.getOwner().equals(fromUser)) {
|
||||
isAllow = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isAllow) {
|
||||
WFCMessage.GroupMember gm = m_messagesStore.getGroupMember(request.getGroupId(), fromUser);
|
||||
if (gm != null && gm.getType() == ProtoConstants.GroupMemberType.GroupMemberType_Manager) {
|
||||
isAllow = true;
|
||||
}
|
||||
}
|
||||
if (!isAllow && (groupInfo.getType() == ProtoConstants.GroupType.GroupType_Normal || groupInfo.getType() == ProtoConstants.GroupType.GroupType_Restricted)) {
|
||||
errorCode = ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
} else {
|
||||
//send notify message first, then kickoff the member
|
||||
if (request.hasNotifyContent() && request.getNotifyContent().getType() > 0) {
|
||||
sendGroupNotification(fromUser, groupInfo.getTargetId(), request.getToLineList(), request.getNotifyContent());
|
||||
} else {
|
||||
WFCMessage.MessageContent content = new GroupNotificationBinaryContent(request.getGroupId(), fromUser, null, request.getRemovedMemberList()).getKickokfMemberGroupNotifyContent();
|
||||
sendGroupNotification(fromUser, request.getGroupId(), request.getToLineList(), content);
|
||||
}
|
||||
errorCode = m_messagesStore.kickoffGroupMembers(fromUser, isAdmin, request.getGroupId(), request.getRemovedMemberList());
|
||||
}
|
||||
}
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
@@ -14,16 +14,15 @@ import io.moquette.spi.impl.Qos1PublishHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
|
||||
import static cn.wildfirechat.proto.ProtoConstants.ModifyGroupInfoType.Modify_Group_Name;
|
||||
import static cn.wildfirechat.proto.ProtoConstants.ModifyGroupInfoType.Modify_Group_Portrait;
|
||||
import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_SUCCESS;
|
||||
import static cn.wildfirechat.proto.ProtoConstants.ModifyGroupInfoType.*;
|
||||
import static win.liyufan.im.IMTopic.ModifyGroupInfoTopic;
|
||||
|
||||
@Handler(value = ModifyGroupInfoTopic)
|
||||
public class ModifyGroupInfoHandler extends GroupHandler<WFCMessage.ModifyGroupInfoRequest> {
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.ModifyGroupInfoRequest request, Qos1PublishHandler.IMCallback callback) {
|
||||
ErrorCode errorCode= m_messagesStore.modifyGroupInfo(fromUser, request.getGroupId(), request.getType(), request.getValue());
|
||||
ErrorCode errorCode= m_messagesStore.modifyGroupInfo(fromUser, request.getGroupId(), request.getType(), request.getValue(), isAdmin);
|
||||
if (errorCode == ERROR_CODE_SUCCESS) {
|
||||
if(request.hasNotifyContent() && request.getNotifyContent().getType() > 0) {
|
||||
sendGroupNotification(fromUser, request.getGroupId(), request.getToLineList(), request.getNotifyContent());
|
||||
@@ -33,6 +32,14 @@ public class ModifyGroupInfoHandler extends GroupHandler<WFCMessage.ModifyGroupI
|
||||
content = new GroupNotificationBinaryContent(request.getGroupId(), fromUser, request.getValue(), "").getChangeGroupNameNotifyContent();
|
||||
} else if(request.getType() == Modify_Group_Portrait) {
|
||||
content = new GroupNotificationBinaryContent(request.getGroupId(), fromUser, null, "").getChangeGroupPortraitNotifyContent();
|
||||
} else if(request.getType() == Modify_Group_Mute) {
|
||||
content = new GroupNotificationBinaryContent(request.getGroupId(), fromUser, request.getValue(), "").getChangeGroupMuteNotifyContent();
|
||||
} else if(request.getType() == Modify_Group_JoinType) {
|
||||
content = new GroupNotificationBinaryContent(request.getGroupId(), fromUser, request.getValue(), "").getChangeGroupJointypeNotifyContent();
|
||||
} else if(request.getType() == Modify_Group_PrivateChat) {
|
||||
content = new GroupNotificationBinaryContent(request.getGroupId(), fromUser, request.getValue(), "").getChangeGroupPrivatechatNotifyContent();
|
||||
} else if(request.getType() == Modify_Group_Searchable) {
|
||||
content = new GroupNotificationBinaryContent(request.getGroupId(), fromUser, request.getValue(), "").getChangeGroupSearchableNotifyContent();
|
||||
}
|
||||
|
||||
if (content != null) {
|
||||
|
||||
@@ -20,19 +20,14 @@ import static win.liyufan.im.IMTopic.QuitGroupTopic;
|
||||
public class QuitGroupHandler extends GroupHandler<WFCMessage.QuitGroupRequest> {
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.QuitGroupRequest request, Qos1PublishHandler.IMCallback callback) {
|
||||
ErrorCode errorCode = ErrorCode.ERROR_CODE_SUCCESS;
|
||||
WFCMessage.GroupInfo groupInfo = m_messagesStore.getGroupInfo(request.getGroupId());
|
||||
if (groupInfo == null) {
|
||||
errorCode = m_messagesStore.quitGroup(fromUser, request.getGroupId());
|
||||
} else {
|
||||
//send notify message first, then quit group
|
||||
ErrorCode errorCode = m_messagesStore.quitGroup(fromUser, request.getGroupId());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
if (request.hasNotifyContent() && request.getNotifyContent().getType() > 0) {
|
||||
sendGroupNotification(fromUser, groupInfo.getTargetId(), request.getToLineList(), request.getNotifyContent());
|
||||
sendGroupNotification(fromUser, request.getGroupId(), request.getToLineList(), request.getNotifyContent());
|
||||
} else {
|
||||
WFCMessage.MessageContent content = new GroupNotificationBinaryContent(request.getGroupId(), fromUser, null, "").getQuitGroupNotifyContent();
|
||||
sendGroupNotification(fromUser, request.getGroupId(), request.getToLineList(), content);
|
||||
}
|
||||
errorCode = m_messagesStore.quitGroup(fromUser, request.getGroupId());
|
||||
}
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class RecallMessageHandler extends IMHandler<WFCMessage.INT64Buf> {
|
||||
return ErrorCode.ERROR_CODE_NOT_EXIST;
|
||||
}
|
||||
|
||||
m_messagesStore.getNotifyReceivers(fromUser, message, notifyReceivers);
|
||||
m_messagesStore.getNotifyReceivers(fromUser, message.toBuilder(), notifyReceivers);
|
||||
this.publisher.publishRecall2Receivers(int64Buf.getId(), fromUser, notifyReceivers, clientID);
|
||||
|
||||
return errorCode;
|
||||
|
||||
@@ -46,6 +46,10 @@ public class SendMessageHandler extends IMHandler<WFCMessage.Message> {
|
||||
ErrorCode errorCode = ErrorCode.ERROR_CODE_SUCCESS;
|
||||
if (message != null) {
|
||||
if (!isAdmin) { //admin do not check the right
|
||||
// 不能在端上直接发送撤回和群通知
|
||||
if (message.getContent().getType() == 80 || (message.getContent().getType() >= 100 && message.getContent().getType() < 200)) {
|
||||
return ErrorCode.INVALID_PARAMETER;
|
||||
}
|
||||
int userStatus = m_messagesStore.getUserStatus(fromUser);
|
||||
if (userStatus == 1 || userStatus == 2) {
|
||||
return ErrorCode.ERROR_CODE_FORBIDDEN_SEND_MSG;
|
||||
@@ -58,14 +62,19 @@ public class SendMessageHandler extends IMHandler<WFCMessage.Message> {
|
||||
}
|
||||
|
||||
|
||||
if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Group && !m_messagesStore.isMemberInGroup(fromUser, message.getConversation().getTarget())) {
|
||||
return ErrorCode.ERROR_CODE_NOT_IN_GROUP;
|
||||
} else if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Group && m_messagesStore.isForbiddenInGroup(fromUser, message.getConversation().getTarget())) {
|
||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
} else if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_ChatRoom && !m_messagesStore.checkUserClientInChatroom(fromUser, clientID, message.getConversation().getTarget())) {
|
||||
return ErrorCode.ERROR_CODE_NOT_IN_CHATROOM;
|
||||
} else if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Channel && !m_messagesStore.checkUserInChannel(fromUser, message.getConversation().getTarget())) {
|
||||
return ErrorCode.ERROR_CODE_NOT_IN_CHANNEL;
|
||||
if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Group ) {
|
||||
errorCode = m_messagesStore.canSendMessageInGroup(fromUser, message.getConversation().getTarget());
|
||||
if (errorCode != ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
return errorCode;
|
||||
}
|
||||
} else if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_ChatRoom) {
|
||||
if(!m_messagesStore.checkUserClientInChatroom(fromUser, clientID, message.getConversation().getTarget())) {
|
||||
return ErrorCode.ERROR_CODE_NOT_IN_CHATROOM;
|
||||
}
|
||||
} else if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Channel) {
|
||||
if(!m_messagesStore.checkUserInChannel(fromUser, message.getConversation().getTarget())) {
|
||||
return ErrorCode.ERROR_CODE_NOT_IN_CHANNEL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,6 +90,7 @@ public class SendMessageHandler extends IMHandler<WFCMessage.Message> {
|
||||
if (!isAdmin && message.getContent().getType() == Text) {
|
||||
Set<String> matched = m_messagesStore.handleSensitiveWord(message.getContent().getSearchableContent());
|
||||
if (matched != null && !matched.isEmpty()) {
|
||||
m_messagesStore.storeSensitiveMessage(message);
|
||||
if (mSensitiveType == 0) {
|
||||
errorCode = ErrorCode.ERROR_CODE_SENSITIVE_MATCHED;
|
||||
} else if(mSensitiveType == 1) {
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <[email protected]>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package io.moquette.imhandler;
|
||||
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.GroupNotificationBinaryContent;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_SUCCESS;
|
||||
|
||||
@Handler(IMTopic.SetGroupManagerTopic)
|
||||
public class SetGroupManagerHandler extends GroupHandler<WFCMessage.SetGroupManagerRequest> {
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.SetGroupManagerRequest request, Qos1PublishHandler.IMCallback callback) {
|
||||
ErrorCode errorCode = m_messagesStore.setGroupManager(fromUser, request.getGroupId(), request.getType(), request.getUserIdList(), isAdmin);
|
||||
if (errorCode == ERROR_CODE_SUCCESS) {
|
||||
if (request.hasNotifyContent() && request.getNotifyContent().getType() > 0) {
|
||||
sendGroupNotification(fromUser, request.getGroupId(), request.getToLineList(), request.getNotifyContent());
|
||||
} else {
|
||||
WFCMessage.MessageContent content = new GroupNotificationBinaryContent(request.getGroupId(), fromUser, request.getType() + "", request.getUserIdList()).getSetGroupManagerNotifyContent();
|
||||
sendGroupNotification(fromUser, request.getGroupId(), request.getToLineList(), content);
|
||||
}
|
||||
}
|
||||
return errorCode;
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ public class UploadDeviceTokenHandler extends IMHandler<WFCMessage.UploadDeviceT
|
||||
session.setAppName(request.getAppName());
|
||||
if (request.getPlatform() == ProtoConstants.Platform.Platform_iOS && request.getPushType() == 2) {
|
||||
session.setVoipDeviceToken(request.getDeviceToken());
|
||||
session.setPushType(0);//如果有voip token,肯定是生产环境的推送
|
||||
// session.setPushType(0);//如果有voip token,肯定是生产环境的推送
|
||||
m_sessionsStore.updateSessionToken(session, true);
|
||||
} else {
|
||||
session.setDeviceToken(request.getDeviceToken());
|
||||
|
||||
@@ -384,11 +384,12 @@ public class DatabaseStore {
|
||||
try {
|
||||
connection = DBUtil.getConnection();
|
||||
String sql = "insert into " + MessageShardingUtil.getMessageTable(message.getMessageId()) +
|
||||
" (`_mid`, `_from`, `_type`, `_target`, `_line`, `_data`, `_searchable_key`, `_dt`) values(?, ?, ?, ?, ?, ?, ?, ?)" +
|
||||
" (`_mid`, `_from`, `_type`, `_target`, `_line`, `_data`, `_searchable_key`, `_dt`, `_content_type`) values(?, ?, ?, ?, ?, ?, ?, ?, ?)" +
|
||||
" ON DUPLICATE KEY UPDATE " +
|
||||
"`_data` = ?," +
|
||||
"`_searchable_key` = ?," +
|
||||
"`_dt` = ?";
|
||||
"`_dt` = ?," +
|
||||
"`_content_type` = ?";
|
||||
|
||||
String searchableContent = message.getContent().getSearchableContent() == null ? "" : message.getContent().getSearchableContent();
|
||||
|
||||
@@ -404,10 +405,63 @@ public class DatabaseStore {
|
||||
statement.setBlob(index++, blob);
|
||||
statement.setString(index++, searchableContent);
|
||||
statement.setTimestamp(index++, new Timestamp(message.getServerTimestamp()));
|
||||
statement.setInt(index++, message.getContent().getType());
|
||||
|
||||
statement.setBlob(index++, blob);
|
||||
statement.setString(index++, searchableContent);
|
||||
statement.setTimestamp(index++, new Timestamp(message.getServerTimestamp()));
|
||||
statement.setInt(index++, message.getContent().getType());
|
||||
|
||||
int count = statement.executeUpdate();
|
||||
LOG.info("Update rows {}", count);
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
Utility.printExecption(LOG, e);
|
||||
} finally {
|
||||
DBUtil.closeDB(connection, statement);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void persistSensitiveMessage(final WFCMessage.Message message) {
|
||||
if(message.getContent().getPersistFlag() == Transparent) {
|
||||
return;
|
||||
}
|
||||
|
||||
mScheduler.execute(()-> {
|
||||
Connection connection = null;
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
connection = DBUtil.getConnection();
|
||||
String sql = "insert into " + "t_sensitive_messages" +
|
||||
" (`_mid`, `_from`, `_type`, `_target`, `_line`, `_data`, `_searchable_key`, `_dt`, `_content_type`) values(?, ?, ?, ?, ?, ?, ?, ?, ?)" +
|
||||
" ON DUPLICATE KEY UPDATE " +
|
||||
"`_data` = ?," +
|
||||
"`_searchable_key` = ?," +
|
||||
"`_dt` = ?," +
|
||||
"`_content_type` = ?";
|
||||
|
||||
String searchableContent = message.getContent().getSearchableContent() == null ? "" : message.getContent().getSearchableContent();
|
||||
|
||||
statement = connection.prepareStatement(sql);
|
||||
int index = 1;
|
||||
statement.setLong(index++, message.getMessageId());
|
||||
statement.setString(index++, message.getFromUser());
|
||||
statement.setInt(index++, message.getConversation().getType());
|
||||
statement.setString(index++, message.getConversation().getTarget());
|
||||
statement.setInt(index++, message.getConversation().getLine());
|
||||
Blob blob = connection.createBlob();
|
||||
blob.setBytes(1, message.getContent().toByteArray());
|
||||
statement.setBlob(index++, blob);
|
||||
statement.setString(index++, searchableContent);
|
||||
statement.setTimestamp(index++, new Timestamp(message.getServerTimestamp()));
|
||||
statement.setInt(index++, message.getContent().getType());
|
||||
|
||||
statement.setBlob(index++, blob);
|
||||
statement.setString(index++, searchableContent);
|
||||
statement.setTimestamp(index++, new Timestamp(message.getServerTimestamp()));
|
||||
statement.setInt(index++, message.getContent().getType());
|
||||
|
||||
int count = statement.executeUpdate();
|
||||
LOG.info("Update rows {}", count);
|
||||
@@ -739,7 +793,11 @@ public class DatabaseStore {
|
||||
", `_extra`" +
|
||||
", `_dt`" +
|
||||
", `_member_count`" +
|
||||
", `_member_dt`) values(?, ?, ?, ?, ?, ?, ?, ?, ?)" +
|
||||
", `_mute`" +
|
||||
", `_join_type`" +
|
||||
", `_private_chat`" +
|
||||
", `_searchable`" +
|
||||
", `_member_dt`) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" +
|
||||
" ON DUPLICATE KEY UPDATE " +
|
||||
"`_name` = ?," +
|
||||
"`_portrait` = ?," +
|
||||
@@ -748,6 +806,10 @@ public class DatabaseStore {
|
||||
"`_extra` = ?," +
|
||||
"`_dt` = ?," +
|
||||
"`_member_count` = ?," +
|
||||
"`_mute` = ?" +
|
||||
", `_join_type` = ?" +
|
||||
", `_private_chat` = ?" +
|
||||
", `_searchable` = ?, " +
|
||||
"`_member_dt` = ?";
|
||||
|
||||
|
||||
@@ -762,6 +824,10 @@ public class DatabaseStore {
|
||||
statement.setString(index++, groupInfo.getExtra());
|
||||
statement.setLong(index++, groupInfo.getUpdateDt() == 0 ? System.currentTimeMillis() : groupInfo.getUpdateDt());
|
||||
statement.setInt(index++, groupInfo.getMemberCount());
|
||||
statement.setInt(index++, groupInfo.getMute());
|
||||
statement.setInt(index++, groupInfo.getJoinType());
|
||||
statement.setInt(index++, groupInfo.getPrivateChat());
|
||||
statement.setInt(index++, groupInfo.getSearchable());
|
||||
statement.setLong(index++, groupInfo.getMemberUpdateDt() == 0 ? System.currentTimeMillis() : groupInfo.getUpdateDt());
|
||||
|
||||
statement.setString(index++, groupInfo.getName());
|
||||
@@ -771,6 +837,10 @@ public class DatabaseStore {
|
||||
statement.setString(index++, groupInfo.getExtra());
|
||||
statement.setLong(index++, groupInfo.getUpdateDt() == 0 ? System.currentTimeMillis() : groupInfo.getUpdateDt());
|
||||
statement.setInt(index++, groupInfo.getMemberCount());
|
||||
statement.setInt(index++, groupInfo.getMute());
|
||||
statement.setInt(index++, groupInfo.getJoinType());
|
||||
statement.setInt(index++, groupInfo.getPrivateChat());
|
||||
statement.setInt(index++, groupInfo.getSearchable());
|
||||
statement.setLong(index++, groupInfo.getMemberUpdateDt() == 0 ? System.currentTimeMillis() : groupInfo.getUpdateDt());
|
||||
int count = statement.executeUpdate();
|
||||
LOG.info("Update rows {}", count);
|
||||
@@ -1101,6 +1171,10 @@ public class DatabaseStore {
|
||||
", `_dt`" +
|
||||
", `_member_count`" +
|
||||
", `_member_dt`" +
|
||||
", `_mute`" +
|
||||
", `_join_type`" +
|
||||
", `_private_chat`" +
|
||||
", `_searchable`" +
|
||||
" from t_group where `_gid` = ?";
|
||||
|
||||
statement = connection.prepareStatement(sql);
|
||||
@@ -1136,18 +1210,27 @@ public class DatabaseStore {
|
||||
strValue = (strValue == null ? "" : strValue);
|
||||
builder.setExtra(strValue);
|
||||
|
||||
|
||||
|
||||
long longValue = rs.getLong(index++);
|
||||
builder.setUpdateDt(longValue);
|
||||
|
||||
|
||||
intValue = rs.getInt(index++);
|
||||
builder.setMemberCount(intValue);
|
||||
|
||||
longValue = rs.getLong(index++);
|
||||
builder.setMemberUpdateDt(longValue);
|
||||
|
||||
intValue = rs.getInt(index++);
|
||||
builder.setMute(intValue);
|
||||
|
||||
intValue = rs.getInt(index++);
|
||||
builder.setJoinType(intValue);
|
||||
|
||||
intValue = rs.getInt(index++);
|
||||
builder.setPrivateChat(intValue);
|
||||
|
||||
intValue = rs.getInt(index++);
|
||||
builder.setSearchable(intValue);
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
@@ -1569,6 +1652,27 @@ public class DatabaseStore {
|
||||
});
|
||||
}
|
||||
|
||||
void deleteUserStatus(String userId) {
|
||||
mScheduler.execute(()->{
|
||||
Connection connection = null;
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
connection = DBUtil.getConnection();
|
||||
String sql = "delete from t_user_status where _uid = ?";
|
||||
statement = connection.prepareStatement(sql);
|
||||
statement.setString(1, userId);
|
||||
int count = statement.executeUpdate();
|
||||
LOG.info("Update rows {}", count);
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
Utility.printExecption(LOG, e);
|
||||
} finally {
|
||||
DBUtil.closeDB(connection, statement);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void updateUserStatus(String userId, int status) {
|
||||
mScheduler.execute(()->{
|
||||
Connection connection = null;
|
||||
@@ -1903,7 +2007,6 @@ public class DatabaseStore {
|
||||
}
|
||||
|
||||
void persistFriendRequestUnreadStatus(String userId, long readDt, long updateDt) {
|
||||
mScheduler.execute(()->{
|
||||
Connection connection = null;
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
@@ -1930,11 +2033,9 @@ public class DatabaseStore {
|
||||
} finally {
|
||||
DBUtil.closeDB(connection, statement);
|
||||
}
|
||||
});
|
||||
}
|
||||
//
|
||||
void persistOrUpdateFriendRequest(final WFCMessage.FriendRequest request) {
|
||||
mScheduler.execute(()->{
|
||||
Connection connection = null;
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
@@ -1971,11 +2072,9 @@ public class DatabaseStore {
|
||||
} finally {
|
||||
DBUtil.closeDB(connection, statement);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void persistOrUpdateFriendData(final FriendData request) {
|
||||
mScheduler.execute(()->{
|
||||
Connection connection = null;
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
@@ -2006,7 +2105,6 @@ public class DatabaseStore {
|
||||
} finally {
|
||||
DBUtil.closeDB(connection, statement);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
boolean removeGroupInfoFromDB(String groupId) {
|
||||
|
||||
@@ -49,10 +49,9 @@ import java.util.function.Consumer;
|
||||
|
||||
|
||||
import static cn.wildfirechat.proto.ProtoConstants.ChannelStatus.Channel_Status_Destoryed;
|
||||
import static cn.wildfirechat.proto.ProtoConstants.GroupMemberType.*;
|
||||
import static cn.wildfirechat.proto.ProtoConstants.ModifyChannelInfoType.*;
|
||||
import static cn.wildfirechat.proto.ProtoConstants.ModifyGroupInfoType.Modify_Group_Extra;
|
||||
import static cn.wildfirechat.proto.ProtoConstants.ModifyGroupInfoType.Modify_Group_Name;
|
||||
import static cn.wildfirechat.proto.ProtoConstants.ModifyGroupInfoType.Modify_Group_Portrait;
|
||||
import static cn.wildfirechat.proto.ProtoConstants.ModifyGroupInfoType.*;
|
||||
import static cn.wildfirechat.proto.ProtoConstants.PersistFlag.Transparent;
|
||||
import static io.moquette.BrokerConstants.*;
|
||||
import static io.moquette.server.Constants.MAX_CHATROOM_MESSAGE_QUEUE;
|
||||
@@ -170,7 +169,14 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNotifyReceivers(String fromUser, WFCMessage.Message message, Set<String> notifyReceivers) {
|
||||
public void storeSensitiveMessage(WFCMessage.Message message) {
|
||||
databaseStore.persistSensitiveMessage(message);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getNotifyReceivers(String fromUser, WFCMessage.Message.Builder messageBuilder, Set<String> notifyReceivers) {
|
||||
WFCMessage.Message message = messageBuilder.build();
|
||||
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
||||
int type = message.getConversation().getType();
|
||||
|
||||
@@ -190,7 +196,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
MultiMap<String, WFCMessage.GroupMember> groupMembers = hzInstance.getMultiMap(GROUP_MEMBERS);
|
||||
Collection<WFCMessage.GroupMember> members = groupMembers.get(message.getConversation().getTarget());
|
||||
for (WFCMessage.GroupMember member : members) {
|
||||
if (member.getType() != ProtoConstants.GroupMemberType.GroupMemberType_Removed) {
|
||||
if (member.getType() != GroupMemberType_Removed) {
|
||||
notifyReceivers.add(member.getMemberId());
|
||||
}
|
||||
}
|
||||
@@ -596,19 +602,25 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
mIMap.put(groupId, groupInfo);
|
||||
MultiMap<String, WFCMessage.GroupMember> groupMembers = hzInstance.getMultiMap(GROUP_MEMBERS);
|
||||
|
||||
List<WFCMessage.GroupMember> updatedMemberList = new ArrayList<>();
|
||||
for (WFCMessage.GroupMember member : memberList) {
|
||||
member = member.toBuilder().setUpdateDt(dt).build();
|
||||
if (member.getMemberId().equals(groupInfo.getOwner())) {
|
||||
member = member.toBuilder().setUpdateDt(dt).setType(ProtoConstants.GroupMemberType.GroupMemberType_Owner).build();
|
||||
} else {
|
||||
member = member.toBuilder().setUpdateDt(dt).build();
|
||||
}
|
||||
groupMembers.put(groupId, member);
|
||||
updatedMemberList.add(member);
|
||||
}
|
||||
|
||||
databaseStore.persistGroupMember(groupId, memberList);
|
||||
databaseStore.persistGroupMember(groupId, updatedMemberList);
|
||||
|
||||
return groupInfo;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ErrorCode addGroupMembers(String operator, String groupId, List<WFCMessage.GroupMember> memberList) {
|
||||
public ErrorCode addGroupMembers(String operator, boolean isAdmin, String groupId, List<WFCMessage.GroupMember> memberList) {
|
||||
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
||||
IMap<String, WFCMessage.GroupInfo> mIMap = hzInstance.getMap(GROUPS_MAP);
|
||||
|
||||
@@ -616,12 +628,38 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
if (groupInfo == null) {
|
||||
return ErrorCode.ERROR_CODE_NOT_EXIST;
|
||||
}
|
||||
if (groupInfo.getType() == ProtoConstants.GroupType.GroupType_Restricted && (groupInfo.getOwner() == null || !groupInfo.getOwner().equals(operator))) {
|
||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
}
|
||||
|
||||
|
||||
MultiMap<String, WFCMessage.GroupMember> groupMembers = hzInstance.getMultiMap(GROUP_MEMBERS);
|
||||
|
||||
if (!isAdmin) {
|
||||
boolean isMember = false;
|
||||
boolean isManager = false;
|
||||
WFCMessage.GroupMember gm = getGroupMember(groupId, operator);
|
||||
if (gm != null) {
|
||||
if (gm.getType() == GroupMemberType_Removed) {
|
||||
return ErrorCode.ERROR_CODE_NOT_IN_GROUP;
|
||||
} else if (gm.getType() == GroupMemberType_Silent) {
|
||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
}
|
||||
isManager = (gm.getType() == GroupMemberType_Manager || gm.getType() == GroupMemberType_Owner);
|
||||
isMember = true;
|
||||
}
|
||||
|
||||
if (groupInfo.getType() == ProtoConstants.GroupType.GroupType_Restricted && ((groupInfo.getOwner() == null || !groupInfo.getOwner().equals(operator)) && !isManager)) {
|
||||
if (groupInfo.getJoinType() == 2) {
|
||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
} else if (groupInfo.getJoinType() == 1) {
|
||||
if (memberList.size() == 1 && operator.equals(memberList.get(0).getMemberId()))
|
||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isMember) {
|
||||
return ErrorCode.ERROR_CODE_NOT_IN_GROUP;
|
||||
}
|
||||
}
|
||||
|
||||
long updateDt = System.currentTimeMillis();
|
||||
|
||||
List<WFCMessage.GroupMember> tmp = new ArrayList<>();
|
||||
@@ -645,7 +683,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
|
||||
int count = 0;
|
||||
for (WFCMessage.GroupMember member : groupMembers.get(groupId)) {
|
||||
if (member.getType() != ProtoConstants.GroupMemberType.GroupMemberType_Removed) {
|
||||
if (member.getType() != GroupMemberType_Removed) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
@@ -657,7 +695,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorCode kickoffGroupMembers(String operator, String groupId, List<String> memberList) {
|
||||
public ErrorCode kickoffGroupMembers(String operator, boolean isAdmin, String groupId, List<String> memberList) {
|
||||
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
||||
IMap<String, WFCMessage.GroupInfo> mIMap = hzInstance.getMap(GROUPS_MAP);
|
||||
|
||||
@@ -665,8 +703,8 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
if (groupInfo == null) {
|
||||
return ErrorCode.ERROR_CODE_NOT_EXIST;
|
||||
}
|
||||
if ((groupInfo.getType() == ProtoConstants.GroupType.GroupType_Restricted || groupInfo.getType() == ProtoConstants.GroupType.GroupType_Normal)
|
||||
&& (groupInfo.getOwner() == null || !groupInfo.getOwner().equals(operator))) {
|
||||
if (!isAdmin && ((groupInfo.getType() == ProtoConstants.GroupType.GroupType_Restricted || groupInfo.getType() == ProtoConstants.GroupType.GroupType_Normal)
|
||||
&& (groupInfo.getOwner() == null || !groupInfo.getOwner().equals(operator)))) {
|
||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
}
|
||||
|
||||
@@ -681,7 +719,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
boolean removed = groupMembers.remove(groupId, member);
|
||||
if (removed) {
|
||||
removeCount++;
|
||||
member = member.toBuilder().setType(ProtoConstants.GroupMemberType.GroupMemberType_Removed).setUpdateDt(updateDt).build();
|
||||
member = member.toBuilder().setType(GroupMemberType_Removed).setUpdateDt(updateDt).build();
|
||||
groupMembers.put(groupId, member);
|
||||
list.add(member);
|
||||
}
|
||||
@@ -732,7 +770,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
databaseStore.persistGroupMember(groupId, list);
|
||||
|
||||
databaseStore.updateGroupMemberCountDt(groupId, groupInfo.getMemberCount()-1, updateDt);
|
||||
member = member.toBuilder().setType(ProtoConstants.GroupMemberType.GroupMemberType_Removed).setUpdateDt(updateDt).build();
|
||||
member = member.toBuilder().setType(GroupMemberType_Removed).setUpdateDt(updateDt).build();
|
||||
groupMembers.put(groupId, member);
|
||||
}
|
||||
break;
|
||||
@@ -776,7 +814,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorCode modifyGroupInfo(String operator, String groupId, int modifyType, String value) {
|
||||
public ErrorCode modifyGroupInfo(String operator, String groupId, int modifyType, String value, boolean isAdmin) {
|
||||
|
||||
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
||||
IMap<String, WFCMessage.GroupInfo> mIMap = hzInstance.getMap(GROUPS_MAP);
|
||||
@@ -787,22 +825,36 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
return ErrorCode.ERROR_CODE_NOT_EXIST;
|
||||
}
|
||||
|
||||
if ((oldInfo.getType() == ProtoConstants.GroupType.GroupType_Restricted)
|
||||
&& (oldInfo.getOwner() == null || !oldInfo.getOwner().equals(operator))) {
|
||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
}
|
||||
|
||||
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 (!isAdmin) {
|
||||
if (oldInfo.getType() == ProtoConstants.GroupType.GroupType_Restricted) {
|
||||
boolean isAllow = false;
|
||||
if ((oldInfo.getOwner() != null && oldInfo.getOwner().equals(operator))) {
|
||||
isAllow = true;
|
||||
} else {
|
||||
WFCMessage.GroupMember gm = getGroupMember(groupId, operator);
|
||||
if (gm != null && gm.getType() == GroupMemberType_Manager) {
|
||||
isAllow = true;
|
||||
}
|
||||
}
|
||||
if (!isAllow) {
|
||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
WFCMessage.GroupInfo.Builder newInfoBuilder = oldInfo.toBuilder();
|
||||
|
||||
if (modifyType == Modify_Group_Name)
|
||||
@@ -811,6 +863,16 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
newInfoBuilder.setPortrait(value);
|
||||
else if(modifyType == Modify_Group_Extra)
|
||||
newInfoBuilder.setExtra(value);
|
||||
else if(modifyType == Modify_Group_Mute)
|
||||
newInfoBuilder.setMute(Integer.parseInt(value));
|
||||
else if(modifyType == Modify_Group_JoinType)
|
||||
newInfoBuilder.setJoinType(Integer.parseInt(value));
|
||||
else if(modifyType == Modify_Group_PrivateChat)
|
||||
newInfoBuilder.setPrivateChat(Integer.parseInt(value));
|
||||
else if(modifyType == Modify_Group_Searchable)
|
||||
newInfoBuilder.setSearchable(Integer.parseInt(value));
|
||||
else
|
||||
return ErrorCode.INVALID_PARAMETER;
|
||||
|
||||
|
||||
newInfoBuilder.setUpdateDt(System.currentTimeMillis());
|
||||
@@ -908,6 +970,24 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
return ErrorCode.ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WFCMessage.GroupMember getGroupMember(String groupId, String memberId) {
|
||||
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
||||
|
||||
MultiMap<String, WFCMessage.GroupMember> groupMembers = hzInstance.getMultiMap(GROUP_MEMBERS);
|
||||
|
||||
Collection<WFCMessage.GroupMember> members = groupMembers.get(groupId);
|
||||
if (members != null) {
|
||||
for (WFCMessage.GroupMember gm : members) {
|
||||
if (gm.getMemberId().equals(memberId)) {
|
||||
return gm;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ErrorCode transferGroup(String operator, String groupId, String newOwner, boolean isAdmin) {
|
||||
@@ -935,6 +1015,40 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
return ErrorCode.ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorCode setGroupManager(String operator, String groupId, int type, List<String> userList, boolean isAdmin) {
|
||||
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
||||
IMap<String, WFCMessage.GroupInfo> mIMap = hzInstance.getMap(GROUPS_MAP);
|
||||
|
||||
|
||||
WFCMessage.GroupInfo groupInfo = mIMap.get(groupId);
|
||||
|
||||
if (groupInfo == null) {
|
||||
return ErrorCode.ERROR_CODE_NOT_EXIST;
|
||||
}
|
||||
|
||||
if (!isAdmin && (groupInfo.getType() == ProtoConstants.GroupType.GroupType_Restricted || groupInfo.getType() == ProtoConstants.GroupType.GroupType_Normal)
|
||||
&& (groupInfo.getOwner() == null || !groupInfo.getOwner().equals(operator))) {
|
||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
}
|
||||
|
||||
long updateDt = System.currentTimeMillis();
|
||||
MultiMap<String, WFCMessage.GroupMember> groupMembers = hzInstance.getMultiMap(GROUP_MEMBERS);
|
||||
Collection<WFCMessage.GroupMember> members = groupMembers.get(groupId);
|
||||
for (WFCMessage.GroupMember member : members) {
|
||||
if (userList.contains(member.getMemberId())) {
|
||||
groupMembers.remove(groupId, member);
|
||||
member = member.toBuilder().setType(ProtoConstants.GroupMemberType.GroupMemberType_Manager).setUpdateDt(updateDt).build();
|
||||
databaseStore.persistGroupMember(groupId, Arrays.asList(member));
|
||||
groupMembers.put(groupId, member);
|
||||
// userList.remove(member.getMemberId());
|
||||
}
|
||||
}
|
||||
|
||||
mIMap.put(groupId, groupInfo.toBuilder().setUpdateDt(updateDt).setMemberUpdateDt(updateDt).build());
|
||||
return ErrorCode.ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMemberInGroup(String memberId, String groupId) {
|
||||
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
||||
@@ -944,7 +1058,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
|
||||
for (WFCMessage.GroupMember member : members
|
||||
) {
|
||||
if (member.getMemberId().equals(memberId) && member.getType() != ProtoConstants.GroupMemberType.GroupMemberType_Removed)
|
||||
if (member.getMemberId().equals(memberId) && member.getType() != GroupMemberType_Removed)
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -952,19 +1066,41 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isForbiddenInGroup(String memberId, String groupId) {
|
||||
public ErrorCode canSendMessageInGroup(String memberId, String groupId) {
|
||||
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
||||
MultiMap<String, WFCMessage.GroupMember> groupMembers = hzInstance.getMultiMap(GROUP_MEMBERS);
|
||||
IMap<String, WFCMessage.GroupInfo> groups = hzInstance.getMap(GROUPS_MAP);
|
||||
WFCMessage.GroupInfo groupInfo = groups.get(groupId);
|
||||
boolean isMute = false;
|
||||
if (groupInfo != null) {
|
||||
if (groupInfo.getOwner().equals(memberId)) {
|
||||
return ErrorCode.ERROR_CODE_SUCCESS;
|
||||
}
|
||||
isMute = groupInfo.getMute()>0;
|
||||
}
|
||||
|
||||
Collection<WFCMessage.GroupMember> members = groupMembers.get(groupId);
|
||||
|
||||
for (WFCMessage.GroupMember member : members
|
||||
) {
|
||||
if (member.getMemberId().equals(memberId) && member.getType() == ProtoConstants.GroupMemberType.GroupMemberType_Silent)
|
||||
return true;
|
||||
if (member.getMemberId().equals(memberId)) {
|
||||
if (member.getType() == GroupMemberType_Silent) {
|
||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
}
|
||||
|
||||
if (isMute && member.getType() != GroupMemberType_Manager && member.getType() != GroupMemberType_Owner) {
|
||||
return ErrorCode.ERROR_CODE_GROUP_MUTED;
|
||||
}
|
||||
|
||||
if (member.getMemberId().equals(memberId) && member.getType() == GroupMemberType_Removed) {
|
||||
return ErrorCode.ERROR_CODE_NOT_IN_GROUP;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
return ErrorCode.ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -995,7 +1131,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
Collection<WFCMessage.GroupMember> members = groupMembers.get(message.getConversation().getTarget());
|
||||
for (WFCMessage.GroupMember member : members) {
|
||||
if (member.getMemberId().equals(operatorId)) {
|
||||
if (member.getType() == ProtoConstants.GroupMemberType.GroupMemberType_Manager || member.getType() == ProtoConstants.GroupMemberType.GroupMemberType_Owner) {
|
||||
if (member.getType() == GroupMemberType_Manager || member.getType() == ProtoConstants.GroupMemberType.GroupMemberType_Owner) {
|
||||
canRecall = true;
|
||||
}
|
||||
break;
|
||||
@@ -1158,7 +1294,6 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
} else {
|
||||
mUserMap.put(userId, status);
|
||||
}
|
||||
databaseStore.updateUserStatus(userId, status);
|
||||
return ErrorCode.ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1340,8 +1475,8 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
|
||||
Collection<FriendData> friendDatas = friendsMap.get(fromUser);
|
||||
|
||||
if (friendDatas == null) {
|
||||
return false;
|
||||
if (friendDatas == null || friendDatas.size() == 0) {
|
||||
friendDatas = loadFriend(friendsMap, fromUser);
|
||||
}
|
||||
|
||||
for (FriendData friendData : friendDatas) {
|
||||
@@ -1412,6 +1547,31 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
}
|
||||
}
|
||||
|
||||
synchronized Collection<FriendData> loadFriend(MultiMap<String, FriendData> friendsMap, String userId) {
|
||||
Collection<FriendData> friends = databaseStore.getPersistFriends(userId);
|
||||
if (friends != null) {
|
||||
for (FriendData friend : friends) {
|
||||
friendsMap.put(userId, friend);
|
||||
}
|
||||
} else {
|
||||
friends = new ArrayList<>();
|
||||
}
|
||||
return friends;
|
||||
}
|
||||
|
||||
synchronized Collection<WFCMessage.FriendRequest> loadFriendRequest(MultiMap<String, WFCMessage.FriendRequest> requestMap, String userId) {
|
||||
Collection<WFCMessage.FriendRequest> requests = databaseStore.getPersistFriendRequests(userId);
|
||||
if (requests != null) {
|
||||
for (WFCMessage.FriendRequest r : requests
|
||||
) {
|
||||
requestMap.put(userId, r);
|
||||
}
|
||||
} else {
|
||||
requests = new ArrayList<>();
|
||||
}
|
||||
return requests;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FriendData> getFriendList(String userId, long version) {
|
||||
List<FriendData> out = new ArrayList<FriendData>();
|
||||
@@ -1420,14 +1580,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
MultiMap<String, FriendData> friendsMap = hzInstance.getMultiMap(USER_FRIENDS);
|
||||
Collection<FriendData> friends = friendsMap.get(userId);
|
||||
if (friends == null || friends.size() == 0) {
|
||||
friends = databaseStore.getPersistFriends(userId);
|
||||
if (friends != null) {
|
||||
for (FriendData friend : friends) {
|
||||
friendsMap.put(userId, friend);
|
||||
}
|
||||
} else {
|
||||
friends = new ArrayList<>();
|
||||
}
|
||||
friends = loadFriend(friendsMap, userId);
|
||||
}
|
||||
|
||||
for (FriendData friend : friends) {
|
||||
@@ -1447,15 +1600,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
MultiMap<String, WFCMessage.FriendRequest> requestMap = hzInstance.getMultiMap(USER_FRIENDS_REQUEST);
|
||||
Collection<WFCMessage.FriendRequest> requests = requestMap.get(userId);
|
||||
if (requests == null || requests.size() == 0) {
|
||||
requests = databaseStore.getPersistFriendRequests(userId);
|
||||
if (requests != null) {
|
||||
for (WFCMessage.FriendRequest request : requests) {
|
||||
if (request.getUpdateDt() > version)
|
||||
requestMap.put(userId, request);
|
||||
}
|
||||
} else {
|
||||
requests = new ArrayList<>();
|
||||
}
|
||||
requests = loadFriendRequest(requestMap, userId);
|
||||
}
|
||||
|
||||
for (WFCMessage.FriendRequest request : requests) {
|
||||
@@ -1473,15 +1618,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
MultiMap<String, WFCMessage.FriendRequest> requestMap = hzInstance.getMultiMap(USER_FRIENDS_REQUEST);
|
||||
Collection<WFCMessage.FriendRequest> requests = requestMap.get(userId);
|
||||
if (requests == null || requests.size() == 0) {
|
||||
requests = databaseStore.getPersistFriendRequests(userId);
|
||||
if (requests != null) {
|
||||
for (WFCMessage.FriendRequest r : requests
|
||||
) {
|
||||
requestMap.put(userId, r);
|
||||
}
|
||||
} else {
|
||||
requests = new ArrayList<>();
|
||||
}
|
||||
requests = loadFriendRequest(requestMap, userId);
|
||||
}
|
||||
|
||||
WFCMessage.FriendRequest existRequest = null;
|
||||
@@ -1499,7 +1636,6 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
&& System.currentTimeMillis() - existRequest.getUpdateDt() < 30 * 24 * 60 * 60 * 1000) {
|
||||
return ErrorCode.ERROR_CODE_FRIEND_REQUEST_BLOCKED;
|
||||
}
|
||||
requestMap.remove(userId, existRequest);
|
||||
} else {
|
||||
return ErrorCode.ERROR_CODE_FRIEND_ALREADY_REQUEST;
|
||||
}
|
||||
@@ -1514,9 +1650,10 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
.setUpdateDt(System.currentTimeMillis())
|
||||
.build();
|
||||
|
||||
requestMap.put(userId, newRequest);
|
||||
requestMap.put(request.getTargetUid(), newRequest);
|
||||
databaseStore.persistOrUpdateFriendRequest(newRequest);
|
||||
requestMap.remove(userId);
|
||||
requestMap.remove(request.getTargetUid());
|
||||
|
||||
head[0] = newRequest.getUpdateDt();
|
||||
return ErrorCode.ERROR_CODE_SUCCESS;
|
||||
}
|
||||
@@ -1544,6 +1681,9 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
|
||||
FriendData friendData1 = null;
|
||||
Collection<FriendData> friendDatas = friendsMap.get(userId);
|
||||
if (friendDatas == null || friendDatas.size() == 0) {
|
||||
friendDatas = loadFriend(friendsMap, userId);
|
||||
}
|
||||
for (FriendData fd : friendDatas) {
|
||||
if (fd.getFriendUid().equals(request.getTargetUid())) {
|
||||
friendData1 = fd;
|
||||
@@ -1553,18 +1693,19 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
if (friendData1 == null) {
|
||||
friendData1 = new FriendData(userId, request.getTargetUid(), "", request.getStatus(), System.currentTimeMillis());
|
||||
} else {
|
||||
friendsMap.remove(userId, friendData1);
|
||||
friendData1.setState(request.getStatus());
|
||||
friendData1.setTimestamp(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
friendsMap.put(userId, friendData1);
|
||||
databaseStore.persistOrUpdateFriendData(friendData1);
|
||||
|
||||
if (request.getStatus() != 2) {
|
||||
FriendData friendData2 = null;
|
||||
|
||||
friendDatas = friendsMap.get(request.getTargetUid());
|
||||
if (friendDatas == null || friendDatas.size() == 0) {
|
||||
friendDatas = loadFriend(friendsMap, request.getTargetUid());
|
||||
}
|
||||
for (FriendData fd : friendDatas) {
|
||||
if (fd.getFriendUid().equals(userId)) {
|
||||
friendData2 = fd;
|
||||
@@ -1579,8 +1720,6 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
friendData2.setTimestamp(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
|
||||
friendsMap.put(request.getTargetUid(), friendData2);
|
||||
databaseStore.persistOrUpdateFriendData(friendData2);
|
||||
|
||||
heads[0] = friendData2.getTimestamp();
|
||||
@@ -1588,19 +1727,15 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
heads[0] = 0;
|
||||
}
|
||||
heads[1] = friendData1.getTimestamp();
|
||||
friendsMap.remove(userId);
|
||||
friendsMap.remove(request.getTargetUid());
|
||||
return ErrorCode.ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
MultiMap<String, WFCMessage.FriendRequest> requestMap = hzInstance.getMultiMap(USER_FRIENDS_REQUEST);
|
||||
Collection<WFCMessage.FriendRequest> requests = requestMap.get(userId);
|
||||
if (requests == null || requests.size() == 0) {
|
||||
requests = databaseStore.getPersistFriendRequests(userId);
|
||||
if (requests != null) {
|
||||
for (WFCMessage.FriendRequest r : requests
|
||||
) {
|
||||
requestMap.put(userId, r);
|
||||
}
|
||||
}
|
||||
requests = loadFriendRequest(requestMap, userId);
|
||||
}
|
||||
|
||||
WFCMessage.FriendRequest existRequest = null;
|
||||
@@ -1615,22 +1750,21 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
if (System.currentTimeMillis() - existRequest.getUpdateDt() > 7 * 24 * 60 * 60 * 1000) {
|
||||
return ErrorCode.ERROR_CODE_FRIEND_REQUEST_OVERTIME;
|
||||
} else {
|
||||
requestMap.remove(userId, existRequest);
|
||||
existRequest = existRequest.toBuilder().setStatus(ProtoConstants.FriendRequestStatus.RequestStatus_Accepted).setUpdateDt(System.currentTimeMillis()).build();
|
||||
databaseStore.persistOrUpdateFriendRequest(existRequest);
|
||||
requestMap.put(userId, existRequest);
|
||||
|
||||
|
||||
MultiMap<String, FriendData> friendsMap = hzInstance.getMultiMap(USER_FRIENDS);
|
||||
|
||||
FriendData friendData1 = new FriendData(userId, request.getTargetUid(), "", 0, System.currentTimeMillis());
|
||||
friendsMap.put(userId, friendData1);
|
||||
databaseStore.persistOrUpdateFriendData(friendData1);
|
||||
|
||||
FriendData friendData2 = new FriendData(request.getTargetUid(), userId, "", 0, friendData1.getTimestamp());
|
||||
friendsMap.put(request.getTargetUid(), friendData2);
|
||||
databaseStore.persistOrUpdateFriendData(friendData2);
|
||||
|
||||
requestMap.remove(userId);
|
||||
requestMap.remove(request.getTargetUid());
|
||||
friendsMap.remove(userId);
|
||||
friendsMap.remove(request.getTargetUid());
|
||||
|
||||
heads[0] = friendData2.getTimestamp();
|
||||
heads[1] = friendData1.getTimestamp();
|
||||
|
||||
@@ -1650,6 +1784,10 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
|
||||
FriendData friendData = null;
|
||||
Collection<FriendData> friends = friendsMap.get(fromUser);
|
||||
if (friends == null || friends.size() == 0) {
|
||||
friends = loadFriend(friendsMap, fromUser);
|
||||
}
|
||||
|
||||
for (FriendData fd:friends) {
|
||||
if (fd.getFriendUid().equals(targetUserId)) {
|
||||
friendData = fd;
|
||||
@@ -1663,8 +1801,9 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
friendData.setState(state);
|
||||
friendData.setTimestamp(System.currentTimeMillis());
|
||||
|
||||
friendsMap.put(fromUser, friendData);
|
||||
|
||||
databaseStore.persistOrUpdateFriendData(friendData);
|
||||
friendsMap.remove(fromUser);
|
||||
|
||||
heads[0] = friendData.getTimestamp();
|
||||
|
||||
@@ -1678,6 +1817,10 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
|
||||
FriendData friendData = null;
|
||||
Collection<FriendData> friends = friendsMap.get(fromUser);
|
||||
if (friends == null || friends.size() == 0) {
|
||||
friends = loadFriend(friendsMap, fromUser);
|
||||
}
|
||||
|
||||
for (FriendData fd:friends) {
|
||||
if (fd.getFriendUid().equals(targetUserId)) {
|
||||
friendData = fd;
|
||||
@@ -1692,11 +1835,12 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
friendData.setAlias(alias);
|
||||
friendData.setTimestamp(System.currentTimeMillis());
|
||||
|
||||
friendsMap.put(fromUser, friendData);
|
||||
databaseStore.persistOrUpdateFriendData(friendData);
|
||||
|
||||
heads[0] = friendData.getTimestamp();
|
||||
|
||||
friendsMap.remove(fromUser);
|
||||
|
||||
return ErrorCode.ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1731,35 +1875,43 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorCode deleteFriend(String userId, String friendUid) {
|
||||
public ErrorCode deleteFriend(String userId, String friendUid, long[] head) {
|
||||
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
||||
MultiMap<String, FriendData> friendsMap = hzInstance.getMultiMap(USER_FRIENDS);
|
||||
Collection<FriendData> user1Friends = friendsMap.get(userId);
|
||||
if (user1Friends == null || user1Friends.size() == 0) {
|
||||
user1Friends = loadFriend(friendsMap, userId);
|
||||
}
|
||||
for (FriendData data :
|
||||
user1Friends) {
|
||||
if (data.getFriendUid().equals(friendUid)) {
|
||||
friendsMap.remove(userId, data);
|
||||
long ts = System.currentTimeMillis();
|
||||
head[0] = ts;
|
||||
data.setState(1);
|
||||
data.setTimestamp(System.currentTimeMillis());
|
||||
friendsMap.put(userId, data);
|
||||
data.setTimestamp(ts);
|
||||
databaseStore.persistOrUpdateFriendData(data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Collection<FriendData> user2Friends = friendsMap.get(friendUid);
|
||||
if (user2Friends == null || user2Friends.size() == 0) {
|
||||
user2Friends = loadFriend(friendsMap, friendUid);
|
||||
}
|
||||
for (FriendData data :
|
||||
user2Friends) {
|
||||
if (data.getFriendUid().equals(userId)) {
|
||||
friendsMap.remove(friendUid, data);
|
||||
data.setState(1);
|
||||
data.setTimestamp(System.currentTimeMillis());
|
||||
friendsMap.put(friendUid, data);
|
||||
long ts = System.currentTimeMillis();
|
||||
head[1] = ts;
|
||||
data.setTimestamp(ts);
|
||||
databaseStore.persistOrUpdateFriendData(data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
friendsMap.remove(userId);
|
||||
friendsMap.remove(friendUid);
|
||||
return ErrorCode.ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1864,7 +2016,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
if (entry.getScope() == request.getScope() && entry.getKey().equals(request.getKey())) {
|
||||
userSettingMap.remove(userId, entry);
|
||||
userSettingMap.put(userId, settingEntry);
|
||||
return updateDt;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2081,7 +2233,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
public boolean addSensitiveWords(List<String> words) {
|
||||
for (String word :
|
||||
words) {
|
||||
databaseStore.persistSensitiveWord(word);
|
||||
databaseStore.persistSensitiveWord(word.toLowerCase());
|
||||
}
|
||||
lastUpdateSensitiveTime = 0;
|
||||
return true;
|
||||
@@ -2150,15 +2302,10 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
||||
MultiMap<String, FriendData> friendsMap = hzInstance.getMultiMap(USER_FRIENDS);
|
||||
Collection<FriendData> friends = friendsMap.get(userId);
|
||||
long max = 0;
|
||||
if (friends == null || friends.size() == 0) {
|
||||
friends = databaseStore.getPersistFriends(userId);
|
||||
for (FriendData friend :
|
||||
friends) {
|
||||
friendsMap.put(userId, friend);
|
||||
}
|
||||
friends = loadFriend(friendsMap, userId);
|
||||
}
|
||||
|
||||
long max = 0;
|
||||
if (friends != null && friends.size() > 0) {
|
||||
for (FriendData friend :
|
||||
friends) {
|
||||
@@ -2177,11 +2324,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
Collection<WFCMessage.FriendRequest> friendsReq = friendsReqMap.get(userId);
|
||||
long max = 0;
|
||||
if (friendsReq == null || friendsReq.size() == 0) {
|
||||
friendsReq = databaseStore.getPersistFriendRequests(userId);
|
||||
for (WFCMessage.FriendRequest req : friendsReq
|
||||
) {
|
||||
friendsReqMap.put(userId, req);
|
||||
}
|
||||
friendsReq = loadFriendRequest(friendsReqMap, userId);
|
||||
}
|
||||
|
||||
if (friendsReq != null && friendsReq.size() > 0) {
|
||||
|
||||
@@ -27,7 +27,7 @@ public class UserStatusLoader implements MapStore<String, Integer> {
|
||||
|
||||
@Override
|
||||
public void delete(String s) {
|
||||
getDatabaseStore().deleteUser(s);
|
||||
getDatabaseStore().deleteUserStatus(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012-2017 The original author or authors
|
||||
* ------------------------------------------------------
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* and Apache License v2.0 which accompanies this distribution.
|
||||
*
|
||||
* The Eclipse Public License is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* The Apache License v2.0 is available at
|
||||
* http://www.opensource.org/licenses/apache2.0.php
|
||||
*
|
||||
* You may elect to redistribute this code under either of these licenses.
|
||||
*/
|
||||
package io.moquette.server.netty;
|
||||
|
||||
import com.bugsnag.Bugsnag;
|
||||
import io.moquette.server.config.IConfig;
|
||||
import io.netty.channel.ChannelHandler.Sharable;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||
|
||||
import static io.moquette.BrokerConstants.BUGSNAG_TOKEN_PROPERTY_NAME;
|
||||
|
||||
@Sharable
|
||||
public class BugSnagErrorsHandler extends ChannelInboundHandlerAdapter {
|
||||
|
||||
private Bugsnag bugsnag;
|
||||
|
||||
public void init(IConfig props) {
|
||||
final String token = props.getProperty(BUGSNAG_TOKEN_PROPERTY_NAME);
|
||||
this.bugsnag = new Bugsnag(token);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||
bugsnag.notify(cause);
|
||||
ctx.fireExceptionCaught(cause);
|
||||
}
|
||||
}
|
||||
@@ -148,14 +148,8 @@ public class NettyAcceptor implements ServerAcceptor {
|
||||
this.metrics = Optional.empty();
|
||||
}
|
||||
|
||||
final boolean useBugSnag = Boolean.parseBoolean(props.getProperty(BUGSNAG_ENABLE_PROPERTY_NAME, "false"));
|
||||
if (useBugSnag) {
|
||||
BugSnagErrorsHandler bugSnagHandler = new BugSnagErrorsHandler();
|
||||
bugSnagHandler.init(props);
|
||||
this.errorsCather = Optional.of(bugSnagHandler);
|
||||
} else {
|
||||
this.errorsCather = Optional.empty();
|
||||
}
|
||||
this.errorsCather = Optional.empty();
|
||||
|
||||
initializePlainTCPTransport(mqttHandler, props);
|
||||
initializeWebSocketTransport(mqttHandler, props);
|
||||
String sslTcpPortProp = props.getProperty(BrokerConstants.SSL_PORT_PROPERTY_NAME);
|
||||
@@ -260,7 +254,7 @@ public class NettyAcceptor implements ServerAcceptor {
|
||||
pipeline.addLast(new HttpServerCodec());
|
||||
pipeline.addLast("aggregator", new HttpObjectAggregator(65536));
|
||||
pipeline.addLast("webSocketHandler",
|
||||
new WebSocketServerProtocolHandler("/org/fusesource/mqtt", MQTT_SUBPROTOCOL_CSV_LIST));
|
||||
new WebSocketServerProtocolHandler("/", MQTT_SUBPROTOCOL_CSV_LIST));
|
||||
pipeline.addLast("ws2bytebufDecoder", new WebSocketFrameToByteBufDecoder());
|
||||
pipeline.addLast("bytebuf2wsEncoder", new ByteBufToWebSocketFrameEncoder());
|
||||
pipeline.addFirst("idleStateHandler", new IdleStateHandler(nettyChannelTimeoutSeconds, 0, 0));
|
||||
|
||||
@@ -96,24 +96,27 @@ public interface IMessagesStore {
|
||||
|
||||
DatabaseStore getDatabaseStore();
|
||||
WFCMessage.Message storeMessage(String fromUser, String fromClientId, WFCMessage.Message message);
|
||||
int getNotifyReceivers(String fromUser, WFCMessage.Message message, Set<String> notifyReceivers);
|
||||
void storeSensitiveMessage(WFCMessage.Message message);
|
||||
int getNotifyReceivers(String fromUser, WFCMessage.Message.Builder message, Set<String> notifyReceivers);
|
||||
Set<String> getAllEnds();
|
||||
WFCMessage.PullMessageResult fetchMessage(String user, String exceptClientId, long fromMessageId, int pullType);
|
||||
WFCMessage.PullMessageResult loadRemoteMessages(String user, WFCMessage.Conversation conversation, long beforeUid, int count);
|
||||
long insertUserMessages(String sender, int conversationType, String target, int line, int messageContentType, String userId, long messageId);
|
||||
WFCMessage.GroupInfo createGroup(String operator, WFCMessage.GroupInfo groupInfo, List<WFCMessage.GroupMember> memberList);
|
||||
ErrorCode addGroupMembers(String operator, String groupId, List<WFCMessage.GroupMember> memberList);
|
||||
ErrorCode kickoffGroupMembers(String operator, String groupId, List<String> memberList);
|
||||
ErrorCode addGroupMembers(String operator, boolean isAdmin, String groupId, List<WFCMessage.GroupMember> memberList);
|
||||
ErrorCode kickoffGroupMembers(String operator, boolean isAdmin, String groupId, List<String> memberList);
|
||||
ErrorCode quitGroup(String operator, String groupId);
|
||||
ErrorCode dismissGroup(String operator, String groupId, boolean isAdmin);
|
||||
ErrorCode modifyGroupInfo(String operator, String groupId, int modifyType, String value);
|
||||
ErrorCode modifyGroupInfo(String operator, String groupId, int modifyType, String value, boolean isAdmin);
|
||||
ErrorCode modifyGroupAlias(String operator, String groupId, String alias);
|
||||
List<WFCMessage.GroupInfo> getGroupInfos(List<WFCMessage.UserRequest> requests);
|
||||
WFCMessage.GroupInfo getGroupInfo(String groupId);
|
||||
ErrorCode getGroupMembers(String groupId, long maxDt, List<WFCMessage.GroupMember> members);
|
||||
WFCMessage.GroupMember getGroupMember(String groupId, String memberId);
|
||||
ErrorCode transferGroup(String operator, String groupId, String newOwner, boolean isAdmin);
|
||||
ErrorCode setGroupManager(String operator, String groupId, int type, List<String> userList, boolean isAdmin);
|
||||
boolean isMemberInGroup(String member, String groupId);
|
||||
boolean isForbiddenInGroup(String member, String groupId);
|
||||
ErrorCode canSendMessageInGroup(String member, String groupId);
|
||||
|
||||
ErrorCode recallMessage(long messageUid, String operatorId);
|
||||
|
||||
@@ -152,7 +155,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);
|
||||
ErrorCode deleteFriend(String userId, String friendUid);
|
||||
ErrorCode deleteFriend(String userId, String friendUid, long[] head);
|
||||
ErrorCode blackUserRequest(String fromUser, String targetUserId, int status, long[] head);
|
||||
ErrorCode SyncFriendRequestUnread(String userId, long unreadDt, long[] head);
|
||||
boolean isBlacked(String fromUser, String userId);
|
||||
|
||||
@@ -308,7 +308,7 @@ public class MessagesPublisher {
|
||||
}
|
||||
|
||||
if (isSlient) {
|
||||
LOG.info("The conversation is slient");
|
||||
LOG.info("Slient of user or conversation");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ public interface IMTopic {
|
||||
String GetGroupInfoTopic = "GPGI";
|
||||
String GetGroupMemberTopic = "GPGM";
|
||||
String TransferGroupTopic = "GTG";
|
||||
|
||||
String SetGroupManagerTopic = "GSM";
|
||||
|
||||
String GetUserInfoTopic = "UPUI";
|
||||
String ModifyMyInfoTopic = "MMI";
|
||||
|
||||
@@ -54,10 +54,15 @@ public class MessageShardingUtil {
|
||||
return "t_messages";
|
||||
}
|
||||
|
||||
mid >>= (nodeIdWidth + rotateIdWidth);
|
||||
Date date = new Date(mid + T201801010000);
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
if (mid != Long.MAX_VALUE) {
|
||||
mid >>= (nodeIdWidth + rotateIdWidth);
|
||||
Date date = new Date(mid + T201801010000);
|
||||
calendar.setTime(date);
|
||||
} else {
|
||||
Date date = new Date(System.currentTimeMillis());
|
||||
calendar.setTime(date);
|
||||
}
|
||||
int month = calendar.get(Calendar.MONTH);
|
||||
int year = calendar.get(Calendar.YEAR);
|
||||
year %= 3;
|
||||
|
||||
@@ -58,6 +58,7 @@ public class SensitiveFilter {
|
||||
return sensitiveWords;
|
||||
}
|
||||
|
||||
text = text.toLowerCase();
|
||||
for(int i=0;i<text.length();i++){
|
||||
int sensitiveWordLength = getSensitiveWordLength(text, i, matchType);
|
||||
if(sensitiveWordLength>0){
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<!--MySQL数据库驱动程序-->
|
||||
<property name="driverClass">com.mysql.cj.jdbc.Driver</property>
|
||||
<!--MySQL数据库地址-->
|
||||
<property name="jdbcUrl">jdbc:mysql://localhost:3306/wfchat?useSSL=false&serverTimezone=GMT&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=utf8</property>
|
||||
<property name="jdbcUrl">jdbc:mysql://localhost:3306/wfchat?useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=utf8</property>
|
||||
<!--MySQL数据库用户名-->
|
||||
<property name="user">root</property>
|
||||
<!--MySQL数据库密码-->
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
<relativePath>../</relativePath>
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.22</version>
|
||||
<version>0.24</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package cn.wildfirechat.client;
|
||||
|
||||
import cn.wildfirechat.proto.ProtoConstants;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import cn.wildfirechat.pojos.InputRoute;
|
||||
import com.xiaoleilu.loServer.pojos.InputRoute;
|
||||
import io.moquette.spi.impl.security.AES;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
@@ -18,6 +19,7 @@ import org.fusesource.mqtt.client.*;
|
||||
import java.io.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
|
||||
@@ -280,15 +282,38 @@ public class IMClient implements Listener {
|
||||
try {
|
||||
WFCMessage.NotifyMessage notifyMessage = WFCMessage.NotifyMessage.parseFrom(body.toByteArray());
|
||||
WFCMessage.PullMessageRequest request = WFCMessage.PullMessageRequest.newBuilder().setId(messageHead).setType(notifyMessage.getType()).build();
|
||||
connection.publish("MP", request.toByteArray(), QoS.AT_LEAST_ONCE, false, new Callback<byte[]>(){
|
||||
byte[] data = request.toByteArray();
|
||||
data = AES.AESEncrypt(data, privateSecret);
|
||||
connection.publish("MP", data, QoS.AT_LEAST_ONCE, false, new Callback<byte[]>(){
|
||||
@Override
|
||||
public void onSuccess(byte[] value) {
|
||||
if (value == null || value.length == 0) {
|
||||
System.out.println("Invalide data");
|
||||
}
|
||||
|
||||
if (value[0] != 0) {
|
||||
System.out.println("Pull message error with errorCode:" + value[0]);
|
||||
}
|
||||
|
||||
byte[] data = new byte[value.length - 1];
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
data[i] = value[i+1];
|
||||
}
|
||||
|
||||
try {
|
||||
byte[] data = AES.AESDecrypt(value, privateSecret, true);
|
||||
data = AES.AESDecrypt(data, privateSecret, true);
|
||||
try {
|
||||
WFCMessage.PullMessageResult result = WFCMessage.PullMessageResult.parseFrom(data);
|
||||
if (receiveMessageCallback != null) {
|
||||
receiveMessageCallback.onReceiveMessages(result.getMessageList(), false);
|
||||
if (receiveMessageCallback != null && result.getMessageList().size() > 0) {
|
||||
List<WFCMessage.Message> messages = result.getMessageList();
|
||||
List<WFCMessage.Message> out = new ArrayList<>();
|
||||
for (WFCMessage.Message msg : messages) {
|
||||
if (msg.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Private && msg.getConversation().getTarget().equals(userId)) {
|
||||
msg = msg.toBuilder().setConversation(msg.getConversation().toBuilder().setTarget(msg.getFromUser())).build();
|
||||
}
|
||||
out.add(msg);
|
||||
}
|
||||
receiveMessageCallback.onReceiveMessages(out, false);
|
||||
}
|
||||
messageHead = result.getHead();
|
||||
} catch (InvalidProtocolBufferException e) {
|
||||
@@ -355,23 +380,24 @@ public class IMClient implements Listener {
|
||||
|
||||
public static void main(String[] args) {
|
||||
//token与userid和clientid是绑定的,使用时一定要传入正确的userid和clientid,不然会认为token非法
|
||||
IMClient client = new IMClient("yzyOyOKK", "7SJk13q+YdHHe6EwDzry9BKogxTNf3UgtYj50cBTZgWNkNuxEkiqg2koKg0lXViONIX1LmwCR1jN0Mw8hvk6KGpiSKFi+IRaRkIb3mNzgIfrq4afhyIHaQfa2HOfsi6Ws+9YobkdDgdq7W70bEdVfiCSU9+JOIY449nxZzfg2Zw=", "DD72C212-26C7-4B38-A5FC-88550896B170", "192.168.1.101", 80);
|
||||
//clientId唯一代表一个设备,只能有一个登录。如果使用同一个clientId登录多次,会出现不可预料问题。
|
||||
IMClient client = new IMClient("KNK_K_00", "6I7UTfKSQT7VhsUJfU6UCvDeCyblLfcXPfajAFxgFGOcqvfFVQCvYy8A5vfAGUj2LSYgoM5W02MHh6jtG/otQs6ft8zLT4Efz315UlDLfrz+OSQYfwAuGFw9m0/x4ckrgiooprsKFxPMaNcCDact0qvp1dBhbeGUipdWVhI33b4=", "5B6DEB72-8A3D-45E2-A88A-47DC4E692B00", "192.168.0.193", 80);
|
||||
|
||||
client.setReceiveMessageCallback(new ReceiveMessageCallback() {
|
||||
@Override
|
||||
public void onReceiveMessages(List<WFCMessage.Message> messageList, boolean hasMore) {
|
||||
|
||||
System.out.println("recieved messages");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRecallMessage(long messageUid) {
|
||||
|
||||
System.out.println("recalled messages");
|
||||
}
|
||||
});
|
||||
|
||||
client.setConnectionStatusCallback((ConnectionStatus newStatus) -> {
|
||||
if (newStatus == ConnectionStatus_Connected) {
|
||||
WFCMessage.Conversation conversation = WFCMessage.Conversation.newBuilder().setType(0).setTarget("yzyOyOKK").setLine(0).build();
|
||||
WFCMessage.Conversation conversation = WFCMessage.Conversation.newBuilder().setType(0).setTarget("IMININnn").setLine(0).build();
|
||||
WFCMessage.MessageContent messageContent = WFCMessage.MessageContent.newBuilder().setSearchableContent("helloworld").setType(1).build();
|
||||
client.sendMessage(conversation, messageContent, new SendMessageCallback() {
|
||||
@Override
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.wildfirechat.pojos;
|
||||
package com.xiaoleilu.loServer.pojos;
|
||||
|
||||
|
||||
public class InputRoute {
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.22</version>
|
||||
<version>0.24</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -22,13 +22,13 @@ public class GroupNotificationBinaryContent {
|
||||
//operator
|
||||
private String o;
|
||||
|
||||
//name
|
||||
//value1(name or something)
|
||||
private String n;
|
||||
|
||||
//members
|
||||
private List<String> ms;
|
||||
|
||||
//members
|
||||
//value2(member or something)
|
||||
private String m;
|
||||
|
||||
public GroupNotificationBinaryContent(String g, String o, String n, String m) {
|
||||
@@ -124,4 +124,27 @@ public class GroupNotificationBinaryContent {
|
||||
public WFCMessage.MessageContent getModifyGroupMemberAliasNotifyContent() {
|
||||
return getGroupNotifyContent(ProtoConstants.MESSAGE_CONTENT_TYPE_MODIFY_GROUP_ALIAS);
|
||||
}
|
||||
|
||||
public WFCMessage.MessageContent getChangeGroupMuteNotifyContent() {
|
||||
return getGroupNotifyContent(ProtoConstants.MESSAGE_CONTENT_TYPE_CHANGE_MUTE);
|
||||
}
|
||||
|
||||
public WFCMessage.MessageContent getChangeGroupJointypeNotifyContent() {
|
||||
return getGroupNotifyContent(ProtoConstants.MESSAGE_CONTENT_TYPE_CHANGE_JOINTYPE);
|
||||
}
|
||||
|
||||
public WFCMessage.MessageContent getChangeGroupPrivatechatNotifyContent() {
|
||||
return getGroupNotifyContent(ProtoConstants.MESSAGE_CONTENT_TYPE_CHANGE_PRIVATECHAT);
|
||||
}
|
||||
|
||||
public WFCMessage.MessageContent getChangeGroupSearchableNotifyContent() {
|
||||
return getGroupNotifyContent(ProtoConstants.MESSAGE_CONTENT_TYPE_CHANGE_SEARCHABLE);
|
||||
}
|
||||
|
||||
public WFCMessage.MessageContent getSetGroupManagerNotifyContent() {
|
||||
return getGroupNotifyContent(ProtoConstants.MESSAGE_CONTENT_TYPE_SET_MANAGER);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ public enum ErrorCode {
|
||||
|
||||
ERROR_CODE_NOT_IN_CHANNEL(21, "not in channel"),
|
||||
|
||||
ERROR_CODE_GROUP_MUTED(241, "group is muted"),
|
||||
ERROR_CODE_SENSITIVE_MATCHED(242, "sensitive matched"),
|
||||
ERROR_CODE_SIGN_EXPIRED(243, "sign expired"),
|
||||
ERROR_CODE_AUTH_FAILURE(244, "auth failure"),
|
||||
|
||||
@@ -87,6 +87,10 @@ public class ProtoConstants {
|
||||
int Modify_Group_Name = 0;
|
||||
int Modify_Group_Portrait = 1;
|
||||
int Modify_Group_Extra = 2;
|
||||
int Modify_Group_Mute = 3;
|
||||
int Modify_Group_JoinType = 4;
|
||||
int Modify_Group_PrivateChat = 5;
|
||||
int Modify_Group_Searchable = 6;
|
||||
}
|
||||
|
||||
//ModifyGroupInfoRequest -> type
|
||||
@@ -137,5 +141,12 @@ public class ProtoConstants {
|
||||
public static final int MESSAGE_CONTENT_TYPE_CHANGE_GROUP_NAME = 110;
|
||||
public static final int MESSAGE_CONTENT_TYPE_MODIFY_GROUP_ALIAS = 111;
|
||||
public static final int MESSAGE_CONTENT_TYPE_CHANGE_GROUP_PORTRAIT = 112;
|
||||
|
||||
public static final int MESSAGE_CONTENT_TYPE_CHANGE_MUTE = 113;
|
||||
public static final int MESSAGE_CONTENT_TYPE_CHANGE_JOINTYPE = 114;
|
||||
public static final int MESSAGE_CONTENT_TYPE_CHANGE_PRIVATECHAT = 115;
|
||||
public static final int MESSAGE_CONTENT_TYPE_CHANGE_SEARCHABLE = 116;
|
||||
|
||||
public static final int MESSAGE_CONTENT_TYPE_SET_MANAGER = 117;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -6,7 +6,7 @@
|
||||
<!--<relativePath>../pom.xml</relativePath>-->
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.22</version>
|
||||
<version>0.24</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>distribution</artifactId>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<!--MySQL数据库驱动程序-->
|
||||
<property name="driverClass">com.mysql.cj.jdbc.Driver</property>
|
||||
<!--MySQL数据库地址-->
|
||||
<property name="jdbcUrl">jdbc:mysql://localhost:3306/wfchat?useSSL=false&serverTimezone=GMT&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=utf8</property>
|
||||
<property name="jdbcUrl">jdbc:mysql://localhost:3306/wfchat?useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=utf8</property>
|
||||
<!--MySQL数据库用户名-->
|
||||
<property name="user">root</property>
|
||||
<!--MySQL数据库密码-->
|
||||
|
||||
@@ -30,6 +30,8 @@ set JAVA_OPTS=
|
||||
set JAVA_OPTS_SCRIPT=-XX:+HeapDumpOnOutOfMemoryError -Djava.awt.headless=true
|
||||
set WILDFIRECHAT_PATH=%WILDFIRECHAT_HOME%
|
||||
set LOG_FILE=%WILDFIRECHAT_HOME%\config\log4j.properties
|
||||
set HZ_CONF_FILE=%WILDFIRECHAT_HOME%\config\hazelcast.xml
|
||||
set C3P0_CONF_FILE=%WILDFIRECHAT_HOME%\config\c3p0-config.xml
|
||||
|
||||
rem Use the Hotspot garbage-first collector.
|
||||
set JAVA_OPTS=%JAVA_OPTS% -XX:+UseG1GC
|
||||
@@ -71,4 +73,4 @@ rem set JAVA_OPTS=%JAVA_OPTS% -XX:+UseGCLogFileRotation
|
||||
rem set JAVA_OPTS=%JAVA_OPTS% -XX:NumberOfGCLogFiles=10
|
||||
rem set JAVA_OPTS=%JAVA_OPTS% -XX:GCLogFileSize=10M"
|
||||
|
||||
%JAVA% -server %JAVA_OPTS% %JAVA_OPTS_SCRIPT% -Dlog4j.configuration=file:%LOG_FILE% -Dwildfirechat.path=%WILDFIRECHAT_PATH% -cp %WILDFIRECHAT_HOME%\lib\* cn.wildfirechat.server.Server
|
||||
%JAVA% -server %JAVA_OPTS% %JAVA_OPTS_SCRIPT% -Dlog4j.configuration=file:%LOG_FILE% -Dcom.mchange.v2.c3p0.cfg.xml=%C3P0_CONF_FILE% -Dhazelcast.configuration=file:%HZ_CONF_FILE% -Dwildfirechat.path=%WILDFIRECHAT_PATH% -cp %WILDFIRECHAT_HOME%\lib\* cn.wildfirechat.server.Server
|
||||
|
||||
@@ -70,7 +70,7 @@ JAVA_OPTS="$JAVA_OPTS -XX:MaxGCPauseMillis=500"
|
||||
### GC logging options -- uncomment to enable
|
||||
|
||||
JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCDetails"
|
||||
JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCDateStamps"
|
||||
#JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCDateStamps"
|
||||
JAVA_OPTS="$JAVA_OPTS -XX:+PrintHeapAtGC"
|
||||
JAVA_OPTS="$JAVA_OPTS -XX:+PrintTenuringDistribution"
|
||||
JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCApplicationStoppedTime"
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
|
||||
<packaging>pom</packaging>
|
||||
<version>0.22</version>
|
||||
<version>0.24</version>
|
||||
<name>Wildfire Chat</name>
|
||||
<description>Wildfire Chat Server</description>
|
||||
<inceptionYear>2019</inceptionYear>
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.22</version>
|
||||
<version>0.24</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -143,6 +143,26 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
resultVoid =UserAdmin.updateUserBlockStatus(userInfo.getUserId(), 0);
|
||||
if (resultVoid != null && resultVoid.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("block user done");
|
||||
} else {
|
||||
System.out.println("block user failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
resultCheckUserStatus = UserAdmin.checkUserBlockStatus(userInfo.getUserId());
|
||||
if (resultCheckUserStatus != null && resultCheckUserStatus.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
if (resultCheckUserStatus.getResult().getStatus() == 0) {
|
||||
System.out.println("check user status success");
|
||||
} else {
|
||||
System.out.println("user status not correct");
|
||||
System.exit(-1);
|
||||
}
|
||||
} else {
|
||||
System.out.println("block user failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
//***********************************************
|
||||
//**** 群组相关功能
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<relativePath>../</relativePath>
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.22</version>
|
||||
<version>0.24</version>
|
||||
</parent>
|
||||
|
||||
<groupId>net.xmeter</groupId>
|
||||
|
||||
@@ -1,21 +1,16 @@
|
||||
package net.xmeter.samplers;
|
||||
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.google.gson.Gson;
|
||||
import cn.wildfirechat.pojos.InputRoute;
|
||||
import cn.wildfirechat.pojos.InputGetToken;
|
||||
import cn.wildfirechat.pojos.OutputGetIMTokenData;
|
||||
import io.moquette.spi.impl.security.AES;
|
||||
import net.xmeter.IMResult;
|
||||
import net.xmeter.Util;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.jmeter.samplers.AbstractSampler;
|
||||
|
||||
@@ -24,11 +19,9 @@ import org.apache.jorphan.logging.LoggingManager;
|
||||
import org.apache.log.Logger;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Type;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Base64;
|
||||
|
||||
public abstract class AbstractMQTTSampler extends AbstractSampler implements Constants {
|
||||
private transient static Logger logger = LoggingManager.getLoggerForClass();
|
||||
|
||||
Reference in New Issue
Block a user