退出群组时,删掉群相关用户设置
This commit is contained in:
@@ -911,6 +911,40 @@ public class DatabaseStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void removeGroupUserSettings(String groupId, List<String> users) {
|
||||||
|
Connection connection = null;
|
||||||
|
PreparedStatement statement = null;
|
||||||
|
try {
|
||||||
|
connection = DBUtil.getConnection();
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder("delete t_user_setting where _scope in (1,3,5,7) and _uid in (");
|
||||||
|
for (int i = 0; i < users.size(); i++) {
|
||||||
|
sb.append("?");
|
||||||
|
if (i != users.size() - 1) {
|
||||||
|
sb.append(",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sb.append(") and _key like '1-_-?'");
|
||||||
|
|
||||||
|
|
||||||
|
statement = connection.prepareStatement(sb.toString());
|
||||||
|
int index = 1;
|
||||||
|
for (String userId:users) {
|
||||||
|
statement.setString(index++, userId);
|
||||||
|
}
|
||||||
|
statement.setString(index++, groupId);
|
||||||
|
|
||||||
|
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 persistGroupInfo(final WFCMessage.GroupInfo groupInfo) {
|
void persistGroupInfo(final WFCMessage.GroupInfo groupInfo) {
|
||||||
mScheduler.execute(()->{
|
mScheduler.execute(()->{
|
||||||
Connection connection = null;
|
Connection connection = null;
|
||||||
|
|||||||
@@ -758,7 +758,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
removeFavGroup(groupId, removedIds);
|
removeFavGroup(groupId, removedIds);
|
||||||
|
removeGroupUserSettings(groupId, removedIds);
|
||||||
return ErrorCode.ERROR_CODE_SUCCESS;
|
return ErrorCode.ERROR_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -827,9 +827,21 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
removeFavGroup(groupId, Arrays.asList(operator));
|
removeFavGroup(groupId, Arrays.asList(operator));
|
||||||
|
removeGroupUserSettings(groupId, Arrays.asList(operator));
|
||||||
return ErrorCode.ERROR_CODE_SUCCESS;
|
return ErrorCode.ERROR_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void removeGroupUserSettings(String groupId, List<String> users) {
|
||||||
|
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
||||||
|
MultiMap<String, WFCMessage.UserSettingEntry> userSettingMap = hzInstance.getMultiMap(USER_SETTING);
|
||||||
|
|
||||||
|
databaseStore.removeGroupUserSettings(groupId, users);
|
||||||
|
for (String userId:users) {
|
||||||
|
userSettingMap.remove(userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ErrorCode dismissGroup(String operator, String groupId, boolean isAdmin) {
|
public ErrorCode dismissGroup(String operator, String groupId, boolean isAdmin) {
|
||||||
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
||||||
@@ -869,6 +881,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
removeFavGroup(groupId, ids);
|
removeFavGroup(groupId, ids);
|
||||||
|
removeGroupUserSettings(groupId, ids);
|
||||||
|
|
||||||
return ErrorCode.ERROR_CODE_SUCCESS;
|
return ErrorCode.ERROR_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user