Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6c5354d17b | ||
|
|
c98bd1fb9b | ||
|
|
fe525e9483 | ||
|
|
6acea9b140 | ||
|
|
4beb573052 | ||
|
|
220e010193 | ||
|
|
865888824c | ||
|
|
583df110fd | ||
|
|
f204bd693e | ||
|
|
b6be1ca045 | ||
|
|
beb403a9f7 | ||
|
|
00f1187200 | ||
|
|
7ee490cc1b | ||
|
|
3dc0ae7a47 | ||
|
|
994a8b5c4a | ||
|
|
5cd2e7affe | ||
|
|
f29ffe4cd2 | ||
|
|
6c7d2ab3ad | ||
|
|
ab7b20871a | ||
|
|
6883418e22 | ||
|
|
32f7266a5f | ||
|
|
35db76e9cd | ||
|
|
4f6aa87b9f | ||
|
|
f5816e20dd | ||
|
|
e72ae59e49 | ||
|
|
f0c2fd82ca | ||
|
|
5a588c8268 | ||
|
|
2adc030d6f | ||
|
|
b0ca8ed2b7 | ||
|
|
f9d5c861ce | ||
|
|
9aaaa71ce9 |
@@ -56,3 +56,6 @@ broker/media
|
||||
common/target
|
||||
server/target
|
||||
sdk/target
|
||||
moments/target
|
||||
monitor
|
||||
wildfire_jmeter
|
||||
|
||||
@@ -58,6 +58,9 @@ message.roaming 0
|
||||
##是否开启拉取远程历史消息
|
||||
message.remote_history_message 0
|
||||
|
||||
##服务器为每个用户缓存的消息数量。这个值改得太大,拉取消息时间变长,另外会占用大量内存。
|
||||
message.max_queue 1024
|
||||
|
||||
#*********************************************************************
|
||||
# hazelcase configuration
|
||||
#*********************************************************************
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
alter table `t_user_session` add column `_deleted` tinyint DEFAULT 0;
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
alter table `t_user` add column `_deleted` tinyint DEFAULT 0;
|
||||
@@ -0,0 +1 @@
|
||||
alter table `t_user_session` add column `_deleted` tinyint DEFAULT 0;
|
||||
+1
@@ -0,0 +1 @@
|
||||
alter table `t_user` add column `_deleted` tinyint DEFAULT 0;
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<relativePath>../</relativePath>
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.32</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, false, 0);
|
||||
ErrorCode errorCode = sessionsStore.loadActiveSession(uid, cid);
|
||||
if (errorCode != ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
sendResponse(response, errorCode, null, base64Response);
|
||||
return true;
|
||||
|
||||
+97
@@ -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;
|
||||
}
|
||||
}
|
||||
+63
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -115,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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, request.getPlatform());
|
||||
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, false, request.getPlatform());
|
||||
m_sessionsStore.loadActiveSession(fromUser, clientID);
|
||||
} else {
|
||||
m_sessionsStore.updateExistSession(fromUser, clientID, request, true);
|
||||
}
|
||||
|
||||
@@ -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,15 +1204,15 @@ 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);
|
||||
DBUtil.closeDB(connection, statement, resultSet);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -1136,6 +1289,35 @@ 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;
|
||||
@@ -1266,13 +1448,19 @@ public class DatabaseStore {
|
||||
String sql;
|
||||
if (platform == ProtoConstants.Platform.Platform_Windows || platform == ProtoConstants.Platform.Platform_OSX
|
||||
|| platform == ProtoConstants.Platform.Platform_iOS || platform == ProtoConstants.Platform.Platform_Android) {
|
||||
sql = "delete from t_user_session where `_uid`=? and (`_platform` = ? or `_platform` = ?) and `_cid` <> ?";
|
||||
sql = "update t_user_session set `_deleted` = ?, `_token` = ?, `_voip_token` = ?, `_dt` = ? where `_uid`=? and (`_platform` = ? or `_platform` = ?) and `_cid` <> ? and `_deleted` = 0";
|
||||
} else {
|
||||
sql = "delete from t_user_session where `_uid`=? and `_platform` = ? and `_cid` <> ?";
|
||||
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) {
|
||||
@@ -1340,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) {
|
||||
@@ -1944,6 +2159,7 @@ public class DatabaseStore {
|
||||
", `_social`=?" +
|
||||
", `_extra`=?" +
|
||||
", `_type`=?" +
|
||||
", `_deleted`=?" +
|
||||
", `_dt`=?";
|
||||
|
||||
statement = connection.prepareStatement(sql);
|
||||
@@ -1977,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();
|
||||
@@ -2103,6 +2320,7 @@ public class DatabaseStore {
|
||||
", `_social`" +
|
||||
", `_extra`" +
|
||||
", `_type`" +
|
||||
", `_deleted`" +
|
||||
", `_dt` from t_user where `_uid` = ?";
|
||||
statement = connection.prepareStatement(sql);
|
||||
|
||||
@@ -2157,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);
|
||||
|
||||
@@ -2224,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);
|
||||
|
||||
|
||||
@@ -2282,6 +2503,52 @@ 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;
|
||||
|
||||
@@ -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
|
||||
@@ -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<>();
|
||||
@@ -1899,7 +1998,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
} else {
|
||||
state = 0;
|
||||
}
|
||||
|
||||
|
||||
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
||||
MultiMap<String, FriendData> friendsMap = hzInstance.getMultiMap(USER_FRIENDS);
|
||||
|
||||
@@ -2189,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);
|
||||
@@ -2246,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();
|
||||
@@ -2531,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());
|
||||
|
||||
@@ -24,9 +24,8 @@ 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;
|
||||
@@ -55,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() {
|
||||
@@ -135,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;
|
||||
@@ -282,7 +294,7 @@ public class MemorySessionStore implements ISessionsStore {
|
||||
while (it.hasNext()) {
|
||||
Session session = it.next().getValue();
|
||||
if (!session.getClientID().equals(cid) && (session.pushType == pushType && token.equals(session.deviceToken))) {
|
||||
session.deviceToken = token;
|
||||
session.deviceToken = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -302,15 +314,43 @@ public class MemorySessionStore implements ISessionsStore {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Session createUserSession(String username, String clientID, int platform) {
|
||||
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, platform);
|
||||
}
|
||||
sessions.put(clientID, session);
|
||||
|
||||
|
||||
if (session.getDeleted() > 0) {
|
||||
session.setDeleted(0);
|
||||
databaseStore.updateSessionDeleted(username, clientID, 0);
|
||||
}
|
||||
|
||||
if (session.getPlatform() != platform) {
|
||||
session.setPlatform(platform);
|
||||
@@ -326,6 +366,10 @@ public class MemorySessionStore implements ISessionsStore {
|
||||
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) {
|
||||
@@ -358,34 +402,29 @@ public class MemorySessionStore implements ISessionsStore {
|
||||
|
||||
|
||||
@Override
|
||||
public ErrorCode createNewSession(String username, String clientID, boolean cleanSession, boolean createWhenNoExist, int platform) {
|
||||
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_SECRECT_KEY_MISMATCH;
|
||||
}
|
||||
|
||||
session = databaseStore.createSession(username, clientID, clientSession, platform);
|
||||
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;
|
||||
@@ -409,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) {
|
||||
@@ -460,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
|
||||
) {
|
||||
@@ -611,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,9 +38,9 @@ public interface ISessionsStore {
|
||||
*/
|
||||
boolean contains(String clientID);
|
||||
|
||||
Session createUserSession(String username, String clientID, int platform);
|
||||
Session updateOrCreateUserSession(String username, String clientID, int platform);
|
||||
|
||||
ErrorCode createNewSession(String username, String clientID, boolean cleanSession, boolean createNoExist, int platform);
|
||||
ErrorCode loadActiveSession(String username, String clientID);
|
||||
|
||||
ClientSession updateExistSession(String username, String clientID, WFCMessage.RouteRequest endpoint, boolean cleanSession);
|
||||
|
||||
@@ -49,6 +49,8 @@ public interface ISessionsStore {
|
||||
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;
|
||||
@@ -181,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) {
|
||||
@@ -270,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, 0);
|
||||
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);
|
||||
|
||||
@@ -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
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.32</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";
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -60355,102 +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\"G\n\017G" +
|
||||
"etTokenRequest\022\017\n\007user_id\030\001 \002(\t\022\021\n\tclien",
|
||||
"t_id\030\002 \002(\t\022\020\n\010platform\030\003 \001(\005\"\\\n\022LoadRemo" +
|
||||
"teMessages\022#\n\014conversation\030\001 \002(\0132\r.Conve" +
|
||||
"rsation\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.MessageContent\022\n\n\002t" +
|
||||
"o\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() {
|
||||
@@ -60612,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
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<!--<relativePath>../pom.xml</relativePath>-->
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.32</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
|
||||
#*********************************************************************
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
|
||||
<packaging>pom</packaging>
|
||||
<version>0.32</version>
|
||||
<version>0.36</version>
|
||||
<name>Wildfire Chat</name>
|
||||
<description>Wildfire Chat Server</description>
|
||||
<inceptionYear>2019</inceptionYear>
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.32</version>
|
||||
<version>0.36</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -113,4 +113,12 @@ public class GroupAdmin {
|
||||
return AdminHttpUtils.httpJsonPost(path, kickoffGroupMember, Void.class);
|
||||
}
|
||||
|
||||
public static IMResult<OutputGroupIds> getUserGroups(String user) throws Exception {
|
||||
String path = APIPath.Get_User_Groups;
|
||||
InputUserId inputUserId = new InputUserId();
|
||||
inputUserId.setUserId(user);
|
||||
return AdminHttpUtils.httpJsonPost(path, inputUserId, OutputGroupIds.class);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -284,6 +284,18 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
IMResult<OutputGroupIds> groupIdsIMResult = GroupAdmin.getUserGroups("user1");
|
||||
if (groupIdsIMResult != null && groupIdsIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
if (groupIdsIMResult.getResult().getGroupIds().contains(groupInfo.getTarget_id())) {
|
||||
System.out.println("get user groups success");
|
||||
} else {
|
||||
System.out.println("get user groups failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
} else {
|
||||
System.out.println("get user groups failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
|
||||
//***********************************************
|
||||
@@ -392,5 +404,14 @@ public class Main {
|
||||
System.out.println("robot get user info by userId failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
|
||||
voidIMResult = UserAdmin.destroyUser("user1");
|
||||
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("destroy user success");
|
||||
} else {
|
||||
System.out.println("destroy user failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,13 @@ public class UserAdmin {
|
||||
return AdminHttpUtils.httpJsonPost(path, null, OutputUserBlockStatusList.class);
|
||||
}
|
||||
|
||||
public static IMResult<Void> destroyUser(String userId) throws Exception {
|
||||
String path = APIPath.Destroy_User;
|
||||
InputDestroyUser inputDestroyUser = new InputDestroyUser();
|
||||
inputDestroyUser.setUserId(userId);
|
||||
return AdminHttpUtils.httpJsonPost(path, inputDestroyUser, Void.class);
|
||||
}
|
||||
|
||||
//not implement
|
||||
// public static IMResult<OutputUserBlockStatusList> getUserOnlineStatus(String userId) throws Exception {
|
||||
// String path = APIPath.User_Get_Online_Status;
|
||||
|
||||
Reference in New Issue
Block a user