Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6c5354d17b | ||
|
|
c98bd1fb9b | ||
|
|
fe525e9483 | ||
|
|
6acea9b140 | ||
|
|
4beb573052 | ||
|
|
220e010193 | ||
|
|
865888824c | ||
|
|
583df110fd | ||
|
|
f204bd693e | ||
|
|
b6be1ca045 | ||
|
|
beb403a9f7 | ||
|
|
00f1187200 |
@@ -56,3 +56,6 @@ broker/media
|
|||||||
common/target
|
common/target
|
||||||
server/target
|
server/target
|
||||||
sdk/target
|
sdk/target
|
||||||
|
moments/target
|
||||||
|
monitor
|
||||||
|
wildfire_jmeter
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
<relativePath>../</relativePath>
|
<relativePath>../</relativePath>
|
||||||
<artifactId>wildfirechat-parent</artifactId>
|
<artifactId>wildfirechat-parent</artifactId>
|
||||||
<groupId>cn.wildfirechat</groupId>
|
<groupId>cn.wildfirechat</groupId>
|
||||||
<version>0.34</version>
|
<version>0.36</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>moquette-broker</artifactId>
|
<artifactId>moquette-broker</artifactId>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import win.liyufan.im.IMTopic;
|
|||||||
public class GetTokenHandler extends IMHandler<WFCMessage.GetTokenRequest> {
|
public class GetTokenHandler extends IMHandler<WFCMessage.GetTokenRequest> {
|
||||||
@Override
|
@Override
|
||||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.GetTokenRequest request, Qos1PublishHandler.IMCallback callback) {
|
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();
|
TokenAuthenticator authenticator = new TokenAuthenticator();
|
||||||
String strToken = authenticator.generateToken(fromUser);
|
String strToken = authenticator.generateToken(fromUser);
|
||||||
String result = strToken + "|" + session.getSecret() + "|" + session.getDbSecret();
|
String result = strToken + "|" + session.getSecret() + "|" + session.getDbSecret();
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import java.util.List;
|
|||||||
public class UserSearchHandler extends IMHandler<WFCMessage.SearchUserRequest> {
|
public class UserSearchHandler extends IMHandler<WFCMessage.SearchUserRequest> {
|
||||||
@Override
|
@Override
|
||||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.SearchUserRequest request, Qos1PublishHandler.IMCallback callback) {
|
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();
|
WFCMessage.SearchUserResult.Builder builder = WFCMessage.SearchUserResult.newBuilder();
|
||||||
builder.addAllEntry(users);
|
builder.addAllEntry(users);
|
||||||
byte[] data = builder.build().toByteArray();
|
byte[] data = builder.build().toByteArray();
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import java.util.function.Function;
|
|||||||
import static cn.wildfirechat.proto.ProtoConstants.PersistFlag.Transparent;
|
import static cn.wildfirechat.proto.ProtoConstants.PersistFlag.Transparent;
|
||||||
import static io.moquette.persistence.MemoryMessagesStore.USER_STATUS;
|
import static io.moquette.persistence.MemoryMessagesStore.USER_STATUS;
|
||||||
import static io.moquette.server.Constants.MAX_MESSAGE_QUEUE;
|
import static io.moquette.server.Constants.MAX_MESSAGE_QUEUE;
|
||||||
|
import static cn.wildfirechat.proto.ProtoConstants.SearchUserType.*;
|
||||||
|
|
||||||
public class DatabaseStore {
|
public class DatabaseStore {
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(DatabaseStore.class);
|
private static final Logger LOG = LoggerFactory.getLogger(DatabaseStore.class);
|
||||||
@@ -148,8 +149,12 @@ public class DatabaseStore {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
//searchType
|
||||||
List<WFCMessage.User> searchUserFromDB(String keyword, boolean buzzy, int page) {
|
// 0 模糊匹配displayName, 精确匹配账户名和电话号码
|
||||||
|
// 1 精确匹配账户名和电话号码
|
||||||
|
// 2 精确匹配账户名
|
||||||
|
// 3 精确匹配电话号码
|
||||||
|
List<WFCMessage.User> searchUserFromDB(String keyword, int searchType, int page) {
|
||||||
Connection connection = null;
|
Connection connection = null;
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
@@ -169,18 +174,29 @@ public class DatabaseStore {
|
|||||||
", `_social`" +
|
", `_social`" +
|
||||||
", `_extra`" +
|
", `_extra`" +
|
||||||
", `_dt` from t_user";
|
", `_dt` from t_user";
|
||||||
if (buzzy) {
|
switch (searchType) {
|
||||||
sql += " where (`_display_name` like ? or `_name` = ? or `_mobile` = ?) ";
|
case SearchUserType_Name_Mobile:
|
||||||
} else {
|
sql += " where (`_name` = ? or `_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
|
sql += " and _type <> 2"; //can search normal user(0) and robot(1), can not search things
|
||||||
|
|
||||||
if (buzzy) {
|
if (searchType == SearchUserType_Name_Mobile || searchType == SearchUserType_Name || searchType == SearchUserType_Mobile) {
|
||||||
sql += " limit 20";
|
|
||||||
} else {
|
|
||||||
sql += " limit 1";
|
sql += " limit 1";
|
||||||
|
} else {
|
||||||
|
sql += " limit 20";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (page > 0) {
|
if (page > 0) {
|
||||||
@@ -190,12 +206,24 @@ public class DatabaseStore {
|
|||||||
|
|
||||||
statement = connection.prepareStatement(sql);
|
statement = connection.prepareStatement(sql);
|
||||||
int index = 1;
|
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();
|
rs = statement.executeQuery();
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
@@ -1011,78 +1039,76 @@ public class DatabaseStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void persistGroupInfo(final WFCMessage.GroupInfo groupInfo) {
|
void persistGroupInfo(final WFCMessage.GroupInfo groupInfo) {
|
||||||
mScheduler.execute(()->{
|
Connection connection = null;
|
||||||
Connection connection = null;
|
PreparedStatement statement = null;
|
||||||
PreparedStatement statement = null;
|
try {
|
||||||
try {
|
connection = DBUtil.getConnection();
|
||||||
connection = DBUtil.getConnection();
|
String sql = "insert into t_group (`_gid`" +
|
||||||
String sql = "insert into t_group (`_gid`" +
|
", `_name`" +
|
||||||
", `_name`" +
|
", `_portrait`" +
|
||||||
", `_portrait`" +
|
", `_owner`" +
|
||||||
", `_owner`" +
|
", `_type`" +
|
||||||
", `_type`" +
|
", `_extra`" +
|
||||||
", `_extra`" +
|
", `_dt`" +
|
||||||
", `_dt`" +
|
", `_member_count`" +
|
||||||
", `_member_count`" +
|
", `_mute`" +
|
||||||
", `_mute`" +
|
", `_join_type`" +
|
||||||
", `_join_type`" +
|
", `_private_chat`" +
|
||||||
", `_private_chat`" +
|
", `_searchable`" +
|
||||||
", `_searchable`" +
|
", `_member_dt`) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" +
|
||||||
", `_member_dt`) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" +
|
" ON DUPLICATE KEY UPDATE " +
|
||||||
" ON DUPLICATE KEY UPDATE " +
|
"`_name` = ?," +
|
||||||
"`_name` = ?," +
|
"`_portrait` = ?," +
|
||||||
"`_portrait` = ?," +
|
"`_owner` = ?," +
|
||||||
"`_owner` = ?," +
|
"`_type` = ?," +
|
||||||
"`_type` = ?," +
|
"`_extra` = ?," +
|
||||||
"`_extra` = ?," +
|
"`_dt` = ?," +
|
||||||
"`_dt` = ?," +
|
"`_member_count` = ?," +
|
||||||
"`_member_count` = ?," +
|
"`_mute` = ?" +
|
||||||
"`_mute` = ?" +
|
", `_join_type` = ?" +
|
||||||
", `_join_type` = ?" +
|
", `_private_chat` = ?" +
|
||||||
", `_private_chat` = ?" +
|
", `_searchable` = ?, " +
|
||||||
", `_searchable` = ?, " +
|
"`_member_dt` = ?";
|
||||||
"`_member_dt` = ?";
|
|
||||||
|
|
||||||
|
|
||||||
statement = connection.prepareStatement(sql);
|
statement = connection.prepareStatement(sql);
|
||||||
|
|
||||||
int index = 1;
|
int index = 1;
|
||||||
statement.setString(index++, groupInfo.getTargetId());
|
statement.setString(index++, groupInfo.getTargetId());
|
||||||
statement.setString(index++, groupInfo.getName());
|
statement.setString(index++, groupInfo.getName());
|
||||||
statement.setString(index++, groupInfo.getPortrait());
|
statement.setString(index++, groupInfo.getPortrait());
|
||||||
statement.setString(index++, groupInfo.getOwner());
|
statement.setString(index++, groupInfo.getOwner());
|
||||||
statement.setInt(index++, groupInfo.getType());
|
statement.setInt(index++, groupInfo.getType());
|
||||||
statement.setString(index++, groupInfo.getExtra());
|
statement.setString(index++, groupInfo.getExtra());
|
||||||
statement.setLong(index++, groupInfo.getUpdateDt() == 0 ? System.currentTimeMillis() : groupInfo.getUpdateDt());
|
statement.setLong(index++, groupInfo.getUpdateDt() == 0 ? System.currentTimeMillis() : groupInfo.getUpdateDt());
|
||||||
statement.setInt(index++, groupInfo.getMemberCount());
|
statement.setInt(index++, groupInfo.getMemberCount());
|
||||||
statement.setInt(index++, groupInfo.getMute());
|
statement.setInt(index++, groupInfo.getMute());
|
||||||
statement.setInt(index++, groupInfo.getJoinType());
|
statement.setInt(index++, groupInfo.getJoinType());
|
||||||
statement.setInt(index++, groupInfo.getPrivateChat());
|
statement.setInt(index++, groupInfo.getPrivateChat());
|
||||||
statement.setInt(index++, groupInfo.getSearchable());
|
statement.setInt(index++, groupInfo.getSearchable());
|
||||||
statement.setLong(index++, groupInfo.getMemberUpdateDt() == 0 ? System.currentTimeMillis() : groupInfo.getUpdateDt());
|
statement.setLong(index++, groupInfo.getMemberUpdateDt() == 0 ? System.currentTimeMillis() : groupInfo.getUpdateDt());
|
||||||
|
|
||||||
statement.setString(index++, groupInfo.getName());
|
statement.setString(index++, groupInfo.getName());
|
||||||
statement.setString(index++, groupInfo.getPortrait());
|
statement.setString(index++, groupInfo.getPortrait());
|
||||||
statement.setString(index++, groupInfo.getOwner());
|
statement.setString(index++, groupInfo.getOwner());
|
||||||
statement.setInt(index++, groupInfo.getType());
|
statement.setInt(index++, groupInfo.getType());
|
||||||
statement.setString(index++, groupInfo.getExtra());
|
statement.setString(index++, groupInfo.getExtra());
|
||||||
statement.setLong(index++, groupInfo.getUpdateDt() == 0 ? System.currentTimeMillis() : groupInfo.getUpdateDt());
|
statement.setLong(index++, groupInfo.getUpdateDt() == 0 ? System.currentTimeMillis() : groupInfo.getUpdateDt());
|
||||||
statement.setInt(index++, groupInfo.getMemberCount());
|
statement.setInt(index++, groupInfo.getMemberCount());
|
||||||
statement.setInt(index++, groupInfo.getMute());
|
statement.setInt(index++, groupInfo.getMute());
|
||||||
statement.setInt(index++, groupInfo.getJoinType());
|
statement.setInt(index++, groupInfo.getJoinType());
|
||||||
statement.setInt(index++, groupInfo.getPrivateChat());
|
statement.setInt(index++, groupInfo.getPrivateChat());
|
||||||
statement.setInt(index++, groupInfo.getSearchable());
|
statement.setInt(index++, groupInfo.getSearchable());
|
||||||
statement.setLong(index++, groupInfo.getMemberUpdateDt() == 0 ? System.currentTimeMillis() : groupInfo.getUpdateDt());
|
statement.setLong(index++, groupInfo.getMemberUpdateDt() == 0 ? System.currentTimeMillis() : groupInfo.getUpdateDt());
|
||||||
int count = statement.executeUpdate();
|
int count = statement.executeUpdate();
|
||||||
LOG.info("Update rows {}", count);
|
LOG.info("Update rows {}", count);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Utility.printExecption(LOG, e);
|
Utility.printExecption(LOG, e);
|
||||||
} finally {
|
} finally {
|
||||||
DBUtil.closeDB(connection, statement);
|
DBUtil.closeDB(connection, statement);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<MemorySessionStore.Session> getUserActivedSessions(String uid) {
|
List<MemorySessionStore.Session> getUserActivedSessions(String uid) {
|
||||||
@@ -1532,39 +1558,37 @@ public class DatabaseStore {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
void updateGroupMemberCountDt(final String groupId, final int count, final long dt) {
|
void updateGroupMemberCountDt(final String groupId, final int count, final long dt) {
|
||||||
mScheduler.execute(()->{
|
Connection connection = null;
|
||||||
Connection connection = null;
|
PreparedStatement statement = null;
|
||||||
PreparedStatement statement = null;
|
try {
|
||||||
try {
|
connection = DBUtil.getConnection();
|
||||||
connection = DBUtil.getConnection();
|
|
||||||
|
|
||||||
String sql ;
|
String sql ;
|
||||||
|
|
||||||
if (count >= 0) {
|
if (count >= 0) {
|
||||||
sql = "update t_group set `_member_count` = ?, `_member_dt` = ? , `_dt` = ? where `_gid` = ?";
|
sql = "update t_group set `_member_count` = ?, `_member_dt` = ? , `_dt` = ? where `_gid` = ?";
|
||||||
} else {
|
} else {
|
||||||
sql = "update t_group set `_member_dt` = ?, `_dt` = ? where `_gid` = ?";
|
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);
|
|
||||||
}
|
}
|
||||||
});
|
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) {
|
void persistGroupMember(final String groupId, final List<WFCMessage.GroupMember> memberList) {
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ import java.sql.PreparedStatement;
|
|||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.locks.Lock;
|
import java.util.concurrent.locks.Lock;
|
||||||
@@ -112,7 +111,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
private final DatabaseStore databaseStore;
|
private final DatabaseStore databaseStore;
|
||||||
private ConcurrentHashMap<String, Long> userMaxPullSeq = new ConcurrentHashMap<>();
|
private ConcurrentHashMap<String, Long> userMaxPullSeq = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private AtomicReference<SensitiveFilter> mSensitiveFilter = new AtomicReference<>();
|
private SensitiveFilter mSensitiveFilter;
|
||||||
private volatile long lastUpdateSensitiveTime = 0;
|
private volatile long lastUpdateSensitiveTime = 0;
|
||||||
|
|
||||||
private ConcurrentHashMap<String, Boolean> userGlobalSlientMap = new ConcurrentHashMap<>();
|
private ConcurrentHashMap<String, Boolean> userGlobalSlientMap = new ConcurrentHashMap<>();
|
||||||
@@ -148,7 +147,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Set<String> sensitiveWords = databaseStore.getSensitiveWord();
|
Set<String> sensitiveWords = databaseStore.getSensitiveWord();
|
||||||
mSensitiveFilter.set(new SensitiveFilter(sensitiveWords));
|
mSensitiveFilter = new SensitiveFilter(sensitiveWords);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -353,6 +352,9 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
|
|
||||||
size += bundle.getMessage().getSerializedSize();
|
size += bundle.getMessage().getSerializedSize();
|
||||||
if (size >= 512 * 1024) { //3M
|
if (size >= 512 * 1024) { //3M
|
||||||
|
if(builder.getMessageCount() == 0){
|
||||||
|
builder.addMessage(bundle.getMessage());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
builder.addMessage(bundle.getMessage());
|
builder.addMessage(bundle.getMessage());
|
||||||
@@ -687,7 +689,11 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
List<WFCMessage.GroupMember> tmp = new ArrayList<>();
|
List<WFCMessage.GroupMember> tmp = new ArrayList<>();
|
||||||
ArrayList<String> newInviteUsers = new ArrayList<>();
|
ArrayList<String> newInviteUsers = new ArrayList<>();
|
||||||
for (WFCMessage.GroupMember member : memberList) {
|
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);
|
tmp.add(member);
|
||||||
newInviteUsers.add(member.getMemberId());
|
newInviteUsers.add(member.getMemberId());
|
||||||
}
|
}
|
||||||
@@ -1492,8 +1498,8 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
return getUserInfo(userId);
|
return getUserInfo(userId);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public List<WFCMessage.User> searchUser(String keyword, boolean buzzy, int page) {
|
public List<WFCMessage.User> searchUser(String keyword, int searchType, int page) {
|
||||||
return databaseStore.searchUserFromDB(keyword, buzzy, page);
|
return databaseStore.searchUserFromDB(keyword, searchType, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2495,7 +2501,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
@Override
|
@Override
|
||||||
public Set<String> handleSensitiveWord(String message) {
|
public Set<String> handleSensitiveWord(String message) {
|
||||||
updateSensitiveWord();
|
updateSensitiveWord();
|
||||||
return mSensitiveFilter.get().getSensitiveWords(message, SensitiveFilter.MatchType.MAX_MATCH);
|
return mSensitiveFilter.getSensitiveWords(message, SensitiveFilter.MatchType.MAX_MATCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -328,15 +328,24 @@ public class MemorySessionStore implements ISessionsStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Session createUserSession(String username, String clientID, int platform) {
|
public Session updateOrCreateUserSession(String username, String clientID, int platform) {
|
||||||
LOG.debug("createUserSession for client <{}>, user <{}>", clientID, username);
|
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);
|
ClientSession clientSession = new ClientSession(clientID, this);
|
||||||
Session session = databaseStore.getSession(username, clientID, clientSession);
|
session = databaseStore.getSession(username, clientID, clientSession);
|
||||||
|
|
||||||
if (session == null) {
|
if (session == null) {
|
||||||
session = databaseStore.createSession(username, clientID, clientSession, platform);
|
session = databaseStore.createSession(username, clientID, clientSession, platform);
|
||||||
}
|
}
|
||||||
|
sessions.put(clientID, session);
|
||||||
|
|
||||||
|
|
||||||
if (session.getDeleted() > 0) {
|
if (session.getDeleted() > 0) {
|
||||||
session.setDeleted(0);
|
session.setDeleted(0);
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ public interface IMessagesStore {
|
|||||||
WFCMessage.User getUserInfo(String userId);
|
WFCMessage.User getUserInfo(String userId);
|
||||||
WFCMessage.User getUserInfoByName(String name);
|
WFCMessage.User getUserInfoByName(String name);
|
||||||
WFCMessage.User getUserInfoByMobile(String mobile);
|
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);
|
boolean updateSystemSetting(int id, String value, String desc);
|
||||||
SystemSettingPojo getSystemSetting(int id);
|
SystemSettingPojo getSystemSetting(int id);
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public interface ISessionsStore {
|
|||||||
*/
|
*/
|
||||||
boolean contains(String clientID);
|
boolean contains(String clientID);
|
||||||
|
|
||||||
Session createUserSession(String username, String clientID, int platform);
|
Session updateOrCreateUserSession(String username, String clientID, int platform);
|
||||||
|
|
||||||
ErrorCode loadActiveSession(String username, String clientID);
|
ErrorCode loadActiveSession(String username, String clientID);
|
||||||
|
|
||||||
|
|||||||
@@ -179,15 +179,16 @@ public class Qos1PublishHandler extends QosPublishHandler {
|
|||||||
MemorySessionStore.Session session = m_sessionStore.getSession(clientID);
|
MemorySessionStore.Session session = m_sessionStore.getSession(clientID);
|
||||||
if (session != null && session.getUsername().equals(fromUser)) {
|
if (session != null && session.getUsername().equals(fromUser)) {
|
||||||
if (data.length > 7*1024 && session.getMqttVersion().protocolLevel() >= MqttVersion.Wildfire_1.protocolLevel()) {
|
if (data.length > 7*1024 && session.getMqttVersion().protocolLevel() >= MqttVersion.Wildfire_1.protocolLevel()) {
|
||||||
try (
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
GZIPOutputStream gzip;
|
||||||
GZIPOutputStream gzip = new GZIPOutputStream(out)
|
try {
|
||||||
) {
|
gzip = new GZIPOutputStream(out);
|
||||||
gzip.write(data);
|
gzip.write(data);
|
||||||
data = out.toByteArray();
|
gzip.close();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
data = out.toByteArray();
|
||||||
code = (byte)ErrorCode.ERROR_CODE_SUCCESS_GZIPED.code;
|
code = (byte)ErrorCode.ERROR_CODE_SUCCESS_GZIPED.code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>wildfirechat-parent</artifactId>
|
<artifactId>wildfirechat-parent</artifactId>
|
||||||
<groupId>cn.wildfirechat</groupId>
|
<groupId>cn.wildfirechat</groupId>
|
||||||
<version>0.34</version>
|
<version>0.36</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -132,6 +132,12 @@ public class ProtoConstants {
|
|||||||
int Group_Max_Member_Count = 1;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<!--<relativePath>../pom.xml</relativePath>-->
|
<!--<relativePath>../pom.xml</relativePath>-->
|
||||||
<artifactId>wildfirechat-parent</artifactId>
|
<artifactId>wildfirechat-parent</artifactId>
|
||||||
<groupId>cn.wildfirechat</groupId>
|
<groupId>cn.wildfirechat</groupId>
|
||||||
<version>0.34</version>
|
<version>0.36</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>distribution</artifactId>
|
<artifactId>distribution</artifactId>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
<artifactId>wildfirechat-parent</artifactId>
|
<artifactId>wildfirechat-parent</artifactId>
|
||||||
|
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<version>0.34</version>
|
<version>0.36</version>
|
||||||
<name>Wildfire Chat</name>
|
<name>Wildfire Chat</name>
|
||||||
<description>Wildfire Chat Server</description>
|
<description>Wildfire Chat Server</description>
|
||||||
<inceptionYear>2019</inceptionYear>
|
<inceptionYear>2019</inceptionYear>
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>wildfirechat-parent</artifactId>
|
<artifactId>wildfirechat-parent</artifactId>
|
||||||
<groupId>cn.wildfirechat</groupId>
|
<groupId>cn.wildfirechat</groupId>
|
||||||
<version>0.34</version>
|
<version>0.36</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user