Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d6d3eba8e6 | ||
|
|
19bd5e83e5 | ||
|
|
2cbbf0a516 | ||
|
|
f6e8cd4ca8 | ||
|
|
da74b9fa94 |
+1
-1
@@ -5,7 +5,7 @@
|
||||
<relativePath>../</relativePath>
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.54</version>
|
||||
<version>0.55</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>moquette-broker</artifactId>
|
||||
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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.common.IMExceptionEvent;
|
||||
import cn.wildfirechat.pojos.InputOutputUserInfo;
|
||||
import cn.wildfirechat.pojos.InputUpdateUserInfo;
|
||||
import cn.wildfirechat.pojos.OutputCreateUser;
|
||||
import cn.wildfirechat.proto.ProtoConstants;
|
||||
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 org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import win.liyufan.im.UUIDGenerator;
|
||||
import win.liyufan.im.Utility;
|
||||
|
||||
@Route(APIPath.Update_User)
|
||||
@HttpMethod("POST")
|
||||
public class UpdateUserAction extends AdminAction {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(UpdateUserAction.class);
|
||||
|
||||
@Override
|
||||
public boolean isTransactionAction() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputUpdateUserInfo inputCreateUser = getRequestBody(request.getNettyRequest(), InputUpdateUserInfo.class);
|
||||
if (inputCreateUser != null
|
||||
&& inputCreateUser.userInfo != null
|
||||
&& !StringUtil.isNullOrEmpty(inputCreateUser.userInfo.getUserId())
|
||||
&& inputCreateUser.flag > 0) {
|
||||
|
||||
ErrorCode errorCode = messagesStore.updateUserInfo(inputCreateUser.userInfo, inputCreateUser.flag);
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(errorCode);
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1555,6 +1555,35 @@ public class DatabaseStore {
|
||||
}
|
||||
}
|
||||
|
||||
void clearMultiUser(String uid, String clientId) {
|
||||
long start = System.currentTimeMillis();
|
||||
LOG.info("clearMultiUser {}, {}", uid, clientId);
|
||||
Connection connection = null;
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
connection = DBUtil.getConnection();
|
||||
String sql = "update t_user_session set _deleted = ?, _token = ?, _voip_token = ?, _dt = ? where _cid = ? and _uid <> ? 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++, clientId);
|
||||
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, RDBS_Exception);
|
||||
} finally {
|
||||
DBUtil.closeDB(connection, statement);
|
||||
}
|
||||
}
|
||||
|
||||
MemorySessionStore.Session createSession(String uid, String clientId, ClientSession clientSession, int platform) {
|
||||
Connection connection = null;
|
||||
PreparedStatement statement = null;
|
||||
|
||||
@@ -59,6 +59,7 @@ import static cn.wildfirechat.proto.ProtoConstants.ModifyChannelInfoType.*;
|
||||
import static cn.wildfirechat.proto.ProtoConstants.ModifyGroupInfoType.*;
|
||||
import static cn.wildfirechat.proto.ProtoConstants.PersistFlag.Transparent;
|
||||
import static cn.wildfirechat.proto.ProtoConstants.Platform.*;
|
||||
import static cn.wildfirechat.proto.ProtoConstants.UpdateUserInfoMask.*;
|
||||
import static io.moquette.BrokerConstants.*;
|
||||
import static io.moquette.server.Constants.MAX_CHATROOM_MESSAGE_QUEUE;
|
||||
import static io.moquette.server.Constants.MAX_MESSAGE_QUEUE;
|
||||
@@ -2127,6 +2128,56 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorCode updateUserInfo(InputOutputUserInfo userInfo, int flag) {
|
||||
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
||||
IMap<String, WFCMessage.User> mUserMap = hzInstance.getMap(USERS);
|
||||
WFCMessage.User user = mUserMap.get(userInfo.getUserId());
|
||||
if(user == null) {
|
||||
return ErrorCode.ERROR_CODE_NOT_EXIST;
|
||||
}
|
||||
WFCMessage.User.Builder builder = user.toBuilder();
|
||||
if((flag & Update_User_DisplayName) > 0) {
|
||||
builder.setDisplayName(userInfo.getDisplayName());
|
||||
}
|
||||
if((flag & Update_User_Portrait) > 0) {
|
||||
builder.setPortrait(userInfo.getPortrait());
|
||||
}
|
||||
if((flag & Update_User_Gender) > 0) {
|
||||
builder.setGender(userInfo.getGender());
|
||||
}
|
||||
if((flag & Update_User_Mobile) > 0) {
|
||||
builder.setMobile(userInfo.getMobile());
|
||||
}
|
||||
if((flag & Update_User_Email) > 0) {
|
||||
builder.setEmail(userInfo.getEmail());
|
||||
}
|
||||
if((flag & Update_User_Address) > 0) {
|
||||
builder.setAddress(userInfo.getAddress());
|
||||
}
|
||||
if((flag & Update_User_Company) > 0) {
|
||||
builder.setCompany(userInfo.getCompany());
|
||||
}
|
||||
if((flag & Update_User_Social) > 0) {
|
||||
builder.setSocial(userInfo.getSocial());
|
||||
}
|
||||
if((flag & Update_User_Extra) > 0) {
|
||||
builder.setExtra(userInfo.getExtra());
|
||||
}
|
||||
builder.setUpdateDt(System.currentTimeMillis());
|
||||
user = builder.build();
|
||||
try {
|
||||
databaseStore.updateUser(user);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return ErrorCode.ERROR_CODE_SERVER_ERROR;
|
||||
}
|
||||
|
||||
mUserMap.put(user.getUid(), user);
|
||||
callbackUserInfoEvent(user);
|
||||
return ErrorCode.ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addUserInfo(WFCMessage.User user, String password) throws Exception {
|
||||
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
||||
|
||||
@@ -375,7 +375,7 @@ public class MemorySessionStore implements ISessionsStore {
|
||||
session.setPlatform(platform);
|
||||
databaseStore.updateSessionPlatform(username, clientID, platform);
|
||||
}
|
||||
|
||||
databaseStore.clearMultiUser(username, clientID);
|
||||
|
||||
if (!supportMultiEndpoint && platform > 0) {
|
||||
databaseStore.clearMultiEndpoint(username, clientID, platform);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package io.moquette.spi;
|
||||
|
||||
import cn.wildfirechat.pojos.InputOutputUserInfo;
|
||||
import cn.wildfirechat.pojos.SystemSettingPojo;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.xiaoleilu.loServer.model.FriendData;
|
||||
@@ -142,6 +143,7 @@ public interface IMessagesStore {
|
||||
int getUserStatus(String userId);
|
||||
List<InputOutputUserBlockStatus> getUserStatusList();
|
||||
|
||||
ErrorCode updateUserInfo(InputOutputUserInfo userInfo, int flag);
|
||||
void addUserInfo(WFCMessage.User user, String password) throws Exception;
|
||||
void destoryUser(String userId);
|
||||
void updateUserInfo(WFCMessage.User user) throws Exception;
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.54</version>
|
||||
<version>0.55</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ public interface APIPath {
|
||||
String Sensitive_Query = "/admin/sensitive/query";
|
||||
|
||||
String Create_User = "/admin/user/create";
|
||||
String Update_User = "/admin/user/update";
|
||||
String Destroy_User = "/admin/user/destroy";
|
||||
String Create_Robot = "/admin/robot/create";
|
||||
String CreateOrUpdate_Device = "/admin/device/create";
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <[email protected]>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package cn.wildfirechat.pojos;
|
||||
|
||||
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
|
||||
public class InputUpdateUserInfo {
|
||||
//UpdateUserInfoMask
|
||||
public int flag;
|
||||
public InputOutputUserInfo userInfo;
|
||||
}
|
||||
@@ -201,6 +201,19 @@ public class ProtoConstants {
|
||||
int Chatroom_Member_Event_Unmute = 4;
|
||||
}
|
||||
|
||||
public interface UpdateUserInfoMask {
|
||||
int Update_User_DisplayName = 0x01;
|
||||
int Update_User_Portrait = 0x02;
|
||||
int Update_User_Gender = 0x04;
|
||||
int Update_User_Mobile = 0x08;
|
||||
int Update_User_Email = 0x10;
|
||||
int Update_User_Address = 0x20;
|
||||
int Update_User_Company = 0x40;
|
||||
int Update_User_Social = 0x80;
|
||||
int Update_User_Extra = 0x100;
|
||||
}
|
||||
|
||||
|
||||
public static final int MESSAGE_CONTENT_TYPE_CREATE_GROUP = 104;
|
||||
public static final int MESSAGE_CONTENT_TYPE_ADD_GROUP_MEMBER = 105;
|
||||
public static final int MESSAGE_CONTENT_TYPE_KICKOF_GROUP_MEMBER = 106;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<!--<relativePath>../pom.xml</relativePath>-->
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.54</version>
|
||||
<version>0.55</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>distribution</artifactId>
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
@ECHO OFF
|
||||
|
||||
set "CURRENT_DIR=%cd%"
|
||||
if not "%WILDFIRECHAT_HOME%" == "" goto gotHome
|
||||
set "WILDFIRECHAT_HOME=%CURRENT_DIR%"
|
||||
if exist "%WILDFIRECHAT_HOME%\bin\wildfirechat.bat" goto okHome
|
||||
cd ..
|
||||
set "WILDFIRECHAT_HOME=%cd%"
|
||||
cd "%CURRENT_DIR%"
|
||||
set "CURRENT_DIR=%cd%"
|
||||
:gotHome
|
||||
if exist "%WILDFIRECHAT_HOME%\bin\wildfirechat.bat" goto okHome
|
||||
echo The WILDFIRECHAT_HOME environment variable is not defined correctly
|
||||
|
||||
@@ -11,11 +11,14 @@ while [ -h "$PRG" ]; do
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`/"$link"
|
||||
PRGDIR=`dirname "$PRG"`
|
||||
cd $PRGDIR
|
||||
PRG="`pwd`"/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
PRGDIR=`dirname "$PRG"`
|
||||
cd $PRGDIR
|
||||
cd ..
|
||||
WILDFIRECHAT_HOME=`pwd`
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
|
||||
<packaging>pom</packaging>
|
||||
<version>0.54</version>
|
||||
<version>0.55</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.54</version>
|
||||
<version>0.55</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -134,6 +134,43 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
InputOutputUserInfo updateUserInfo = new InputOutputUserInfo();
|
||||
updateUserInfo.setUserId(System.currentTimeMillis()+"");
|
||||
updateUserInfo.setDisplayName("updatedUserName");
|
||||
updateUserInfo.setPortrait("updatedUserPortrait");
|
||||
int updateUserFlag = ProtoConstants.UpdateUserInfoMask.Update_User_DisplayName | ProtoConstants.UpdateUserInfoMask.Update_User_Portrait;
|
||||
IMResult<Void> result = UserAdmin.updateUserInfo(updateUserInfo, updateUserFlag);
|
||||
if(result != null && result.getErrorCode() == ErrorCode.ERROR_CODE_NOT_EXIST) {
|
||||
System.out.println("updateUserInfo success");
|
||||
} else {
|
||||
System.out.println("updateUserInfo failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
updateUserInfo.setUserId(userInfo.getUserId());
|
||||
result = UserAdmin.updateUserInfo(updateUserInfo, updateUserFlag);
|
||||
if(result != null && result.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("updateUserInfo success");
|
||||
} else {
|
||||
System.out.println("updateUserInfo failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
IMResult<InputOutputUserInfo> resultGetUserInfo4 = UserAdmin.getUserByUserId(userInfo.getUserId());
|
||||
if (resultGetUserInfo4 != null && resultGetUserInfo4.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
if (userInfo.getUserId().equals(resultGetUserInfo4.getResult().getUserId())
|
||||
&& updateUserInfo.getDisplayName().equals(resultGetUserInfo4.getResult().getDisplayName())
|
||||
&& updateUserInfo.getPortrait().equals(resultGetUserInfo4.getResult().getPortrait())) {
|
||||
System.out.println("get user info success");
|
||||
} else {
|
||||
System.out.println("get user info by userId failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
} else {
|
||||
System.out.println("get user info by userId failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
IMResult<OutputGetIMTokenData> resultGetToken = UserAdmin.getUserToken(userInfo.getUserId(), "client111", ProtoConstants.Platform.Platform_Android);
|
||||
if (resultGetToken != null && resultGetToken.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("get token success: " + resultGetToken.getResult().getToken());
|
||||
@@ -255,7 +292,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
IMResult<Void> result = RelationAdmin.sendFrienRequest("ff1", "ff2", "hello", true);
|
||||
IMResult<Void> result = RelationAdmin.sendFriendRequest("ff1", "ff2", "hello", true);
|
||||
if (result != null && result.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("send friend request success");
|
||||
} else {
|
||||
@@ -263,7 +300,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
result = RelationAdmin.sendFrienRequest("ff1", "ff2", "hello2", false);
|
||||
result = RelationAdmin.sendFriendRequest("ff1", "ff2", "hello2", false);
|
||||
if (result != null && result.getErrorCode() != ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("success");
|
||||
} else {
|
||||
@@ -271,7 +308,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
result = RelationAdmin.sendFrienRequest("ff1", "ff2", "hello3", true);
|
||||
result = RelationAdmin.sendFriendRequest("ff1", "ff2", "hello3", true);
|
||||
if (result != null && result.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("success");
|
||||
} else {
|
||||
|
||||
@@ -56,7 +56,7 @@ public class RelationAdmin {
|
||||
return AdminHttpUtils.httpJsonPost(path, input, OutputGetAlias.class);
|
||||
}
|
||||
|
||||
public static IMResult<Void> sendFrienRequest(String userId, String targetId, String reason, boolean force) throws Exception {
|
||||
public static IMResult<Void> sendFriendRequest(String userId, String targetId, String reason, boolean force) throws Exception {
|
||||
String path = APIPath.Friend_Send_Request;
|
||||
InputAddFriendRequest input = new InputAddFriendRequest();
|
||||
input.setUserId(userId);
|
||||
|
||||
@@ -29,6 +29,14 @@ public class UserAdmin {
|
||||
return AdminHttpUtils.httpJsonPost(path, user, OutputCreateUser.class);
|
||||
}
|
||||
|
||||
public static IMResult<Void> updateUserInfo(InputOutputUserInfo user, int/*UpdateUserInfoMask*/ flag) throws Exception {
|
||||
String path = APIPath.Update_User;
|
||||
InputUpdateUserInfo updateUserInfo = new InputUpdateUserInfo();
|
||||
updateUserInfo.flag = flag;
|
||||
updateUserInfo.userInfo = user;
|
||||
return AdminHttpUtils.httpJsonPost(path, updateUserInfo, Void.class);
|
||||
}
|
||||
|
||||
public static IMResult<OutputCreateRobot> createRobot(InputCreateRobot robot) throws Exception {
|
||||
String path = APIPath.Create_Robot;
|
||||
return AdminHttpUtils.httpJsonPost(path, robot, OutputCreateRobot.class);
|
||||
|
||||
Reference in New Issue
Block a user