Compare commits

...
45 Commits
Author SHA1 Message Date
imhao183 6c5354d17b 优化session处理 2019-12-18 11:37:39 +08:00
imhao183 c98bd1fb9b update version to 0.36 2019-12-18 10:54:08 +08:00
imhao183 fe525e9483 优化用户session逻辑 2019-12-18 09:02:59 +08:00
imhao183 6acea9b140 创建群时同步操作 2019-12-17 14:39:49 +08:00
imhao183 4beb573052 add ignore 2019-12-17 14:36:49 +08:00
imhao183 220e010193 update version to 0.35 2019-12-13 13:02:27 +08:00
imhao183 865888824c Revert "Fix race condition during SensitiveFilter update"
This reverts commit ab7b20871a.
2019-12-13 12:58:07 +08:00
imhao183 583df110fd Revert "Fix potential GZIPOutputStream resource leak on exception"
This reverts commit 6c7d2ab3ad.
2019-12-13 12:57:59 +08:00
imhao183 f204bd693e Revert "fix build error"
This reverts commit 5cd2e7affe.
2019-12-13 12:57:46 +08:00
x86 b6be1ca045 fix pull message issue 2019-12-10 23:34:15 +08:00
imhao183 beb403a9f7 添加搜索类型 2019-12-06 10:36:26 +08:00
imhao183 00f1187200 添加群主进群时,修改群主的的状态问题 2019-12-05 15:42:20 +08:00
heavyrain.lee 7ee490cc1b update version to 0.34 2019-12-03 13:54:17 +08:00
imhao183 3dc0ae7a47 update 2019-12-03 08:24:15 +08:00
imhao183 994a8b5c4a 添加服务器为客户缓存消息数量的配置 2019-12-03 08:10:38 +08:00
imhao183 5cd2e7affe fix build error 2019-12-02 15:21:04 +08:00
heavyrain.lee f29ffe4cd2 Merge pull request #124 from k81/wildfirechat
Fix race condition during SensitiveFilter update and potential resource leak of GZIPOutputStream on exception
2019-12-02 14:43:55 +08:00
gitlab-runner 6c7d2ab3ad Fix potential GZIPOutputStream resource leak on exception 2019-11-30 23:05:28 +08:00
gitlab-runner ab7b20871a Fix race condition during SensitiveFilter update 2019-11-30 17:27:56 +08:00
imhao183 6883418e22 解决okhttp内存泄漏问题 2019-11-30 14:25:41 +08:00
fengyun 32f7266a5f add deleted property 2019-11-30 13:11:25 +08:00
fengyun 35db76e9cd set use deleted 2019-11-30 13:11:18 +08:00
heavyrain.lee 4f6aa87b9f update proto 2019-11-30 13:10:53 +08:00
fengyun f5816e20dd add get user group list and destroy user function 2019-11-30 11:46:52 +08:00
heavyrain2012 e72ae59e49 update version to 0.33 2019-11-28 17:33:35 +08:00
heavyrain2012 f0c2fd82ca 调整部分文件包名 2019-11-28 14:20:34 +08:00
heavyrain2012 5a588c8268 update 2019-11-27 12:57:07 +08:00
heavyrain2012 2adc030d6f 修改日志缺陷 2019-11-27 11:09:07 +08:00
heavyrain2012 b0ca8ed2b7 update 2019-11-27 10:39:32 +08:00
heavyrain2012 f9d5c861ce 优化用户session 2019-11-27 10:30:39 +08:00
heavyrain2012 9aaaa71ce9 清除掉重复token 2019-11-26 14:44:25 +08:00
heavyrain2012 73a971bde3 同步已读设置时,如果是排除掉已经解散的群组和销毁的频道 2019-11-25 18:50:00 +08:00
heavyrain2012 5942eb7b15 update version to 0.32 2019-11-25 12:12:06 +08:00
heavyrain2012 b97fea1841 添加索引 2019-11-25 11:22:36 +08:00
heavyrain2012 33637229d6 限制多端登陆 2019-11-25 11:19:53 +08:00
heavyrain2012 af366fcdb2 update proto 2019-11-25 11:19:44 +08:00
heavyrain2012 c9089c5d51 性能优化 2019-11-25 11:18:44 +08:00
imndx 3afc6a2da9 update readme 2019-11-24 20:37:45 +08:00
heavyrain2012 12d22e78bf 根据devicetoken进行排重 2019-11-21 20:51:52 +08:00
heavyrain2012 bcf969e56f 兼容旧客户端 2019-11-21 12:20:53 +08:00
heavyrain2012 b3a95c0310 update 2019-11-21 10:24:16 +08:00
heavyrain2012 ae863ab6e4 update version 2019-11-21 10:12:19 +08:00
heavyrain2012 688ca4e31d 黑名单功能 2019-11-21 09:36:41 +08:00
heavyrain2012 724b6dddd6 消息推送显示详情配置错误 2019-11-21 08:08:20 +08:00
heavyrain.lee bf3b30eb2c remove invalid message 2019-11-18 21:51:33 +08:00
104 changed files with 1526 additions and 341 deletions
+3
View File
@@ -56,3 +56,6 @@ broker/media
common/target
server/target
sdk/target
moments/target
monitor
wildfire_jmeter
+12 -10
View File
@@ -2,16 +2,18 @@
野火IM是一套跨平台、核心功能开源的即时通讯解决方案,主要包含以下内容。
| 仓库 | 说明 | 备注 |
| ------------------------------------------------------------ | ------------------------------------------------------- | ---------------------------------------------- |
| [android-chat](https://github.com/wildfirechat/android-chat) | 野火IM Android SDK源码和App源码 | 可以很方便地进行二次开发,或集成到现有应用当中 |
| [ios-chat](https://github.com/wildfirechat/ios-chat) | 野火IM iOS SDK源码和App源码 | 可以很方便地进行二次开发,或集成到现有应用当中 |
| [pc-chat](https://github.com/wildfirechat/pc-chat) | 基于[Electron](https://electronjs.org/)开发的PC平台应用 | |
| [server](https://github.com/wildfirechat/server) | IM server | |
| [app server](https://github.com/wildfirechat/app_server) | 应用服务端 | |
| [robot_server](https://github.com/wildfirechat/robot_server) | 机器人服务端 | |
| [push_server](https://github.com/wildfirechat/push_server) | 推送服务器 | |
| [docs](https://github.com/wildfirechat/docs) | 野火IM相关文档,包含设计、概念、开发、使用说明 | |
| 仓库 | 说明 | 备注 |
| ------------------------------------------------------------ | ------------------------------------------------------- | ---- |
| [android-chat](https://github.com/wildfirechat/android-chat) | 野火IM Android SDK源码和App源码 |可以很方便地进行二次开发,或集成到现有应用当中 |
| [ios-chat](https://github.com/wildfirechat/ios-chat) | 野火IM iOS SDK源码和App源码 |可以很方便地进行二次开发,或集成到现有应用当中 |
| [pc-chat](https://github.com/wildfirechat/pc-chat) | 基于[Electron](https://electronjs.org/)开发的PC平台应用 | |
| [web-chat](https://github.com/wildfirechat/web-chat) | Web平台的Demo, [体验地址](http://web.wildfirechat.cn) | |
| [wx-chat](https://github.com/wildfirechat/wx-chat) | 微信小程序平台的Demo | |
| [server](https://github.com/wildfirechat/server) | IM server | |
| [app server](https://github.com/wildfirechat/app_server) | 应用服务端 | |
| [robot_server](https://github.com/wildfirechat/robot_server) | 机器人服务端 | |
| [push_server](https://github.com/wildfirechat/push_server) | 推送服务器 | |
| [docs](https://github.com/wildfirechat/docs) | 野火IM相关文档,包含设计、概念、开发、使用说明 | | | |
# server
本工程为野火IM 社区版IM服务软件。野火IM作为一个通用的即时通讯解决方案,可以集成到各种应用中。请阅读[docs](http://docs.wildfirechat.cn)或下载服务器[发布版本](https://github.com/wildfirechat/server/releases)
+6
View File
@@ -58,6 +58,9 @@ message.roaming 0
##是否开启拉取远程历史消息
message.remote_history_message 0
##服务器为每个用户缓存的消息数量。这个值改得太大,拉取消息时间变长,另外会占用大量内存。
message.max_queue 1024
#*********************************************************************
# hazelcase configuration
#*********************************************************************
@@ -102,6 +105,9 @@ qiniu.bucket_favorite_domain http://cdn2.wildfirechat.cn
# 本地媒体服务器配置。
local.media.storage.root media
# 是否支持多端登陆
server.multi_endpoint false
#*********************************************************************
# Push server configuration
#*********************************************************************
+1
View File
@@ -0,0 +1 @@
alter table `t_user_session` ADD INDEX `session_token_index` ( `_token` );
+1
View File
@@ -0,0 +1 @@
alter table t_friend_request add index `friend_request_uid_index` (`_friend_uid`);
+1
View File
@@ -0,0 +1 @@
alter table `t_user_session` ADD INDEX `session_uid_index` ( `_uid` );
+1
View File
@@ -0,0 +1 @@
alter table `t_user_session` add column `_deleted` tinyint DEFAULT 0;
+1
View File
@@ -0,0 +1 @@
alter table `t_user` add column `_deleted` tinyint DEFAULT 0;
@@ -0,0 +1 @@
alter table `t_user_session` ADD INDEX `session_token_index` ( `_token` );
+1
View File
@@ -0,0 +1 @@
alter table t_friend_request add index `friend_request_uid_index` (`_friend_uid`);
+1
View File
@@ -0,0 +1 @@
alter table `t_user_session` ADD INDEX `session_uid_index` ( `_uid` );
+1
View File
@@ -0,0 +1 @@
alter table `t_user_session` add column `_deleted` tinyint DEFAULT 0;
+1
View File
@@ -0,0 +1 @@
alter table `t_user` add column `_deleted` tinyint DEFAULT 0;
+1 -1
View File
@@ -5,7 +5,7 @@
<relativePath>../</relativePath>
<artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId>
<version>0.30</version>
<version>0.36</version>
</parent>
<artifactId>moquette-broker</artifactId>
@@ -57,7 +57,7 @@ public class PushServer {
}
public void pushMessage(PushMessage pushMessage, String deviceId, String pushContent) {
LOG.info("try to delivery push diviceId = {}, pushContent", deviceId, pushContent);
LOG.info("try to delivery push diviceId = {}, pushContent = {}", deviceId, pushContent);
executorService.execute(() ->{
try {
pushMessageInternel(pushMessage, deviceId, pushContent);
@@ -82,7 +82,7 @@ public class RouteAction extends Action {
MemorySessionStore.Session session = sessionsStore.sessionForClientAndUser(uid, cid);
if (session == null) {
ErrorCode errorCode = sessionsStore.createNewSession(uid, cid, true, true);
ErrorCode errorCode = sessionsStore.loadActiveSession(uid, cid);
if (errorCode != ErrorCode.ERROR_CODE_SUCCESS) {
sendResponse(response, errorCode, null, base64Response);
return true;
@@ -0,0 +1,97 @@
/*
* 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 com.xiaoleilu.loServer.action.admin;
import cn.wildfirechat.common.APIPath;
import cn.wildfirechat.common.ErrorCode;
import cn.wildfirechat.pojos.InputDestroyUser;
import cn.wildfirechat.pojos.InputOutputUserInfo;
import cn.wildfirechat.pojos.OutputCreateUser;
import cn.wildfirechat.pojos.OutputGetIMTokenData;
import cn.wildfirechat.proto.WFCMessage;
import com.google.gson.Gson;
import com.xiaoleilu.loServer.RestResult;
import com.xiaoleilu.loServer.annotation.HttpMethod;
import com.xiaoleilu.loServer.annotation.Route;
import com.xiaoleilu.loServer.handler.Request;
import com.xiaoleilu.loServer.handler.Response;
import io.moquette.persistence.RPCCenter;
import io.moquette.persistence.TargetEntry;
import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.handler.codec.http.HttpResponseStatus;
import io.netty.util.internal.StringUtil;
import win.liyufan.im.IMTopic;
import win.liyufan.im.UUIDGenerator;
import java.util.Base64;
import java.util.concurrent.Executor;
@Route(APIPath.Destroy_User)
@HttpMethod("POST")
public class DestroyUserAction extends AdminAction {
@Override
public boolean isTransactionAction() {
return true;
}
@Override
public boolean action(Request request, Response response) {
if (request.getNettyRequest() instanceof FullHttpRequest) {
InputDestroyUser inputDestroyUser = getRequestBody(request.getNettyRequest(), InputDestroyUser.class);
if (inputDestroyUser != null
&& !StringUtil.isNullOrEmpty(inputDestroyUser.getUserId())) {
WFCMessage.IDBuf idBuf = WFCMessage.IDBuf.newBuilder().setId(inputDestroyUser.getUserId()).build();
RPCCenter.getInstance().sendRequest(inputDestroyUser.getUserId(), null, IMTopic.DestroyUserTopic, idBuf.toByteArray(), inputDestroyUser.getUserId(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
@Override
public void onSuccess(byte[] result) {
ErrorCode errorCode1 = ErrorCode.fromCode(result[0]);
if (errorCode1 == ErrorCode.ERROR_CODE_SUCCESS) {
//ba errorcode qudiao
byte[] data = new byte[result.length -1];
for (int i = 0; i < data.length; i++) {
data[i] = result[i+1];
}
String token = Base64.getEncoder().encodeToString(data);
sendResponse(response, null, null);
} else {
sendResponse(response, errorCode1, null);
}
}
@Override
public void onError(ErrorCode errorCode) {
sendResponse(response, errorCode, null);
}
@Override
public void onTimeout() {
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
}
@Override
public Executor getResponseExecutor() {
return command -> {
ctx.executor().execute(command);
};
}
}, true);
return false;
} else {
response.setStatus(HttpResponseStatus.OK);
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
response.setContent(new Gson().toJson(result));
}
}
return true;
}
}
@@ -41,7 +41,7 @@ public class GetIMTokenAction extends AdminAction {
String userId = input.getUserId();
WFCMessage.GetTokenRequest getTokenRequest = WFCMessage.GetTokenRequest.newBuilder().setUserId(userId).setClientId(input.getClientId()).build();
WFCMessage.GetTokenRequest getTokenRequest = WFCMessage.GetTokenRequest.newBuilder().setUserId(userId).setClientId(input.getClientId()).setPlatform(input.getPlatform() == null ? 0 : input.getPlatform()).build();
RPCCenter.getInstance().sendRequest(userId, input.getClientId(), IMTopic.GetTokenTopic, getTokenRequest.toByteArray(), userId, TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
@Override
public void onSuccess(byte[] result) {
@@ -0,0 +1,63 @@
/*
* 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 com.xiaoleilu.loServer.action.admin;
import cn.wildfirechat.common.APIPath;
import cn.wildfirechat.common.ErrorCode;
import cn.wildfirechat.pojos.InputGetGroup;
import cn.wildfirechat.pojos.InputUserId;
import cn.wildfirechat.pojos.OutputGroupIds;
import cn.wildfirechat.pojos.PojoGroupInfo;
import cn.wildfirechat.proto.WFCMessage;
import com.google.gson.Gson;
import com.xiaoleilu.loServer.RestResult;
import com.xiaoleilu.loServer.annotation.HttpMethod;
import com.xiaoleilu.loServer.annotation.Route;
import com.xiaoleilu.loServer.handler.Request;
import com.xiaoleilu.loServer.handler.Response;
import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.handler.codec.http.HttpResponseStatus;
import io.netty.util.internal.StringUtil;
import java.util.ArrayList;
import java.util.Set;
@Route(APIPath.Get_User_Groups)
@HttpMethod("POST")
public class GetUserGroupsAction extends AdminAction {
@Override
public boolean isTransactionAction() {
return true;
}
@Override
public boolean action(Request request, Response response) {
if (request.getNettyRequest() instanceof FullHttpRequest) {
InputUserId inputUserId = getRequestBody(request.getNettyRequest(), InputUserId.class);
if (inputUserId != null
&& (!StringUtil.isNullOrEmpty(inputUserId.getUserId()))) {
Set<String> groupIds = messagesStore.getUserGroupIds(inputUserId.getUserId());
response.setStatus(HttpResponseStatus.OK);
OutputGroupIds outputGroupIds = new OutputGroupIds();
outputGroupIds.setGroupIds(new ArrayList<>(groupIds));
RestResult result = RestResult.ok(outputGroupIds);
response.setContent(new Gson().toJson(result));
} else {
response.setStatus(HttpResponseStatus.OK);
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
response.setContent(new Gson().toJson(result));
}
}
return true;
}
}
@@ -106,6 +106,8 @@ public final class BrokerConstants {
public static final String MESSAGE_Forward_Url = "message.forward.url";
public static final String SERVER_MULTI_ENDPOINT = "server.multi_endpoint";
public static final String MONGODB_Client_URI = "mongodb.client_uri";
public static final String MONGODB_Database = "mongodb.database";
public static final String MONGODB_Data_Expire_Days = "mongodb.data_expire_days";
@@ -113,6 +115,9 @@ public final class BrokerConstants {
public static final String MESSAGE_ROAMING = "message.roaming";
public static final String MESSAGE_Remote_History_Message = "message.remote_history_message";
public static final String MESSAGE_Max_Queue = "message.max_queue";
private BrokerConstants() {
}
@@ -0,0 +1,38 @@
/*
* 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.proto.WFCMessage;
import io.moquette.persistence.MemorySessionStore;
import io.moquette.spi.impl.Qos1PublishHandler;
import io.moquette.spi.impl.security.TokenAuthenticator;
import io.netty.buffer.ByteBuf;
import win.liyufan.im.IMTopic;
@Handler(IMTopic.DestroyUserTopic)
public class DestroyUserHandler extends IMHandler<WFCMessage.IDBuf> {
@Override
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.IDBuf request, Qos1PublishHandler.IMCallback callback) {
if (isAdmin) {
mServer.getImBusinessScheduler().execute(()-> {
m_sessionsStore.clearUserSession(fromUser);
m_messagesStore.clearUserMessages(fromUser);
m_messagesStore.clearUserSettings(fromUser);
m_messagesStore.clearUserFriend(fromUser);
m_messagesStore.clearUserGroups(fromUser);
m_messagesStore.clearUserChannels(fromUser);
m_messagesStore.destoryUser(fromUser);
});
return ErrorCode.ERROR_CODE_SUCCESS;
} else {
return ErrorCode.ERROR_CODE_NOT_RIGHT;
}
}
}
@@ -26,7 +26,7 @@ public class FriendPullHandler extends IMHandler<WFCMessage.Version> {
WFCMessage.GetFriendsResult.Builder builder = WFCMessage.GetFriendsResult.newBuilder();
for (FriendData data : friendDatas
) {
WFCMessage.Friend.Builder builder1 = WFCMessage.Friend.newBuilder().setState(data.getState()).setUid(data.getFriendUid()).setUpdateDt(data.getTimestamp());
WFCMessage.Friend.Builder builder1 = WFCMessage.Friend.newBuilder().setState(data.getState()).setBlacked(data.getBlacked()).setUid(data.getFriendUid()).setUpdateDt(data.getTimestamp());
if (!StringUtil.isNullOrEmpty(data.getAlias())) {
builder1.setAlias(data.getAlias());
}
@@ -20,7 +20,7 @@ import win.liyufan.im.IMTopic;
public class GetTokenHandler extends IMHandler<WFCMessage.GetTokenRequest> {
@Override
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.GetTokenRequest request, Qos1PublishHandler.IMCallback callback) {
MemorySessionStore.Session session = m_sessionsStore.createUserSession(fromUser, clientID);
MemorySessionStore.Session session = m_sessionsStore.updateOrCreateUserSession(fromUser, clientID, request.getPlatform());
TokenAuthenticator authenticator = new TokenAuthenticator();
String strToken = authenticator.generateToken(fromUser);
String result = strToken + "|" + session.getSecret() + "|" + session.getDbSecret();
@@ -83,11 +83,10 @@ abstract public class IMHandler<T> {
}
}
for (Method method : getClass().getDeclaredMethods()
) {
if (method.getName() == actionName && method.getParameterCount() == 6) {
if (method.getName() == actionName && method.getParameterCount() == 6 && !method.getParameterTypes()[4].equals(Object.class)) {
dataCls = method.getParameterTypes()[4];
break;
}
@@ -240,7 +239,7 @@ abstract public class IMHandler<T> {
WFCMessage.Message.Builder messageBuilder = message.toBuilder();
int pullType = m_messagesStore.getNotifyReceivers(username, messageBuilder, notifyReceivers);
this.publisher.publish2Receivers(messageBuilder.build(), notifyReceivers, clientID, pullType);
mServer.getImBusinessScheduler().execute(() -> this.publisher.publish2Receivers(messageBuilder.build(), notifyReceivers, clientID, pullType));
return notifyReceivers.size();
}
@@ -250,7 +249,7 @@ abstract public class IMHandler<T> {
message = m_messagesStore.storeMessage(username, clientID, message);
WFCMessage.Message.Builder messageBuilder = message.toBuilder();
int pullType = m_messagesStore.getNotifyReceivers(username, messageBuilder, notifyReceivers);
this.publisher.publish2Receivers(messageBuilder.build(), notifyReceivers, clientID, pullType);
mServer.getImBusinessScheduler().execute(() -> this.publisher.publish2Receivers(messageBuilder.build(), notifyReceivers, clientID, pullType));
return notifyReceivers.size();
}
@@ -32,7 +32,7 @@ public class RouteHandler extends IMHandler<WFCMessage.RouteRequest> {
ClientSession clientSession = m_sessionsStore.sessionForClient(clientID);
boolean isSessionAlreadyStored = clientSession != null;
if (!isSessionAlreadyStored) {
m_sessionsStore.createNewSession(fromUser, clientID, true, true);
m_sessionsStore.loadActiveSession(fromUser, clientID);
} else {
m_sessionsStore.updateExistSession(fromUser, clientID, request, true);
}
@@ -26,12 +26,12 @@ 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,肯定是生产环境的推送
m_sessionsStore.updateSessionToken(session, true);
} else {
session.setDeviceToken(request.getDeviceToken());
session.setPushType(request.getPushType());
m_sessionsStore.updateSessionToken(session, false);
m_sessionsStore.cleanDuplatedToken(session.getClientID(), session.getPushType(), session.getDeviceToken(), false);
}
return ErrorCode.ERROR_CODE_SUCCESS;
@@ -20,7 +20,7 @@ import java.util.List;
public class UserSearchHandler extends IMHandler<WFCMessage.SearchUserRequest> {
@Override
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.SearchUserRequest request, Qos1PublishHandler.IMCallback callback) {
List<WFCMessage.User> users = m_messagesStore.searchUser(request.getKeyword(), request.getFuzzy() > 0, request.getPage());
List<WFCMessage.User> users = m_messagesStore.searchUser(request.getKeyword(), request.getFuzzy(), request.getPage());
WFCMessage.SearchUserResult.Builder builder = WFCMessage.SearchUserResult.newBuilder();
builder.addAllEntry(users);
byte[] data = builder.build().toByteArray();
@@ -16,6 +16,7 @@ import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.MultiMap;
import com.hazelcast.util.StringUtil;
import com.xiaoleilu.loServer.model.FriendData;
import io.moquette.server.Server;
import io.moquette.spi.ClientSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,9 +31,11 @@ import java.sql.*;
import java.util.*;
import java.util.function.Function;
import static cn.wildfirechat.proto.ProtoConstants.PersistFlag.Transparent;
import static io.moquette.persistence.MemoryMessagesStore.USER_STATUS;
import static io.moquette.server.Constants.MAX_MESSAGE_QUEUE;
import static cn.wildfirechat.proto.ProtoConstants.SearchUserType.*;
public class DatabaseStore {
private static final Logger LOG = LoggerFactory.getLogger(DatabaseStore.class);
@@ -146,8 +149,12 @@ public class DatabaseStore {
}
return null;
}
List<WFCMessage.User> searchUserFromDB(String keyword, boolean buzzy, int page) {
//searchType
// 0 模糊匹配displayName, 精确匹配账户名和电话号码
// 1 精确匹配账户名和电话号码
// 2 精确匹配账户名
// 3 精确匹配电话号码
List<WFCMessage.User> searchUserFromDB(String keyword, int searchType, int page) {
Connection connection = null;
PreparedStatement statement = null;
ResultSet rs = null;
@@ -167,18 +174,29 @@ public class DatabaseStore {
", `_social`" +
", `_extra`" +
", `_dt` from t_user";
if (buzzy) {
sql += " where (`_display_name` like ? or `_name` = ? or `_mobile` = ?) ";
} else {
sql += " where (`_name` = ? or `_mobile` = ?) ";
switch (searchType) {
case SearchUserType_Name_Mobile:
sql += " where (`_name` = ? or `_mobile` = ?) ";
break;
case SearchUserType_Name:
sql += " where `_name` = ? ";
break;
case SearchUserType_Mobile:
sql += " where `_mobile` = ? ";
break;
case SearchUserType_General:
default:
sql += " where (`_display_name` like ? or `_name` = ? or `_mobile` = ?) ";
break;
}
sql += " and _type <> 2"; //can search normal user(0) and robot(1), can not search things
if (buzzy) {
sql += " limit 20";
} else {
if (searchType == SearchUserType_Name_Mobile || searchType == SearchUserType_Name || searchType == SearchUserType_Mobile) {
sql += " limit 1";
} else {
sql += " limit 20";
}
if (page > 0) {
@@ -188,12 +206,24 @@ public class DatabaseStore {
statement = connection.prepareStatement(sql);
int index = 1;
if (buzzy) {
statement.setString(index++, "%" + keyword + "%");
switch (searchType) {
case SearchUserType_Name_Mobile:
statement.setString(index++, keyword);
statement.setString(index++, keyword);
break;
case SearchUserType_Name:
case SearchUserType_Mobile:
statement.setString(index++, keyword);
break;
case SearchUserType_General:
default:
statement.setString(index++, "%" + keyword + "%");
statement.setString(index++, keyword);
statement.setString(index++, keyword);
break;
}
statement.setString(index++, keyword);
statement.setString(index++, keyword);
rs = statement.executeQuery();
while (rs.next()) {
@@ -638,11 +668,12 @@ public class DatabaseStore {
String sql = "select `_from`, `_type`, `_target`, `_line`, `_data`, `_dt` from " + MessageShardingUtil.getMessageTable(messageId) +" where _mid = ? limit 1";
Connection connection = null;
PreparedStatement statement = null;
ResultSet resultSet = null;
try {
connection = DBUtil.getConnection();
statement = connection.prepareStatement(sql);
statement.setLong(1, messageId);
ResultSet resultSet = statement.executeQuery();
resultSet = statement.executeQuery();
if (resultSet.next()) {
WFCMessage.Message.Builder builder = WFCMessage.Message.newBuilder();
builder.setMessageId(messageId);
@@ -661,12 +692,11 @@ public class DatabaseStore {
WFCMessage.Message message = builder.build();
return new MessageBundle(messageId, message.getFromUser(), null, message);
}
resultSet.close();
} catch (SQLException | IOException e) {
e.printStackTrace();
Utility.printExecption(LOG, e);
} finally {
DBUtil.closeDB(connection, statement);
DBUtil.closeDB(connection, statement, resultSet);
}
return null;
}
@@ -786,6 +816,40 @@ public class DatabaseStore {
});
}
void clearUserMessage(final String userId) {
mScheduler.execute(()->{
String tableName = getUserMessageTable(userId);
Connection connection = null;
PreparedStatement statement = null;
try {
connection = DBUtil.getConnection();
String sql = "delete from " + tableName + " where _uid = ?";
statement = connection.prepareStatement(sql);
statement.setString(1, userId);
int count = statement.executeUpdate();
LOG.info("Update rows {}", count);
try {
if (statement!=null) {
statement.close();
}
statement = null;
} catch (SQLException e) {
e.printStackTrace();
Utility.printExecption(LOG, e);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Utility.printExecption(LOG, e);
} finally {
DBUtil.closeDB(connection, statement);
}
});
}
void removeFavGroup(final String groupId, final List<String> memberIds) {
Connection connection = null;
PreparedStatement statement = null;
@@ -861,6 +925,31 @@ public class DatabaseStore {
});
}
void clearUserSetting(final String userId) {
mScheduler.execute(()->{
Connection connection = null;
PreparedStatement statement = null;
try {
connection = DBUtil.getConnection();
String sql = "delete from t_user_setting where `_uid` = ?";
statement = connection.prepareStatement(sql);
int index = 1;
statement.setString(index++, 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);
}
});
}
List<WFCMessage.UserSettingEntry> getPersistUserSetting(final String userId) {
Connection connection = null;
PreparedStatement statement = null;
@@ -950,90 +1039,154 @@ public class DatabaseStore {
}
void persistGroupInfo(final WFCMessage.GroupInfo groupInfo) {
mScheduler.execute(()->{
Connection connection = null;
PreparedStatement statement = null;
try {
connection = DBUtil.getConnection();
String sql = "insert into t_group (`_gid`" +
", `_name`" +
", `_portrait`" +
", `_owner`" +
", `_type`" +
", `_extra`" +
", `_dt`" +
", `_member_count`" +
", `_mute`" +
", `_join_type`" +
", `_private_chat`" +
", `_searchable`" +
", `_member_dt`) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" +
" ON DUPLICATE KEY UPDATE " +
"`_name` = ?," +
"`_portrait` = ?," +
"`_owner` = ?," +
"`_type` = ?," +
"`_extra` = ?," +
"`_dt` = ?," +
"`_member_count` = ?," +
"`_mute` = ?" +
", `_join_type` = ?" +
", `_private_chat` = ?" +
", `_searchable` = ?, " +
"`_member_dt` = ?";
Connection connection = null;
PreparedStatement statement = null;
try {
connection = DBUtil.getConnection();
String sql = "insert into t_group (`_gid`" +
", `_name`" +
", `_portrait`" +
", `_owner`" +
", `_type`" +
", `_extra`" +
", `_dt`" +
", `_member_count`" +
", `_mute`" +
", `_join_type`" +
", `_private_chat`" +
", `_searchable`" +
", `_member_dt`) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" +
" ON DUPLICATE KEY UPDATE " +
"`_name` = ?," +
"`_portrait` = ?," +
"`_owner` = ?," +
"`_type` = ?," +
"`_extra` = ?," +
"`_dt` = ?," +
"`_member_count` = ?," +
"`_mute` = ?" +
", `_join_type` = ?" +
", `_private_chat` = ?" +
", `_searchable` = ?, " +
"`_member_dt` = ?";
statement = connection.prepareStatement(sql);
statement = connection.prepareStatement(sql);
int index = 1;
statement.setString(index++, groupInfo.getTargetId());
statement.setString(index++, groupInfo.getName());
statement.setString(index++, groupInfo.getPortrait());
statement.setString(index++, groupInfo.getOwner());
statement.setInt(index++, groupInfo.getType());
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());
statement.setString(index++, groupInfo.getPortrait());
statement.setString(index++, groupInfo.getOwner());
statement.setInt(index++, groupInfo.getType());
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);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Utility.printExecption(LOG, e);
} finally {
DBUtil.closeDB(connection, statement);
}
}
List<MemorySessionStore.Session> getUserActivedSessions(String uid) {
String sql = "select `_cid`, `_package_name`,`_token`,`_voip_token`,`_secret`,`_db_secret`,`_platform`,`_push_type`,`_device_name`,`_device_version`,`_phone_name`,`_language`,`_carrier_name`, `_dt` from t_user_session where `_uid` = ? and `_deleted` = 0";
Connection connection = null;
PreparedStatement statement = null;
List<MemorySessionStore.Session> result = new ArrayList<>();
ResultSet resultSet = null;
try {
connection = DBUtil.getConnection();
statement = connection.prepareStatement(sql);
statement.setString(1, uid);
resultSet = statement.executeQuery();
while (resultSet.next()) {
int index = 1;
statement.setString(index++, groupInfo.getTargetId());
statement.setString(index++, groupInfo.getName());
statement.setString(index++, groupInfo.getPortrait());
statement.setString(index++, groupInfo.getOwner());
statement.setInt(index++, groupInfo.getType());
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());
String cid = resultSet.getString(index++);
statement.setString(index++, groupInfo.getName());
statement.setString(index++, groupInfo.getPortrait());
statement.setString(index++, groupInfo.getOwner());
statement.setInt(index++, groupInfo.getType());
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);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Utility.printExecption(LOG, e);
} finally {
DBUtil.closeDB(connection, statement);
ClientSession clientSession = new ClientSession(cid, Server.getServer().getStore().sessionsStore());
MemorySessionStore.Session session = new MemorySessionStore.Session(uid, cid, clientSession);
session.setAppName(resultSet.getString(index++));
session.setDeviceToken(resultSet.getString(index++));
session.setVoipDeviceToken(resultSet.getString(index++));
session.setSecret(resultSet.getString(index++));
session.setDbSecret(resultSet.getString(index++));
session.setPlatform(resultSet.getInt(index++));
session.setPushType(resultSet.getInt(index++));
session.setDeviceName(resultSet.getString(index++));
session.setDeviceVersion(resultSet.getString(index++));
session.setPhoneName(resultSet.getString(index++));
session.setLanguage(resultSet.getString(index++));
session.setCarrierName(resultSet.getString(index++));
session.setUpdateDt(resultSet.getLong(index++));
result.add(session);
}
});
} catch (SQLException e) {
e.printStackTrace();
Utility.printExecption(LOG, e);
} finally {
DBUtil.closeDB(connection, statement, resultSet);
}
return result;
}
void clearUserSessions(String uid) {
Connection connection = null;
PreparedStatement statement = null;
try {
connection = DBUtil.getConnection();
String sql = "delete from t_user_session where `_uid`=?";
statement = connection.prepareStatement(sql);
int index = 1;
statement.setString(index++, uid);
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);
}
}
MemorySessionStore.Session getSession(String uid, String clientId, ClientSession clientSession) {
String sql = "select `_package_name`,`_token`,`_voip_token`,`_secret`,`_db_secret`,`_platform`,`_push_type`,`_device_name`,`_device_version`,`_phone_name`,`_language`,`_carrier_name`, `_dt` from t_user_session where `_uid` = ? and `_cid` = ? limit 1";
String sql = "select `_package_name`,`_token`,`_voip_token`,`_secret`,`_db_secret`,`_platform`,`_push_type`,`_device_name`,`_device_version`,`_phone_name`,`_language`,`_carrier_name`, `_dt`, `_deleted` from t_user_session where `_uid` = ? and `_cid` = ? limit 1";
Connection connection = null;
PreparedStatement statement = null;
ResultSet resultSet = null;
try {
connection = DBUtil.getConnection();
statement = connection.prepareStatement(sql);
statement.setString(1, uid);
statement.setString(2, clientId);
ResultSet resultSet = statement.executeQuery();
resultSet = statement.executeQuery();
if (resultSet.next()) {
MemorySessionStore.Session session = new MemorySessionStore.Session(uid, clientId, clientSession);
@@ -1051,23 +1204,58 @@ public class DatabaseStore {
session.setPhoneName(resultSet.getString(index++));
session.setLanguage(resultSet.getString(index++));
session.setCarrierName(resultSet.getString(index++));
session.setUpdateDt(resultSet.getLong(index));
session.setUpdateDt(resultSet.getLong(index++));
session.setDeleted(resultSet.getInt(index));
return session;
}
resultSet.close();
} catch (SQLException e) {
e.printStackTrace();
Utility.printExecption(LOG, e);
} finally {
DBUtil.closeDB(connection, statement, resultSet);
}
return null;
}
void clearOtherSessionToken(String cid, String token, int pushType, boolean voipToken) {
if (voipToken) {
return;
}
Connection connection = null;
PreparedStatement statement = null;
try {
connection = DBUtil.getConnection();
String sql = "update t_user_session set `_token` = ?, `_dt` = ? where `_token` = ? and `_push_type` = ? and `_cid` <> ?";
statement = connection.prepareStatement(sql);
int index = 1;
statement.setString(index++, "");
statement.setLong(index++, System.currentTimeMillis());
statement.setString(index++, token);
statement.setInt(index++, pushType);
statement.setString(index++, cid);
int c = statement.executeUpdate();
LOG.info("Update rows {}", c);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Utility.printExecption(LOG, e);
} finally {
DBUtil.closeDB(connection, statement);
}
return null;
}
void updateSessionToken(String uid, String cid, String token, boolean voipToken) {
void updateSessionToken(String uid, String cid, String token, int pushType, boolean voipToken) {
mScheduler.execute(()->{
Connection connection = null;
PreparedStatement statement = null;
clearOtherSessionToken(cid, token, pushType, voipToken);
try {
connection = DBUtil.getConnection();
@@ -1076,12 +1264,15 @@ public class DatabaseStore {
if (voipToken) {
sql = "update t_user_session set `_voip_token` = ?, `_dt` = ? where `_uid` = ? and `_cid` = ?";
} else {
sql = "update t_user_session set `_token` = ?, `_dt` = ? where `_uid` = ? and `_cid` = ?";
sql = "update t_user_session set `_token` = ?, `_push_type` = ?, `_dt` = ? where `_uid` = ? and `_cid` = ?";
}
statement = connection.prepareStatement(sql);
int index = 1;
statement.setString(index++, token);
if (!voipToken) {
statement.setInt(index++, pushType);
}
statement.setLong(index++, System.currentTimeMillis());
statement.setString(index++, uid);
statement.setString(index++, cid);
@@ -1098,6 +1289,64 @@ public class DatabaseStore {
});
}
void updateSessionDeleted(String uid, String cid, int deleted) {
mScheduler.execute(()->{
Connection connection = null;
PreparedStatement statement = null;
try {
connection = DBUtil.getConnection();
String sql = "update t_user_session set `_deleted` = ? where `_uid` = ? and `_cid` = ?";
statement = connection.prepareStatement(sql);
int index = 1;
statement.setInt(index++, deleted);
statement.setString(index++, uid);
statement.setString(index++, cid);
int c = statement.executeUpdate();
LOG.info("Update rows {}", c);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Utility.printExecption(LOG, e);
} finally {
DBUtil.closeDB(connection, statement);
}
});
}
void updateSessionPlatform(String uid, String cid, int platform) {
mScheduler.execute(()->{
Connection connection = null;
PreparedStatement statement = null;
try {
connection = DBUtil.getConnection();
String sql = "update t_user_session set `_platform` = ? where `_uid` = ? and `_cid` = ?";
statement = connection.prepareStatement(sql);
int index = 1;
statement.setInt(index++, platform);
statement.setString(index++, uid);
statement.setString(index++, cid);
int c = statement.executeUpdate();
LOG.info("Update rows {}", c);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Utility.printExecption(LOG, e);
} finally {
DBUtil.closeDB(connection, statement);
}
});
}
private boolean strEqual(String left, String right) {
if (left == right)
return true;
@@ -1190,23 +1439,71 @@ public class DatabaseStore {
});
}
MemorySessionStore.Session createSession(String uid, String clientId, ClientSession clientSession) {
void clearMultiEndpoint(String uid, String clientId, int platform) {
LOG.info("clearMultiEndpoint {}, {}", uid, clientId);
Connection connection = null;
PreparedStatement statement = null;
try {
connection = DBUtil.getConnection();
String sql;
if (platform == ProtoConstants.Platform.Platform_Windows || platform == ProtoConstants.Platform.Platform_OSX
|| platform == ProtoConstants.Platform.Platform_iOS || platform == ProtoConstants.Platform.Platform_Android) {
sql = "update t_user_session set `_deleted` = ?, `_token` = ?, `_voip_token` = ?, `_dt` = ? where `_uid`=? and (`_platform` = ? or `_platform` = ?) and `_cid` <> ? and `_deleted` = 0";
} else {
sql = "update t_user_session set `_deleted` = ?, `_token` = ?, `_voip_token` = ?, `_dt` = ? where `_uid`=? and `_platform` = ? and `_cid` <> ? and `_deleted` = 0";
}
statement = connection.prepareStatement(sql);
int index = 1;
statement.setInt(index++, 1);
statement.setString(index++, "");
statement.setString(index++, "");
statement.setLong(index++, System.currentTimeMillis());
statement.setString(index++, uid);
if (platform == ProtoConstants.Platform.Platform_Windows || platform == ProtoConstants.Platform.Platform_OSX) {
statement.setInt(index++, ProtoConstants.Platform.Platform_Windows);
statement.setInt(index++, ProtoConstants.Platform.Platform_OSX);
} else if(platform == ProtoConstants.Platform.Platform_iOS || platform == ProtoConstants.Platform.Platform_Android) {
statement.setInt(index++, ProtoConstants.Platform.Platform_iOS);
statement.setInt(index++, ProtoConstants.Platform.Platform_Android);
} else {
statement.setInt(index++, platform);
}
statement.setString(index++, clientId);
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);
}
}
MemorySessionStore.Session createSession(String uid, String clientId, ClientSession clientSession, int platform) {
Connection connection = null;
PreparedStatement statement = null;
LOG.info("Database create session {},{}", uid, clientId);
try {
connection = DBUtil.getConnection();
String sql = "insert into t_user_session (`_uid`,`_cid`,`_secret`,`_db_secret`, `_dt`) values (?,?,?,?,?)";
String sql = "insert into t_user_session (`_uid`,`_cid`,`_platform`,`_secret`,`_db_secret`, `_dt`) values (?,?,?,?,?,?)";
statement = connection.prepareStatement(sql);
int index = 1;
MemorySessionStore.Session session = new MemorySessionStore.Session(uid, clientId, clientSession);
session.setPlatform(platform);
statement.setString(index++, uid);
statement.setString(index++, clientId);
statement.setInt(index++, platform);
session.setSecret(UUID.randomUUID().toString());
@@ -1231,40 +1528,67 @@ public class DatabaseStore {
return null;
}
void updateGroupMemberCountDt(final String groupId, final int count, final long dt) {
mScheduler.execute(()->{
Connection connection = null;
PreparedStatement statement = null;
try {
connection = DBUtil.getConnection();
Set<String> getUserGroupIds(String userId) {
Connection connection = null;
PreparedStatement statement = null;
ResultSet rs = null;
try {
connection = DBUtil.getConnection();
String sql = "select `_gid` from t_group_member where `_mid` = ? and `_type` <> ?";
statement = connection.prepareStatement(sql);
String sql ;
statement.setString(1, userId);
statement.setInt(2, ProtoConstants.GroupMemberType.GroupMemberType_Removed);
if (count >= 0) {
sql = "update t_group set `_member_count` = ?, `_member_dt` = ? , `_dt` = ? where `_gid` = ?";
} else {
sql = "update t_group set `_member_dt` = ?, `_dt` = ? where `_gid` = ?";
}
statement = connection.prepareStatement(sql);
int index = 1;
if (count >=0) {
statement.setInt(index++, count);
}
statement.setLong(index++, dt);
statement.setLong(index++, dt);
statement.setString(index++, groupId);
int c = statement.executeUpdate();
LOG.info("Update rows {}", c);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Utility.printExecption(LOG, e);
} finally {
DBUtil.closeDB(connection, statement);
rs = statement.executeQuery();
Set<String> out = new HashSet<>();
while (rs.next()) {
String uid = rs.getString(1);
out.add(uid);
}
});
return out;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Utility.printExecption(LOG, e);
} finally {
DBUtil.closeDB(connection, statement, rs);
}
return null;
}
void updateGroupMemberCountDt(final String groupId, final int count, final long dt) {
Connection connection = null;
PreparedStatement statement = null;
try {
connection = DBUtil.getConnection();
String sql ;
if (count >= 0) {
sql = "update t_group set `_member_count` = ?, `_member_dt` = ? , `_dt` = ? where `_gid` = ?";
} else {
sql = "update t_group set `_member_dt` = ?, `_dt` = ? where `_gid` = ?";
}
statement = connection.prepareStatement(sql);
int index = 1;
if (count >=0) {
statement.setInt(index++, count);
}
statement.setLong(index++, dt);
statement.setLong(index++, dt);
statement.setString(index++, groupId);
int c = statement.executeUpdate();
LOG.info("Update rows {}", c);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Utility.printExecption(LOG, e);
} finally {
DBUtil.closeDB(connection, statement);
}
}
void persistGroupMember(final String groupId, final List<WFCMessage.GroupMember> memberList) {
@@ -1835,6 +2159,7 @@ public class DatabaseStore {
", `_social`=?" +
", `_extra`=?" +
", `_type`=?" +
", `_deleted`=?" +
", `_dt`=?";
statement = connection.prepareStatement(sql);
@@ -1868,6 +2193,7 @@ public class DatabaseStore {
statement.setString(index++, user.getExtra());
statement.setInt(index++, user.getType());
statement.setInt(index++, user.getDeleted());
statement.setLong(index++, user.getUpdateDt() == 0 ? System.currentTimeMillis() : user.getUpdateDt());
int count = statement.executeUpdate();
@@ -1994,6 +2320,7 @@ public class DatabaseStore {
", `_social`" +
", `_extra`" +
", `_type`" +
", `_deleted`" +
", `_dt` from t_user where `_uid` = ?";
statement = connection.prepareStatement(sql);
@@ -2048,6 +2375,9 @@ public class DatabaseStore {
int type = rs.getInt(index++);
builder.setType(type);
int deleted = rs.getInt(index++);
builder.setDeleted(deleted);
long longValue = rs.getLong(index++);
builder.setUpdateDt(longValue);
@@ -2115,7 +2445,7 @@ public class DatabaseStore {
ResultSet rs = null;
try {
connection = DBUtil.getConnection();
String sql = "select distinct(`_uid`) from t_user_session";
String sql = "select distinct(`_uid`) from t_user_session where `_deleted` = 0";
statement = connection.prepareStatement(sql);
@@ -2173,19 +2503,72 @@ public class DatabaseStore {
return null;
}
void removeUserFriend(String userId) {
Connection connection = null;
PreparedStatement statement = null;
try {
connection = DBUtil.getConnection();
String sql = "update t_friend set `_alias` = '', `_state` = 1, `_blacked` = 0, `_dt` = ? where `_uid` = ? or `_friend_uid` = ?";
statement = connection.prepareStatement(sql);
int index = 1;
statement.setLong(index++, System.currentTimeMillis());
statement.setString(index++, userId);
statement.setString(index++, 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 removeUserFriendRequest(String userId) {
Connection connection = null;
PreparedStatement statement = null;
try {
connection = DBUtil.getConnection();
String sql = "delete from t_friend_request where _uid = ? or _friend_uid = ?";
statement = connection.prepareStatement(sql);
int index = 1;
statement.setString(index++, userId);
statement.setString(index++, 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);
}
}
List<WFCMessage.FriendRequest> getPersistFriendRequests(String userId) {
Connection connection = null;
PreparedStatement statement = null;
ResultSet rs = null;
try {
connection = DBUtil.getConnection();
String sql = "select `_uid`" +
String sql = "select `_uid`" +
", `_friend_uid`" +
", `_reason`" +
", `_status`" +
", `_dt`" +
", `_from_read_status`" +
", `_to_read_status` from t_friend_request where `_uid` = ? or `_friend_uid` = ?";
", `_to_read_status` from t_friend_request where `_uid` = ? UNION ALL " +
"select `_uid`" +
", `_friend_uid`" +
", `_reason`" +
", `_status`" +
", `_dt`" +
", `_from_read_status`" +
", `_to_read_status` from t_friend_request where `_friend_uid` = ?";
statement = connection.prepareStatement(sql);
int index = 1;
@@ -25,6 +25,7 @@ import com.hazelcast.util.StringUtil;
import com.xiaoleilu.loServer.model.FriendData;
import cn.wildfirechat.pojos.InputOutputUserBlockStatus;
import cn.wildfirechat.common.ErrorCode;
import io.moquette.server.Constants;
import io.moquette.server.Server;
import io.moquette.spi.IMatchingCondition;
import io.moquette.spi.IMessagesStore;
@@ -122,6 +123,7 @@ public class MemoryMessagesStore implements IMessagesStore {
this.databaseStore = databaseStore;
IS_MESSAGE_ROAMING = "1".equals(m_Server.getConfig().getProperty(MESSAGE_ROAMING));
IS_MESSAGE_REMOTE_HISTORY_MESSAGE = "1".equals(m_Server.getConfig().getProperty(MESSAGE_Remote_History_Message));
Constants.MAX_MESSAGE_QUEUE = Integer.parseInt(m_Server.getConfig().getProperty(MESSAGE_Max_Queue));
}
@Override
@@ -350,6 +352,9 @@ public class MemoryMessagesStore implements IMessagesStore {
size += bundle.getMessage().getSerializedSize();
if (size >= 512 * 1024) { //3M
if(builder.getMessageCount() == 0){
builder.addMessage(bundle.getMessage());
}
break;
}
builder.addMessage(bundle.getMessage());
@@ -684,7 +689,11 @@ public class MemoryMessagesStore implements IMessagesStore {
List<WFCMessage.GroupMember> tmp = new ArrayList<>();
ArrayList<String> newInviteUsers = new ArrayList<>();
for (WFCMessage.GroupMember member : memberList) {
member = member.toBuilder().setType(ProtoConstants.GroupMemberType.GroupMemberType_Normal).setUpdateDt(updateDt).setAlias("").build();
if (member.getMemberId().equals(groupInfo.getOwner())) {
member = member.toBuilder().setType(GroupMemberType_Owner).setUpdateDt(updateDt).setAlias("").build();
} else {
member = member.toBuilder().setType(GroupMemberType_Normal).setUpdateDt(updateDt).setAlias("").build();
}
tmp.add(member);
newInviteUsers.add(member.getMemberId());
}
@@ -772,7 +781,31 @@ public class MemoryMessagesStore implements IMessagesStore {
}
if (groupInfo.getType() != ProtoConstants.GroupType.GroupType_Free && groupInfo.getOwner() != null && groupInfo.getOwner().equals(operator)) {
return ErrorCode.ERROR_CODE_NOT_RIGHT;
MultiMap<String, WFCMessage.GroupMember> groupMembers = hzInstance.getMultiMap(GROUP_MEMBERS);
Collection<WFCMessage.GroupMember> members = groupMembers.get(groupId);
if (members == null || members.size() == 0) {
members = loadGroupMemberFromDB(hzInstance, groupId);
}
WFCMessage.GroupMember newOwner = null;
for (WFCMessage.GroupMember member :members) {
if (!member.getMemberId().equals(operator) && member.getType() != GroupMemberType_Removed) {
newOwner = member;
break;
}
}
if (newOwner == null) {
return dismissGroup(operator, groupId, false);
}
transferGroup(operator, groupId, newOwner.getMemberId(), false);
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
removeGroupMember(groupId, Arrays.asList(operator));
@@ -781,6 +814,18 @@ public class MemoryMessagesStore implements IMessagesStore {
return ErrorCode.ERROR_CODE_SUCCESS;
}
@Override
public void clearUserGroups(String userId) {
Set<String> groupIds = databaseStore.getUserGroupIds(userId);
int[] removedCount = new int[1];
for (String groupId : groupIds) {
removedCount[0] = 0;
ErrorCode errorCode = quitGroup(userId, groupId);
LOG.info("clear user {} group {} result {}", userId, groupId, errorCode);
}
}
private void removeGroupUserSettings(String groupId, List<String> users) {
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
MultiMap<String, WFCMessage.UserSettingEntry> userSettingMap = hzInstance.getMultiMap(USER_SETTING);
@@ -971,6 +1016,11 @@ public class MemoryMessagesStore implements IMessagesStore {
return groupInfo;
}
@Override
public Set<String> getUserGroupIds(String userId) {
return databaseStore.getUserGroupIds(userId);
}
@Override
public ErrorCode getGroupMembers(String groupId, long maxDt, List<WFCMessage.GroupMember> members) {
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
@@ -1230,6 +1280,18 @@ public class MemoryMessagesStore implements IMessagesStore {
}
}
@Override
public void clearUserMessages(String userId) {
mWriteLock.lock();
try {
userMessages.remove(userId);
} finally {
mWriteLock.unlock();
}
databaseStore.clearUserMessage(userId);
}
@Override
public WFCMessage.Robot getRobot(String robotId) {
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
@@ -1400,6 +1462,18 @@ public class MemoryMessagesStore implements IMessagesStore {
databaseStore.updateUserPassword(user.getUid(), password);
}
@Override
public void destoryUser(String userId) {
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
IMap<String, WFCMessage.User> mUserMap = hzInstance.getMap(USERS);
WFCMessage.User us = mUserMap.get(userId);
if (us != null) {
us = WFCMessage.User.newBuilder().setUid(userId).setUpdateDt(System.currentTimeMillis()).setDisplayName("已删除用户").setName(userId).setDeleted(1).build();
mUserMap.put(userId, us);
}
}
@Override
public WFCMessage.User getUserInfo(String userId) {
if (StringUtil.isNullOrEmpty(userId)) {
@@ -1424,8 +1498,8 @@ public class MemoryMessagesStore implements IMessagesStore {
return getUserInfo(userId);
}
@Override
public List<WFCMessage.User> searchUser(String keyword, boolean buzzy, int page) {
return databaseStore.searchUserFromDB(keyword, buzzy, page);
public List<WFCMessage.User> searchUser(String keyword, int searchType, int page) {
return databaseStore.searchUserFromDB(keyword, searchType, page);
}
@Override
@@ -1562,7 +1636,7 @@ public class MemoryMessagesStore implements IMessagesStore {
for (FriendData friendData : friendDatas) {
if (friendData.getFriendUid().equals(userId)) {
if (friendData.getState() == 2) {
if (friendData.getBlacked() == 1) {
return true;
} else {
return false;
@@ -1689,6 +1763,31 @@ public class MemoryMessagesStore implements IMessagesStore {
return out;
}
@Override
public void clearUserFriend(String userId) {
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
MultiMap<String, FriendData> friendsMap = hzInstance.getMultiMap(USER_FRIENDS);
Collection<FriendData> friendDatas = friendsMap.get(userId);
if (friendDatas == null || friendDatas.size() == 0) {
friendDatas = loadFriend(friendsMap, userId);
}
databaseStore.removeUserFriend(userId);
databaseStore.removeUserFriendRequest(userId);
MultiMap<String, WFCMessage.FriendRequest> requestMap = hzInstance.getMultiMap(USER_FRIENDS_REQUEST);
requestMap.remove(userId);
if (friendDatas != null) {
for (FriendData fd : friendDatas) {
friendsMap.remove(fd.getFriendUid());
}
friendsMap.remove(userId);
}
}
@Override
public List<WFCMessage.FriendRequest> getFriendRequestList(String userId, long version) {
List<WFCMessage.FriendRequest> out = new ArrayList<>();
@@ -1896,7 +1995,10 @@ public class MemoryMessagesStore implements IMessagesStore {
public ErrorCode blackUserRequest(String fromUser, String targetUserId, int state, long[] heads) {
if (state == 2) {
state = 1;
} else {
state = 0;
}
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
MultiMap<String, FriendData> friendsMap = hzInstance.getMultiMap(USER_FRIENDS);
@@ -2037,6 +2139,8 @@ public class MemoryMessagesStore implements IMessagesStore {
public ErrorCode getUserSettings(String userId, long version, WFCMessage.GetUserSettingResult.Builder builder) {
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
MultiMap<String, WFCMessage.UserSettingEntry> userSettingMap = hzInstance.getMultiMap(USER_SETTING);
IMap<String, WFCMessage.GroupInfo> mGroups = hzInstance.getMap(GROUPS_MAP);
IMap<String, WFCMessage.ChannelInfo> mChannels = hzInstance.getMap(CHANNELS);
Collection<WFCMessage.UserSettingEntry> entries = userSettingMap.get(userId);
if (entries == null || entries.size() == 0) {
@@ -2044,12 +2148,51 @@ public class MemoryMessagesStore implements IMessagesStore {
}
ErrorCode ec = ErrorCode.ERROR_CODE_NOT_MODIFIED;
Calendar c = Calendar.getInstance();
c.setTime(new Date());
c.add(Calendar.MONTH, -1);
long monthAgo = c.getTimeInMillis();
if (entries != null) {
for (WFCMessage.UserSettingEntry entry : entries
) {
if (entry.getUpdateDt() > version) {
ec = ErrorCode.ERROR_CODE_SUCCESS;
builder.addEntry(entry);
boolean skip = false;
if (version == 0 && entry.getUpdateDt() > monthAgo) {
if (entry.getScope() == UserSettingScope.kUserSettingConversationSync) {
try {
String key = entry.getKey();
int pos1 = key.indexOf('-');
String typeStr = key.substring(0, pos1);
int type = Integer.parseInt(typeStr);
if (type == ProtoConstants.ConversationType.ConversationType_Group
|| type == ProtoConstants.ConversationType.ConversationType_Channel) {
int pos2 = key.indexOf('-', pos1 + 1);
String target = key.substring(pos2 + 1);
if (type == ProtoConstants.ConversationType.ConversationType_Group) {
WFCMessage.GroupInfo groupInfo = mGroups.get(target);
if (groupInfo == null) {
skip = true;
}
} else {
WFCMessage.ChannelInfo channelInfo = mChannels.get(target);
if (channelInfo == null) {
skip = true;
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
if (!skip) {
builder.addEntry(entry);
}
}
}
}
@@ -2145,6 +2288,14 @@ public class MemoryMessagesStore implements IMessagesStore {
return updateDt;
}
@Override
public void clearUserSettings(String userId) {
databaseStore.clearUserSetting(userId);
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
MultiMap<String, WFCMessage.UserSettingEntry> userSettingMap = hzInstance.getMultiMap(USER_SETTING);
userSettingMap.remove(userId);
}
@Override
public boolean getUserGlobalSlient(String userId) {
Boolean slient = userGlobalSlientMap.get(userId);
@@ -2164,7 +2315,7 @@ public class MemoryMessagesStore implements IMessagesStore {
public boolean getUserPushHiddenDetail(String userId) {
Boolean hidden = userPushHiddenDetail.get(userId);
if (hidden == null) {
WFCMessage.UserSettingEntry entry = getUserSetting(userId, UserSettingScope.kUserSettingGlobalSilent, null);
WFCMessage.UserSettingEntry entry = getUserSetting(userId, UserSettingScope.kUserSettingHiddenNotificationDetail, null);
if (entry == null || !entry.getValue().equals("1")) {
hidden = false;
} else {
@@ -2202,6 +2353,12 @@ public class MemoryMessagesStore implements IMessagesStore {
return ErrorCode.ERROR_CODE_SUCCESS;
}
@Override
public void clearUserChannels(String userId) {
}
@Override
public ErrorCode modifyChannelInfo(String operator, String channelId, int modifyType, String value) {
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
@@ -2487,7 +2644,7 @@ public class MemoryMessagesStore implements IMessagesStore {
}
return UUIDGenerator.getUUID();
}
@Override
public void storeRetained(Topic topic, StoredMessage storedMessage) {
LOG.debug("Store retained message for topic={}, CId={}", topic, storedMessage.getClientID());
@@ -16,17 +16,19 @@
package io.moquette.persistence;
import cn.wildfirechat.common.ErrorCode;
import cn.wildfirechat.proto.ProtoConstants;
import cn.wildfirechat.proto.WFCMessage;
import com.hazelcast.util.StringUtil;
import io.moquette.BrokerConstants;
import io.moquette.server.Constants;
import io.moquette.server.Server;
import io.moquette.spi.ClientSession;
import io.moquette.spi.IMessagesStore.StoredMessage;
import io.moquette.spi.ISessionsStore;
import io.moquette.spi.IMessagesStore.StoredMessage;
import io.netty.handler.codec.mqtt.MqttVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import cn.wildfirechat.common.ErrorCode;
import java.util.*;
import java.util.concurrent.*;
@@ -35,6 +37,8 @@ public class MemorySessionStore implements ISessionsStore {
private static int dumy = 1;
private static final Logger LOG = LoggerFactory.getLogger(MemorySessionStore.class);
private boolean supportMultiEndpoint = false;
public static class Session implements Comparable<Session>{
final String clientID;
String username;
@@ -50,6 +54,16 @@ public class MemorySessionStore implements ISessionsStore {
private volatile int unReceivedMsgs;
private int deleted;
public int getDeleted() {
return deleted;
}
public void setDeleted(int deleted) {
this.deleted = deleted;
}
private MqttVersion mqttVersion = MqttVersion.MQTT_3_1_1;
public long getLastActiveTime() {
@@ -130,6 +144,9 @@ public class MemorySessionStore implements ISessionsStore {
public void setUpdateDt(long updateDt) {
this.updateDt = updateDt;
if (this.lastActiveTime == 0) {
this.lastActiveTime = updateDt;
}
}
private int pushType;
@@ -248,8 +265,14 @@ public class MemorySessionStore implements ISessionsStore {
private final Server mServer;
private final DatabaseStore databaseStore;
public MemorySessionStore(Server server, DatabaseStore databaseStore) {
mServer = server;
this.databaseStore = databaseStore;
mServer = server;
this.databaseStore = databaseStore;
try {
supportMultiEndpoint = Boolean.parseBoolean(server.getConfig().getProperty(BrokerConstants.SERVER_MULTI_ENDPOINT));
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
@@ -261,6 +284,21 @@ public class MemorySessionStore implements ISessionsStore {
return session;
}
@Override
public void cleanDuplatedToken(String cid, int pushType, String token, boolean isVoip) {
if (StringUtil.isNullOrEmpty(token) || isVoip) {
return;
}
Iterator<Map.Entry<String, Session>> it = sessions.entrySet().iterator();
while (it.hasNext()) {
Session session = it.next().getValue();
if (!session.getClientID().equals(cid) && (session.pushType == pushType && token.equals(session.deviceToken))) {
session.deviceToken = null;
}
}
}
@Override
public void initStore() {
}
@@ -272,18 +310,91 @@ public class MemorySessionStore implements ISessionsStore {
@Override
public void updateSessionToken(Session session, boolean voip) {
databaseStore.updateSessionToken(session.getUsername(), session.getClientID(), voip ? session.getVoipDeviceToken() : session.getDeviceToken(), voip);
databaseStore.updateSessionToken(session.getUsername(), session.getClientID(), voip ? session.getVoipDeviceToken() : session.getDeviceToken(), session.getPushType(), voip);
}
@Override
public Session createUserSession(String username, String clientID) {
public void clearUserSession(String username) {
LOG.info("Fooooooooo <{}>", username);
databaseStore.clearUserSessions(username);
ConcurrentSkipListSet<String> sessionSet = getUserSessionSet(username);
for (String clientID : sessionSet) {
Session s = sessions.remove(clientID);
mServer.getProcessor().kickoffSession(s);
}
userSessions.remove(username);
}
@Override
public Session updateOrCreateUserSession(String username, String clientID, int platform) {
LOG.debug("createUserSession for client <{}>, user <{}>", clientID, username);
Session session = sessions.get(clientID);
if (session != null && !session.username.equals(username)) {
if (userSessions.get(username) != null) {
userSessions.get(username).remove(clientID);
}
}
ClientSession clientSession = new ClientSession(clientID, this);
Session session = databaseStore.getSession(username, clientID, clientSession);
session = databaseStore.getSession(username, clientID, clientSession);
if (session == null) {
session = databaseStore.createSession(username, clientID, clientSession);
session = databaseStore.createSession(username, clientID, clientSession, platform);
}
sessions.put(clientID, session);
if (session.getDeleted() > 0) {
session.setDeleted(0);
databaseStore.updateSessionDeleted(username, clientID, 0);
}
if (session.getPlatform() != platform) {
session.setPlatform(platform);
databaseStore.updateSessionPlatform(username, clientID, platform);
}
if (!supportMultiEndpoint && platform > 0) {
databaseStore.clearMultiEndpoint(username, clientID, platform);
if (userSessions.get(username) != null) {
Iterator<String> it = userSessions.get(username).iterator();
while (it.hasNext()) {
String c = it.next();
if (!clientID.equals(c)) {
Session s = sessions.get(c);
if (s == null) {
it.remove();
continue;
}
boolean remove = false;
if (platform == ProtoConstants.Platform.Platform_Android || platform == ProtoConstants.Platform.Platform_iOS) {
if (s.getPlatform() == ProtoConstants.Platform.Platform_Android || s.getPlatform() == ProtoConstants.Platform.Platform_iOS) {
remove = true;
}
} else if(platform == ProtoConstants.Platform.Platform_OSX || platform == ProtoConstants.Platform.Platform_Windows) {
if (s.getPlatform() == ProtoConstants.Platform.Platform_OSX || s.getPlatform() == ProtoConstants.Platform.Platform_Windows) {
remove = true;
}
} else {
if (s.getPlatform() ==platform) {
remove = true;
}
}
if (remove) {
sessions.remove(c);
mServer.getProcessor().kickoffSession(s);
it.remove();
}
}
}
}
}
return session;
@@ -291,34 +402,29 @@ public class MemorySessionStore implements ISessionsStore {
@Override
public ErrorCode createNewSession(String username, String clientID, boolean cleanSession, boolean createWhenNoExist) {
public ErrorCode loadActiveSession(String username, String clientID) {
LOG.debug("createNewSession for client <{}>", clientID);
Session session = sessions.get(clientID);
if (session != null) {
if (session != null && session.getDeleted() == 0) {
LOG.error("already exists a session for client <{}>, bad condition", clientID);
throw new IllegalArgumentException("Can't create a session with the ID of an already existing" + clientID);
}
if (session != null && session.getDeleted() > 0) {
return ErrorCode.ERROR_CODE_SECRECT_KEY_MISMATCH;
}
ClientSession clientSession = new ClientSession(clientID, this);
session = databaseStore.getSession(username, clientID, clientSession);
if (session == null) {
if (!createWhenNoExist) {
return ErrorCode.ERROR_CODE_NOT_EXIST;
}
session = databaseStore.createSession(username, clientID, clientSession);
if (session == null || session.getDeleted() > 0) {
return ErrorCode.ERROR_CODE_SECRECT_KEY_MISMATCH;
}
sessions.put(clientID, session);
ConcurrentSkipListSet<String> sessionSet = userSessions.get(username);
if (sessionSet == null) {
sessionSet = new ConcurrentSkipListSet<>();
userSessions.put(username, sessionSet);
}
sessionSet = userSessions.get(username);
ConcurrentSkipListSet<String> sessionSet = getUserSessionSet(username);
sessionSet.add(clientID);
return ErrorCode.ERROR_CODE_SUCCESS;
@@ -342,12 +448,7 @@ public class MemorySessionStore implements ISessionsStore {
session.setUsername(username);
sessions.put(clientID, session);
ConcurrentSkipListSet<String> sessionSet = userSessions.get(username);
if (sessionSet == null) {
sessionSet = new ConcurrentSkipListSet<>();
userSessions.put(username, sessionSet);
}
sessionSet = userSessions.get(username);
ConcurrentSkipListSet<String> sessionSet = getUserSessionSet(username);
sessionSet.add(clientID);
if (endpoint != null) {
@@ -393,14 +494,26 @@ public class MemorySessionStore implements ISessionsStore {
}
}
private ConcurrentSkipListSet<String> getUserSessionSet(String username) {
ConcurrentSkipListSet<String> sessionSet = userSessions.get(username);
if (sessionSet == null) {
sessionSet = new ConcurrentSkipListSet<String>();
List<Session> ss = databaseStore.getUserActivedSessions(username);
for (Session s : ss) {
sessionSet.add(s.getClientID());
sessions.put(s.getClientID(), s);
}
userSessions.put(username, sessionSet);
}
sessionSet = userSessions.get(username);
return sessionSet;
}
@Override
public Collection<Session> sessionForUser(String username) {
ConcurrentSkipListSet<String> sessionSet = userSessions.get(username);
if (sessionSet == null) {
sessionSet = new ConcurrentSkipListSet<String>();
userSessions.put(username, sessionSet);
}
sessionSet = userSessions.get(username);
ConcurrentSkipListSet<String> sessionSet = getUserSessionSet(username);
ArrayList<Session> out = new ArrayList<>();
for (String clientId : sessionSet
) {
@@ -466,7 +579,9 @@ public class MemorySessionStore implements ISessionsStore {
@Override
public void dropQueue(String clientID) {
sessions.get(clientID).queue.clear();
if (sessions.get(clientID) != null) {
sessions.get(clientID).queue.clear();
}
}
@Override
@@ -542,12 +657,7 @@ public class MemorySessionStore implements ISessionsStore {
LOG.error("Can't find the session for client <{}>", clientID);
return;
}
ConcurrentSkipListSet<String> sessionSet = userSessions.get(session.username);
if (sessionSet == null) {
sessionSet = new ConcurrentSkipListSet<>();
userSessions.put(session.username, sessionSet);
}
sessionSet = userSessions.get(session.username);
ConcurrentSkipListSet<String> sessionSet = getUserSessionSet(session.username);
sessionSet.remove(clientID);
// remove also the messages stored of type QoS1/2
@@ -24,8 +24,10 @@ public final class Constants {
public static final String ATTR_CLIENTID = "ClientID";
public static final String CLEAN_SESSION = "cleanSession";
public static final String KEEP_ALIVE = "keepAlive";
public static final int MAX_MESSAGE_QUEUE = 1024; // number of messages
public static final int MAX_CHATROOM_MESSAGE_QUEUE = 256; // number of chatroom messages
public static int MAX_MESSAGE_QUEUE = 1024; // number of messages
public static int MAX_CHATROOM_MESSAGE_QUEUE = 256; // number of chatroom messages
private Constants() {
}
@@ -107,11 +107,13 @@ public interface IMessagesStore {
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);
void clearUserGroups(String userId);
ErrorCode dismissGroup(String operator, String groupId, boolean isAdmin);
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);
Set<String> getUserGroupIds(String userId);
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);
@@ -121,6 +123,8 @@ public interface IMessagesStore {
ErrorCode recallMessage(long messageUid, String operatorId, boolean isAdmin);
void clearUserMessages(String userId);
WFCMessage.Robot getRobot(String robotId);
void addRobot(WFCMessage.Robot robot);
ErrorCode getUserInfo(List<WFCMessage.UserRequest> requestList, WFCMessage.PullUserResult.Builder builder);
@@ -131,10 +135,11 @@ public interface IMessagesStore {
List<InputOutputUserBlockStatus> getUserStatusList();
void addUserInfo(WFCMessage.User user, String password);
void destoryUser(String userId);
WFCMessage.User getUserInfo(String userId);
WFCMessage.User getUserInfoByName(String name);
WFCMessage.User getUserInfoByMobile(String mobile);
List<WFCMessage.User> searchUser(String keyword, boolean buzzy, int page);
List<WFCMessage.User> searchUser(String keyword, int searchType, int page);
boolean updateSystemSetting(int id, String value, String desc);
SystemSettingPojo getSystemSetting(int id);
@@ -154,6 +159,7 @@ public interface IMessagesStore {
ErrorCode login(String name, String password, List<String> userIdRet);
List<FriendData> getFriendList(String userId, String clientId, long version);
void clearUserFriend(String userId);
List<WFCMessage.FriendRequest> getFriendRequestList(String userId, long version);
ErrorCode saveAddFriendRequest(String userId, WFCMessage.AddFriendRequest request, long[] head);
@@ -171,12 +177,14 @@ public interface IMessagesStore {
WFCMessage.UserSettingEntry getUserSetting(String userId, int scope, String key);
List<WFCMessage.UserSettingEntry> getUserSetting(String userId, int scope);
long updateUserSettings(String userId, WFCMessage.ModifyUserSettingReq request);
void clearUserSettings(String userId);
boolean getUserGlobalSlient(String userId);
boolean getUserPushHiddenDetail(String userId);
boolean getUserConversationSlient(String userId, WFCMessage.Conversation conversation);
ErrorCode createChannel(String operator, WFCMessage.ChannelInfo channelInfo);
void clearUserChannels(String userId);
ErrorCode modifyChannelInfo(String operator, String channelId, int modifyType, String value);
ErrorCode transferChannel(String operator, String channelId, String newOwner);
ErrorCode distoryChannel(String operator, String channelId);
@@ -38,15 +38,19 @@ public interface ISessionsStore {
*/
boolean contains(String clientID);
Session createUserSession(String username, String clientID);
Session updateOrCreateUserSession(String username, String clientID, int platform);
ErrorCode createNewSession(String username, String clientID, boolean cleanSession, boolean createNoExist);
ErrorCode loadActiveSession(String username, String clientID);
ClientSession updateExistSession(String username, String clientID, WFCMessage.RouteRequest endpoint, boolean cleanSession);
Session getSession(String clientID);
void cleanDuplatedToken(String cid, int pushType, String token, boolean isVoip);
void updateSessionToken(Session session, boolean voip);
void clearUserSession(String username);
/**
* @param clientID
* the client owning the session.
@@ -16,6 +16,7 @@
package io.moquette.spi.impl;
import cn.wildfirechat.common.ErrorCode;
import cn.wildfirechat.proto.WFCMessage;
import io.moquette.persistence.RPCCenter;
import io.moquette.interception.InterceptHandler;
@@ -55,7 +56,24 @@ import static io.moquette.server.ConnectionDescriptor.ConnectionState.*;
*
* Used by the front facing class ProtocolProcessorBootstrapper.
*/
public class ProtocolProcessor {
public void kickoffSession(final MemorySessionStore.Session session) {
mServer.getImBusinessScheduler().execute(()->{
ConnectionDescriptor descriptor = connectionDescriptors.getConnection(session.getClientID());
try {
if (descriptor != null) {
processDisconnect(descriptor.getChannel(), true);
}
} catch (InterruptedException e) {
e.printStackTrace();
Utility.printExecption(LOG, e);
}
});
}
private void handleTargetRemovedFromCurrentNode(TargetEntry target) {
System.out.println("kickof user " + target);
if (target.type == TargetEntry.Type.TARGET_TYPE_USER) {
@@ -142,7 +160,7 @@ public class ProtocolProcessor {
String clientId = payload.clientIdentifier();
LOG.info("Processing CONNECT message. CId={}, username={}", clientId, payload.userName());
if (msg.variableHeader().version() <= MqttVersion.MQTT_3_1_1.protocolLevel() ||
if (msg.variableHeader().version() < MqttVersion.MQTT_3_1_1.protocolLevel() ||
msg.variableHeader().version() >= MqttVersion.Wildfire_Max.protocolLevel()) {
MqttConnAckMessage badProto = connAck(CONNECTION_REFUSED_UNACCEPTABLE_PROTOCOL_VERSION);
@@ -164,7 +182,11 @@ public class ProtocolProcessor {
MqttVersion mqttVersion = MqttVersion.fromProtocolLevel(msg.variableHeader().version());
if (!login(channel, msg, clientId, mqttVersion)) {
MqttConnAckMessage badId = connAck(CONNECTION_REFUSED_BAD_USER_NAME_OR_PASSWORD);
channel.writeAndFlush(badId);
channel.close();
LOG.error("The MQTT login failure. Username={}", payload.userName());
return;
}
if (!mServer.m_initialized) {
@@ -253,9 +275,16 @@ public class ProtocolProcessor {
MemorySessionStore.Session session = m_sessionsStore.getSession(clientId);
if (session == null) {
m_sessionsStore.createNewSession(msg.payload().userName(), clientId, true, false);
ErrorCode errorCode = m_sessionsStore.loadActiveSession(msg.payload().userName(), clientId);
if (errorCode != ErrorCode.ERROR_CODE_SUCCESS) {
return false;
}
session = m_sessionsStore.getSession(clientId);
}
if (session.getDeleted() != 0) {
return false;
}
if (session != null && session.getUsername().equals(msg.payload().userName())) {
pwd = AES.AESDecrypt(pwd, session.getSecret(), true);
@@ -501,15 +530,12 @@ public class ProtocolProcessor {
return;
}
boolean stillPresent = this.connectionDescriptors.removeConnection(existingDescriptor);
if (!stillPresent) {
// another descriptor was inserted
LOG.warn("Another descriptor has been inserted. CId={}", clientID);
return;
}
this.connectionDescriptors.removeConnection(existingDescriptor);
LOG.info("The DISCONNECT message has been processed. CId={}", clientID);
channel.closeFuture();
//disconnect the session
m_sessionsStore.sessionForClient(clientID).disconnect(clearSession);
}
@@ -52,7 +52,14 @@ public class HttpUtils {
@Override
public void onResponse(Call call, Response response) throws IOException {
LOG.info("POST to {} success with response", url, response.body().string());
LOG.info("POST to {} success with response: {}", url, response.body());
try {
if (response.body() != null) {
response.body().close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
@@ -71,6 +71,7 @@ public interface IMTopic {
String ChannelPullTopic = "CHP";
String GetTokenTopic = "GETTOKEN";
String DestroyUserTopic = "DESTROYUSER";
String LoadRemoteMessagesTopic = "LRM";
}
+1 -1
View File
@@ -22,7 +22,7 @@
<!--MySQL数据库用户名-->
<property name="user">root</property>
<!--MySQL数据库密码-->
<property name="password">lt123456</property>
<property name="password">123456</property>
<!-- 初始化连接池中的连接数,取值应在minPoolSize与maxPoolSize之间,默认为3-->
<property name="initialPoolSize">10</property>
<!--最大空闲时间,60秒内未使用则连接被丢弃。若为0则永不丢弃。默认值: 0 -->
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId>
<version>0.30</version>
<version>0.36</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -0,0 +1,22 @@
/*
* This file is part of the Wildfire Chat package.
* (c) Heavyrain2012 <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
package cn.wildfirechat.pojos;
public class InputDestroyUser {
private String userId;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
}
@@ -11,6 +11,7 @@ public interface APIPath {
String Sensitive_Query = "/admin/sensitive/query";
String Create_User = "/admin/user/create";
String Destroy_User = "/admin/user/destroy";
String Create_Robot = "/admin/robot/create";
String User_Get_Token = "/admin/user/get_token";
String User_Update_Block_Status = "/admin/user/update_block_status";
@@ -37,6 +38,7 @@ public interface APIPath {
String Group_Member_Add = "/admin/group/member/add";
String Group_Member_Kickoff = "/admin/group/member/del";
String Group_Set_Manager = "/admin/group/manager/set";
String Get_User_Groups = "/admin/group/of_user";
String Create_Channel = "/admin/channel/create";
@@ -3,10 +3,20 @@ package cn.wildfirechat.pojos;
public class InputGetToken {
private String userId;
private String clientId;
private Integer platform;
public InputGetToken(String userId, String clientId) {
public InputGetToken(String userId, String clientId, int platform) {
this.userId = userId;
this.clientId = clientId;
this.platform = platform;
}
public Integer getPlatform() {
return platform;
}
public void setPlatform(Integer platform) {
this.platform = platform;
}
public String getUserId() {
@@ -0,0 +1,21 @@
/*
* This file is part of the Wildfire Chat package.
* (c) Heavyrain2012 <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
package cn.wildfirechat.pojos;
public class InputUserId {
private String userId;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
}
@@ -0,0 +1,23 @@
/*
* This file is part of the Wildfire Chat package.
* (c) Heavyrain2012 <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
package cn.wildfirechat.pojos;
import java.util.List;
public class OutputGroupIds {
private List<String> groupIds;
public List<String> getGroupIds() {
return groupIds;
}
public void setGroupIds(List<String> groupIds) {
this.groupIds = groupIds;
}
}
@@ -132,6 +132,12 @@ public class ProtoConstants {
int Group_Max_Member_Count = 1;
}
public interface SearchUserType {
int SearchUserType_General = 0;
int SearchUserType_Name_Mobile = 1;
int SearchUserType_Name = 2;
int SearchUserType_Mobile = 3;
}
@@ -22192,6 +22192,16 @@ public final class WFCMessage {
* </pre>
*/
int getType();
// optional int32 deleted = 14;
/**
* <code>optional int32 deleted = 14;</code>
*/
boolean hasDeleted();
/**
* <code>optional int32 deleted = 14;</code>
*/
int getDeleted();
}
/**
* Protobuf type {@code User}
@@ -22309,6 +22319,11 @@ public final class WFCMessage {
type_ = input.readInt32();
break;
}
case 112: {
bitField0_ |= 0x00002000;
deleted_ = input.readInt32();
break;
}
}
}
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
@@ -22835,6 +22850,22 @@ public final class WFCMessage {
return type_;
}
// optional int32 deleted = 14;
public static final int DELETED_FIELD_NUMBER = 14;
private int deleted_;
/**
* <code>optional int32 deleted = 14;</code>
*/
public boolean hasDeleted() {
return ((bitField0_ & 0x00002000) == 0x00002000);
}
/**
* <code>optional int32 deleted = 14;</code>
*/
public int getDeleted() {
return deleted_;
}
private void initFields() {
uid_ = "";
name_ = "";
@@ -22849,6 +22880,7 @@ public final class WFCMessage {
gender_ = 0;
social_ = "";
type_ = 0;
deleted_ = 0;
}
private byte memoizedIsInitialized = -1;
public final boolean isInitialized() {
@@ -22905,6 +22937,9 @@ public final class WFCMessage {
if (((bitField0_ & 0x00001000) == 0x00001000)) {
output.writeInt32(13, type_);
}
if (((bitField0_ & 0x00002000) == 0x00002000)) {
output.writeInt32(14, deleted_);
}
getUnknownFields().writeTo(output);
}
@@ -22966,6 +23001,10 @@ public final class WFCMessage {
size += com.google.protobuf.CodedOutputStream
.computeInt32Size(13, type_);
}
if (((bitField0_ & 0x00002000) == 0x00002000)) {
size += com.google.protobuf.CodedOutputStream
.computeInt32Size(14, deleted_);
}
size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size;
return size;
@@ -23108,6 +23147,8 @@ public final class WFCMessage {
bitField0_ = (bitField0_ & ~0x00000800);
type_ = 0;
bitField0_ = (bitField0_ & ~0x00001000);
deleted_ = 0;
bitField0_ = (bitField0_ & ~0x00002000);
return this;
}
@@ -23188,6 +23229,10 @@ public final class WFCMessage {
to_bitField0_ |= 0x00001000;
}
result.type_ = type_;
if (((from_bitField0_ & 0x00002000) == 0x00002000)) {
to_bitField0_ |= 0x00002000;
}
result.deleted_ = deleted_;
result.bitField0_ = to_bitField0_;
onBuilt();
return result;
@@ -23263,6 +23308,9 @@ public final class WFCMessage {
if (other.hasType()) {
setType(other.getType());
}
if (other.hasDeleted()) {
setDeleted(other.getDeleted());
}
this.mergeUnknownFields(other.getUnknownFields());
return this;
}
@@ -24149,6 +24197,39 @@ public final class WFCMessage {
return this;
}
// optional int32 deleted = 14;
private int deleted_ ;
/**
* <code>optional int32 deleted = 14;</code>
*/
public boolean hasDeleted() {
return ((bitField0_ & 0x00002000) == 0x00002000);
}
/**
* <code>optional int32 deleted = 14;</code>
*/
public int getDeleted() {
return deleted_;
}
/**
* <code>optional int32 deleted = 14;</code>
*/
public Builder setDeleted(int value) {
bitField0_ |= 0x00002000;
deleted_ = value;
onChanged();
return this;
}
/**
* <code>optional int32 deleted = 14;</code>
*/
public Builder clearDeleted() {
bitField0_ = (bitField0_ & ~0x00002000);
deleted_ = 0;
onChanged();
return this;
}
// @@protoc_insertion_point(builder_scope:User)
}
@@ -57571,6 +57652,16 @@ public final class WFCMessage {
*/
com.google.protobuf.ByteString
getClientIdBytes();
// optional int32 platform = 3;
/**
* <code>optional int32 platform = 3;</code>
*/
boolean hasPlatform();
/**
* <code>optional int32 platform = 3;</code>
*/
int getPlatform();
}
/**
* Protobuf type {@code GetTokenRequest}
@@ -57633,6 +57724,11 @@ public final class WFCMessage {
clientId_ = input.readBytes();
break;
}
case 24: {
bitField0_ |= 0x00000004;
platform_ = input.readInt32();
break;
}
}
}
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
@@ -57759,9 +57855,26 @@ public final class WFCMessage {
}
}
// optional int32 platform = 3;
public static final int PLATFORM_FIELD_NUMBER = 3;
private int platform_;
/**
* <code>optional int32 platform = 3;</code>
*/
public boolean hasPlatform() {
return ((bitField0_ & 0x00000004) == 0x00000004);
}
/**
* <code>optional int32 platform = 3;</code>
*/
public int getPlatform() {
return platform_;
}
private void initFields() {
userId_ = "";
clientId_ = "";
platform_ = 0;
}
private byte memoizedIsInitialized = -1;
public final boolean isInitialized() {
@@ -57789,6 +57902,9 @@ public final class WFCMessage {
if (((bitField0_ & 0x00000002) == 0x00000002)) {
output.writeBytes(2, getClientIdBytes());
}
if (((bitField0_ & 0x00000004) == 0x00000004)) {
output.writeInt32(3, platform_);
}
getUnknownFields().writeTo(output);
}
@@ -57806,6 +57922,10 @@ public final class WFCMessage {
size += com.google.protobuf.CodedOutputStream
.computeBytesSize(2, getClientIdBytes());
}
if (((bitField0_ & 0x00000004) == 0x00000004)) {
size += com.google.protobuf.CodedOutputStream
.computeInt32Size(3, platform_);
}
size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size;
return size;
@@ -57926,6 +58046,8 @@ public final class WFCMessage {
bitField0_ = (bitField0_ & ~0x00000001);
clientId_ = "";
bitField0_ = (bitField0_ & ~0x00000002);
platform_ = 0;
bitField0_ = (bitField0_ & ~0x00000004);
return this;
}
@@ -57962,6 +58084,10 @@ public final class WFCMessage {
to_bitField0_ |= 0x00000002;
}
result.clientId_ = clientId_;
if (((from_bitField0_ & 0x00000004) == 0x00000004)) {
to_bitField0_ |= 0x00000004;
}
result.platform_ = platform_;
result.bitField0_ = to_bitField0_;
onBuilt();
return result;
@@ -57988,6 +58114,9 @@ public final class WFCMessage {
clientId_ = other.clientId_;
onChanged();
}
if (other.hasPlatform()) {
setPlatform(other.getPlatform());
}
this.mergeUnknownFields(other.getUnknownFields());
return this;
}
@@ -58171,6 +58300,39 @@ public final class WFCMessage {
return this;
}
// optional int32 platform = 3;
private int platform_ ;
/**
* <code>optional int32 platform = 3;</code>
*/
public boolean hasPlatform() {
return ((bitField0_ & 0x00000004) == 0x00000004);
}
/**
* <code>optional int32 platform = 3;</code>
*/
public int getPlatform() {
return platform_;
}
/**
* <code>optional int32 platform = 3;</code>
*/
public Builder setPlatform(int value) {
bitField0_ |= 0x00000004;
platform_ = value;
onChanged();
return this;
}
/**
* <code>optional int32 platform = 3;</code>
*/
public Builder clearPlatform() {
bitField0_ = (bitField0_ & ~0x00000004);
platform_ = 0;
onChanged();
return this;
}
// @@protoc_insertion_point(builder_scope:GetTokenRequest)
}
@@ -60274,101 +60436,102 @@ public final class WFCMessage {
"om_user\030\002 \002(\t\022 \n\007content\030\003 \002(\0132\017.Message" +
"Content\022\022\n\nmessage_id\030\004 \001(\003\022\030\n\020server_ti",
"mestamp\030\005 \001(\003\022\017\n\007to_user\030\006 \001(\t\022\n\n\002to\030\007 \003" +
"(\t\"\332\001\n\004User\022\013\n\003uid\030\001 \002(\t\022\014\n\004name\030\002 \001(\t\022\024" +
"(\t\"\353\001\n\004User\022\013\n\003uid\030\001 \002(\t\022\014\n\004name\030\002 \001(\t\022\024" +
"\n\014display_name\030\003 \001(\t\022\020\n\010portrait\030\004 \001(\t\022\016" +
"\n\006mobile\030\005 \001(\t\022\r\n\005email\030\006 \001(\t\022\017\n\007address" +
"\030\007 \001(\t\022\017\n\007company\030\010 \001(\t\022\r\n\005extra\030\t \001(\t\022\021" +
"\n\tupdate_dt\030\n \001(\003\022\016\n\006gender\030\013 \001(\005\022\016\n\006soc" +
"ial\030\014 \001(\t\022\014\n\004type\030\r \001(\005\"c\n\005Robot\022\013\n\003uid\030" +
"\001 \002(\t\022\r\n\005state\030\002 \002(\005\022\r\n\005owner\030\003 \001(\t\022\016\n\006s" +
"ecret\030\004 \001(\t\022\020\n\010callback\030\005 \001(\t\022\r\n\005extra\030\006" +
" \001(\t\"(\n\017GetRobotsResult\022\025\n\005entry\030\001 \003(\0132\006",
".Robot\"P\n\005Thing\022\013\n\003uid\030\001 \002(\t\022\r\n\005state\030\002 " +
"\002(\005\022\r\n\005token\030\003 \002(\t\022\r\n\005owner\030\004 \001(\t\022\r\n\005ext" +
"ra\030\005 \001(\t\"(\n\017GetThingsResult\022\025\n\005entry\030\001 \003" +
"(\0132\006.Thing\"g\n\030UploadDeviceTokenRequest\022\020" +
"\n\010platform\030\001 \002(\005\022\020\n\010app_name\030\002 \002(\t\022\024\n\014de" +
"vice_token\030\003 \002(\t\022\021\n\tpush_type\030\004 \002(\005\"\201\001\n\026" +
"ModifyGroupInfoRequest\022\020\n\010group_id\030\001 \002(\t" +
"\022\014\n\004type\030\002 \002(\005\022\r\n\005value\030\003 \002(\t\022\017\n\007to_line" +
"\030\004 \003(\005\022\'\n\016notify_content\030\005 \001(\0132\017.Message" +
"Content\"\203\001\n\026SetGroupManagerRequest\022\020\n\010gr",
"oup_id\030\001 \002(\t\022\014\n\004type\030\002 \002(\005\022\017\n\007user_id\030\003 " +
"\003(\t\022\017\n\007to_line\030\004 \003(\005\022\'\n\016notify_content\030\005" +
" \001(\0132\017.MessageContent\"(\n\tInfoEntry\022\014\n\004ty" +
"pe\030\001 \002(\005\022\r\n\005value\030\002 \002(\t\"0\n\023ModifyMyInfoR" +
"equest\022\031\n\005entry\030\001 \003(\0132\n.InfoEntry\";\n\rNot" +
"ifyMessage\022\014\n\004type\030\001 \002(\005\022\014\n\004head\030\002 \002(\003\022\016" +
"\n\006target\030\003 \001(\t\"=\n\022PullMessageRequest\022\n\n\002" +
"id\030\001 \002(\003\022\014\n\004type\030\002 \002(\005\022\r\n\005delay\030\003 \001(\003\"M\n" +
"\021PullMessageResult\022\031\n\007message\030\001 \003(\0132\010.Me" +
"ssage\022\017\n\007current\030\002 \002(\003\022\014\n\004head\030\003 \002(\003\"/\n\023",
"PullGroupInfoResult\022\030\n\004info\030\001 \003(\0132\n.Grou" +
"pInfo\"6\n\026PullGroupMemberRequest\022\016\n\006targe" +
"t\030\001 \002(\t\022\014\n\004head\030\002 \002(\003\"5\n\025PullGroupMember" +
"Result\022\034\n\006member\030\001 \003(\0132\014.GroupMember\"-\n\013" +
"UserRequest\022\013\n\003uid\030\001 \002(\t\022\021\n\tupdate_dt\030\002 " +
"\001(\003\"0\n\017PullUserRequest\022\035\n\007request\030\001 \003(\0132" +
"\014.UserRequest\"/\n\nUserResult\022\023\n\004user\030\001 \002(" +
"\0132\005.User\022\014\n\004code\030\002 \002(\005\"-\n\016PullUserResult" +
"\022\033\n\006result\030\001 \003(\0132\013.UserResult\"^\n\020QuitGro" +
"upRequest\022\020\n\010group_id\030\001 \002(\t\022\017\n\007to_line\030\002",
" \003(\005\022\'\n\016notify_content\030\003 \001(\0132\017.MessageCo" +
"ntent\"~\n\030RemoveGroupMemberRequest\022\020\n\010gro" +
"up_id\030\001 \002(\t\022\026\n\016removed_member\030\002 \003(\t\022\017\n\007t" +
"o_line\030\003 \003(\005\022\'\n\016notify_content\030\004 \001(\0132\017.M" +
"essageContent\"u\n\024TransferGroupRequest\022\020\n" +
"\010group_id\030\001 \002(\t\022\021\n\tnew_owner\030\002 \002(\t\022\017\n\007to" +
"_line\030\003 \003(\005\022\'\n\016notify_content\030\004 \001(\0132\017.Me" +
"ssageContent\"s\n\026ModifyGroupMemberAlias\022\020" +
"\n\010group_id\030\001 \002(\t\022\r\n\005alias\030\002 \002(\t\022\017\n\007to_li" +
"ne\030\003 \003(\005\022\'\n\016notify_content\030\004 \001(\0132\017.Messa",
"geContent\"P\n\020UserSettingEntry\022\r\n\005scope\030\001" +
" \002(\005\022\013\n\003key\030\002 \002(\t\022\r\n\005value\030\003 \002(\t\022\021\n\tupda" +
"te_dt\030\004 \002(\003\"A\n\024ModifyUserSettingReq\022\r\n\005s" +
"cope\030\001 \002(\005\022\013\n\003key\030\002 \002(\t\022\r\n\005value\030\003 \002(\t\"\032" +
"\n\007Version\022\017\n\007version\030\001 \002(\003\"8\n\024GetUserSet" +
"tingResult\022 \n\005entry\030\001 \003(\0132\021.UserSettingE" +
"ntry\"W\n\006Friend\022\013\n\003uid\030\001 \002(\t\022\r\n\005state\030\002 \002" +
"(\005\022\021\n\tupdate_dt\030\003 \002(\003\022\r\n\005alias\030\004 \001(\t\022\017\n\007" +
"blacked\030\005 \001(\005\"*\n\020GetFriendsResult\022\026\n\005ent" +
"ry\030\001 \003(\0132\007.Friend\"7\n\026GetFriendRequestRes",
"ult\022\035\n\005entry\030\001 \003(\0132\016.FriendRequest\"\243\001\n\021C" +
"onnectAckPayload\022\020\n\010msg_head\030\001 \001(\003\022\023\n\013fr" +
"iend_head\030\002 \001(\003\022\026\n\016friend_rq_head\030\003 \001(\003\022" +
"\024\n\014setting_head\030\004 \001(\003\022\021\n\tnode_addr\030\005 \001(\t" +
"\022\021\n\tnode_port\030\006 \001(\005\022\023\n\013server_time\030\007 \001(\003" +
"\"P\n\rIMHttpWrapper\022\r\n\005token\030\001 \002(\t\022\021\n\tclie" +
"nt_id\030\002 \002(\t\022\017\n\007request\030\003 \002(\t\022\014\n\004data\030\004 \001" +
"(\014\"A\n\021SearchUserRequest\022\017\n\007keyword\030\001 \002(\t" +
"\022\r\n\005fuzzy\030\002 \001(\005\022\014\n\004page\030\003 \001(\005\"(\n\020SearchU" +
"serResult\022\024\n\005entry\030\001 \003(\0132\005.User\"@\n\026GetCh",
"atroomInfoRequest\022\023\n\013chatroom_id\030\001 \002(\t\022\021" +
"\n\tupdate_dt\030\002 \001(\003\"\227\001\n\014ChatroomInfo\022\r\n\005ti" +
"tle\030\001 \002(\t\022\014\n\004desc\030\002 \001(\t\022\020\n\010portrait\030\003 \001(" +
"\t\022\024\n\014member_count\030\004 \001(\005\022\021\n\tcreate_dt\030\005 \001" +
"(\003\022\021\n\tupdate_dt\030\006 \001(\003\022\r\n\005extra\030\007 \001(\t\022\r\n\005" +
"state\030\010 \001(\005\"F\n\034GetChatroomMemberInfoRequ" +
"est\022\023\n\013chatroom_id\030\001 \002(\t\022\021\n\tmax_count\030\002 " +
"\001(\005\";\n\022ChatroomMemberInfo\022\024\n\014member_coun" +
"t\030\001 \001(\005\022\017\n\007members\030\002 \003(\t\"\026\n\010INT64Buf\022\n\n\002" +
"id\030\001 \002(\003\"4\n\023NotifyRecallMessage\022\n\n\002id\030\001 ",
"\002(\003\022\021\n\tfrom_user\030\002 \002(\t\"/\n\020BlackUserReque" +
"st\022\013\n\003uid\030\001 \002(\t\022\016\n\006status\030\002 \002(\005\"\323\001\n\014Rout" +
"eRequest\022\013\n\003app\030\001 \001(\t\022\020\n\010platform\030\002 \001(\005\022" +
"\021\n\tpush_type\030\003 \001(\005\022\023\n\013device_name\030\004 \001(\t\022" +
"\026\n\016device_version\030\005 \001(\t\022\022\n\nphone_name\030\006 " +
"\001(\t\022\020\n\010language\030\007 \001(\t\022\024\n\014carrier_name\030\010 " +
"\001(\t\022\023\n\013app_version\030\t \001(\t\022\023\n\013sdk_version\030" +
"\n \001(\t\"D\n\rRouteResponse\022\014\n\004host\030\001 \002(\t\022\021\n\t" +
"long_port\030\002 \002(\005\022\022\n\nshort_port\030\003 \002(\005\"5\n\017G" +
"etTokenRequest\022\017\n\007user_id\030\001 \002(\t\022\021\n\tclien",
"t_id\030\002 \002(\t\"\\\n\022LoadRemoteMessages\022#\n\014conv" +
"ersation\030\001 \002(\0132\r.Conversation\022\022\n\nbefore_" +
"uid\030\002 \002(\003\022\r\n\005count\030\003 \002(\005\"a\n\020MultiCastMes" +
"sage\022\021\n\tfrom_user\030\001 \002(\t\022 \n\007content\030\002 \002(\013" +
"2\017.MessageContent\022\n\n\002to\030\003 \003(\t\022\014\n\004line\030\004 " +
"\002(\005B#\n\025cn.wildfirechat.protoB\nWFCMessage"
"ial\030\014 \001(\t\022\014\n\004type\030\r \001(\005\022\017\n\007deleted\030\016 \001(\005" +
"\"c\n\005Robot\022\013\n\003uid\030\001 \002(\t\022\r\n\005state\030\002 \002(\005\022\r\n" +
"\005owner\030\003 \001(\t\022\016\n\006secret\030\004 \001(\t\022\020\n\010callback" +
"\030\005 \001(\t\022\r\n\005extra\030\006 \001(\t\"(\n\017GetRobotsResult",
"\022\025\n\005entry\030\001 \003(\0132\006.Robot\"P\n\005Thing\022\013\n\003uid\030" +
"\001 \002(\t\022\r\n\005state\030\002 \002(\005\022\r\n\005token\030\003 \002(\t\022\r\n\005o" +
"wner\030\004 \001(\t\022\r\n\005extra\030\005 \001(\t\"(\n\017GetThingsRe" +
"sult\022\025\n\005entry\030\001 \003(\0132\006.Thing\"g\n\030UploadDev" +
"iceTokenRequest\022\020\n\010platform\030\001 \002(\005\022\020\n\010app" +
"_name\030\002 \002(\t\022\024\n\014device_token\030\003 \002(\t\022\021\n\tpus" +
"h_type\030\004 \002(\005\"\201\001\n\026ModifyGroupInfoRequest\022" +
"\020\n\010group_id\030\001 \002(\t\022\014\n\004type\030\002 \002(\005\022\r\n\005value" +
"\030\003 \002(\t\022\017\n\007to_line\030\004 \003(\005\022\'\n\016notify_conten" +
"t\030\005 \001(\0132\017.MessageContent\"\203\001\n\026SetGroupMan",
"agerRequest\022\020\n\010group_id\030\001 \002(\t\022\014\n\004type\030\002 " +
"\002(\005\022\017\n\007user_id\030\003 \003(\t\022\017\n\007to_line\030\004 \003(\005\022\'\n" +
"\016notify_content\030\005 \001(\0132\017.MessageContent\"(" +
"\n\tInfoEntry\022\014\n\004type\030\001 \002(\005\022\r\n\005value\030\002 \002(\t" +
"\"0\n\023ModifyMyInfoRequest\022\031\n\005entry\030\001 \003(\0132\n" +
".InfoEntry\";\n\rNotifyMessage\022\014\n\004type\030\001 \002(" +
"\005\022\014\n\004head\030\002 \002(\003\022\016\n\006target\030\003 \001(\t\"=\n\022PullM" +
"essageRequest\022\n\n\002id\030\001 \002(\003\022\014\n\004type\030\002 \002(\005\022" +
"\r\n\005delay\030\003 \001(\003\"M\n\021PullMessageResult\022\031\n\007m" +
"essage\030\001 \003(\0132\010.Message\022\017\n\007current\030\002 \002(\003\022",
"\014\n\004head\030\003 \002(\003\"/\n\023PullGroupInfoResult\022\030\n\004" +
"info\030\001 \003(\0132\n.GroupInfo\"6\n\026PullGroupMembe" +
"rRequest\022\016\n\006target\030\001 \002(\t\022\014\n\004head\030\002 \002(\003\"5" +
"\n\025PullGroupMemberResult\022\034\n\006member\030\001 \003(\0132" +
"\014.GroupMember\"-\n\013UserRequest\022\013\n\003uid\030\001 \002(" +
"\t\022\021\n\tupdate_dt\030\002 \001(\003\"0\n\017PullUserRequest\022" +
"\035\n\007request\030\001 \003(\0132\014.UserRequest\"/\n\nUserRe" +
"sult\022\023\n\004user\030\001 \002(\0132\005.User\022\014\n\004code\030\002 \002(\005\"" +
"-\n\016PullUserResult\022\033\n\006result\030\001 \003(\0132\013.User" +
"Result\"^\n\020QuitGroupRequest\022\020\n\010group_id\030\001",
" \002(\t\022\017\n\007to_line\030\002 \003(\005\022\'\n\016notify_content\030" +
"\003 \001(\0132\017.MessageContent\"~\n\030RemoveGroupMem" +
"berRequest\022\020\n\010group_id\030\001 \002(\t\022\026\n\016removed_" +
"member\030\002 \003(\t\022\017\n\007to_line\030\003 \003(\005\022\'\n\016notify_" +
"content\030\004 \001(\0132\017.MessageContent\"u\n\024Transf" +
"erGroupRequest\022\020\n\010group_id\030\001 \002(\t\022\021\n\tnew_" +
"owner\030\002 \002(\t\022\017\n\007to_line\030\003 \003(\005\022\'\n\016notify_c" +
"ontent\030\004 \001(\0132\017.MessageContent\"s\n\026ModifyG" +
"roupMemberAlias\022\020\n\010group_id\030\001 \002(\t\022\r\n\005ali" +
"as\030\002 \002(\t\022\017\n\007to_line\030\003 \003(\005\022\'\n\016notify_cont",
"ent\030\004 \001(\0132\017.MessageContent\"P\n\020UserSettin" +
"gEntry\022\r\n\005scope\030\001 \002(\005\022\013\n\003key\030\002 \002(\t\022\r\n\005va" +
"lue\030\003 \002(\t\022\021\n\tupdate_dt\030\004 \002(\003\"A\n\024ModifyUs" +
"erSettingReq\022\r\n\005scope\030\001 \002(\005\022\013\n\003key\030\002 \002(\t" +
"\022\r\n\005value\030\003 \002(\t\"\032\n\007Version\022\017\n\007version\030\001 " +
"\002(\003\"8\n\024GetUserSettingResult\022 \n\005entry\030\001 \003" +
"(\0132\021.UserSettingEntry\"W\n\006Friend\022\013\n\003uid\030\001" +
" \002(\t\022\r\n\005state\030\002 \002(\005\022\021\n\tupdate_dt\030\003 \002(\003\022\r" +
"\n\005alias\030\004 \001(\t\022\017\n\007blacked\030\005 \001(\005\"*\n\020GetFri" +
"endsResult\022\026\n\005entry\030\001 \003(\0132\007.Friend\"7\n\026Ge",
"tFriendRequestResult\022\035\n\005entry\030\001 \003(\0132\016.Fr" +
"iendRequest\"\243\001\n\021ConnectAckPayload\022\020\n\010msg" +
"_head\030\001 \001(\003\022\023\n\013friend_head\030\002 \001(\003\022\026\n\016frie" +
"nd_rq_head\030\003 \001(\003\022\024\n\014setting_head\030\004 \001(\003\022\021" +
"\n\tnode_addr\030\005 \001(\t\022\021\n\tnode_port\030\006 \001(\005\022\023\n\013" +
"server_time\030\007 \001(\003\"P\n\rIMHttpWrapper\022\r\n\005to" +
"ken\030\001 \002(\t\022\021\n\tclient_id\030\002 \002(\t\022\017\n\007request\030" +
"\003 \002(\t\022\014\n\004data\030\004 \001(\014\"A\n\021SearchUserRequest" +
"\022\017\n\007keyword\030\001 \002(\t\022\r\n\005fuzzy\030\002 \001(\005\022\014\n\004page" +
"\030\003 \001(\005\"(\n\020SearchUserResult\022\024\n\005entry\030\001 \003(",
"\0132\005.User\"@\n\026GetChatroomInfoRequest\022\023\n\013ch" +
"atroom_id\030\001 \002(\t\022\021\n\tupdate_dt\030\002 \001(\003\"\227\001\n\014C" +
"hatroomInfo\022\r\n\005title\030\001 \002(\t\022\014\n\004desc\030\002 \001(\t" +
"\022\020\n\010portrait\030\003 \001(\t\022\024\n\014member_count\030\004 \001(\005" +
"\022\021\n\tcreate_dt\030\005 \001(\003\022\021\n\tupdate_dt\030\006 \001(\003\022\r" +
"\n\005extra\030\007 \001(\t\022\r\n\005state\030\010 \001(\005\"F\n\034GetChatr" +
"oomMemberInfoRequest\022\023\n\013chatroom_id\030\001 \002(" +
"\t\022\021\n\tmax_count\030\002 \001(\005\";\n\022ChatroomMemberIn" +
"fo\022\024\n\014member_count\030\001 \001(\005\022\017\n\007members\030\002 \003(" +
"\t\"\026\n\010INT64Buf\022\n\n\002id\030\001 \002(\003\"4\n\023NotifyRecal",
"lMessage\022\n\n\002id\030\001 \002(\003\022\021\n\tfrom_user\030\002 \002(\t\"" +
"/\n\020BlackUserRequest\022\013\n\003uid\030\001 \002(\t\022\016\n\006stat" +
"us\030\002 \002(\005\"\323\001\n\014RouteRequest\022\013\n\003app\030\001 \001(\t\022\020" +
"\n\010platform\030\002 \001(\005\022\021\n\tpush_type\030\003 \001(\005\022\023\n\013d" +
"evice_name\030\004 \001(\t\022\026\n\016device_version\030\005 \001(\t" +
"\022\022\n\nphone_name\030\006 \001(\t\022\020\n\010language\030\007 \001(\t\022\024" +
"\n\014carrier_name\030\010 \001(\t\022\023\n\013app_version\030\t \001(" +
"\t\022\023\n\013sdk_version\030\n \001(\t\"D\n\rRouteResponse\022" +
"\014\n\004host\030\001 \002(\t\022\021\n\tlong_port\030\002 \002(\005\022\022\n\nshor" +
"t_port\030\003 \002(\005\"G\n\017GetTokenRequest\022\017\n\007user_",
"id\030\001 \002(\t\022\021\n\tclient_id\030\002 \002(\t\022\020\n\010platform\030" +
"\003 \001(\005\"\\\n\022LoadRemoteMessages\022#\n\014conversat" +
"ion\030\001 \002(\0132\r.Conversation\022\022\n\nbefore_uid\030\002" +
" \002(\003\022\r\n\005count\030\003 \002(\005\"a\n\020MultiCastMessage\022" +
"\021\n\tfrom_user\030\001 \002(\t\022 \n\007content\030\002 \002(\0132\017.Me" +
"ssageContent\022\n\n\002to\030\003 \003(\t\022\014\n\004line\030\004 \002(\005B#" +
"\n\025cn.wildfirechat.protoB\nWFCMessage"
};
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
@@ -60530,7 +60693,7 @@ public final class WFCMessage {
internal_static_User_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_User_descriptor,
new java.lang.String[] { "Uid", "Name", "DisplayName", "Portrait", "Mobile", "Email", "Address", "Company", "Extra", "UpdateDt", "Gender", "Social", "Type", });
new java.lang.String[] { "Uid", "Name", "DisplayName", "Portrait", "Mobile", "Email", "Address", "Company", "Extra", "UpdateDt", "Gender", "Social", "Type", "Deleted", });
internal_static_Robot_descriptor =
getDescriptor().getMessageTypes().get(26);
internal_static_Robot_fieldAccessorTable = new
@@ -60794,7 +60957,7 @@ public final class WFCMessage {
internal_static_GetTokenRequest_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_GetTokenRequest_descriptor,
new java.lang.String[] { "UserId", "ClientId", });
new java.lang.String[] { "UserId", "ClientId", "Platform", });
internal_static_LoadRemoteMessages_descriptor =
getDescriptor().getMessageTypes().get(70);
internal_static_LoadRemoteMessages_fieldAccessorTable = new
+1 -1
View File
@@ -6,7 +6,7 @@
<!--<relativePath>../pom.xml</relativePath>-->
<artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId>
<version>0.30</version>
<version>0.36</version>
</parent>
<artifactId>distribution</artifactId>
@@ -49,6 +49,9 @@ message.roaming 0
##是否开启拉取远程历史消息
message.remote_history_message 0
##服务器为每个用户缓存的消息数量。这个值改得太大,拉取消息时间变长,另外会占用大量内存。
message.max_queue 1024
#*********************************************************************
# hazelcase configuration
#*********************************************************************
@@ -95,6 +98,10 @@ qiniu.bucket_favorite_domain http://cdn2.wildfirechat.cn
# 本地媒体服务器配置。
local.media.storage.root ./media
# 是否支持多端登陆
server.multi_endpoint false
#*********************************************************************
# Push server configuration
#*********************************************************************
+1 -1
View File
@@ -12,7 +12,7 @@
<artifactId>wildfirechat-parent</artifactId>
<packaging>pom</packaging>
<version>0.30</version>
<version>0.36</version>
<name>Wildfire Chat</name>
<description>Wildfire Chat Server</description>
<inceptionYear>2019</inceptionYear>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId>
<version>0.30</version>
<version>0.36</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Some files were not shown because too many files have changed in this diff Show More