添加配置,当删除用户时是否保留用户昵称
This commit is contained in:
@@ -157,6 +157,9 @@ group.visible_quit_or_kickoff_notification 0
|
||||
## 注意,修改本配置不会对已经同步的信息产生影响。
|
||||
#user.hide_properties 3,4,5
|
||||
|
||||
## 销毁用户时,用户信息会被清空,deleted字段设置为1,这个开关控制是否保留用户昵称,默认为true。
|
||||
user.keep_display_name_when_destroy true
|
||||
|
||||
# 好友/好友请求/用户设置 这三类数据同步的最大条目数。之前是客户第一次登录时,会把所有的对应数据一次下载到客户端,但如果有特别多的信息,会导致无法同步到客户端,
|
||||
# 因此需要分段多次同步,此开关定义了每次同步的数据的条数。此需要客户端支持,客户端SDK在2021.5.25日后支持此功能。如果确认所有客户端都在这个日志之后才可以打开此设置。
|
||||
#sync.data_part_size 1000
|
||||
|
||||
@@ -160,6 +160,8 @@ public final class BrokerConstants {
|
||||
public static final String GROUP_Visible_Quit_Kickoff_Notification = "group.visible_quit_or_kickoff_notification";
|
||||
|
||||
public static final String USER_HIDE_PROPERTIES = "user.hide_properties";
|
||||
public static final String USER_KEEP_DISPLAY_NAME_WHEN_DESTROY = "user.keep_display_name_when_destroy";
|
||||
|
||||
public static final String SYNC_Data_Part_Size = "sync.data_part_size";
|
||||
|
||||
public static final String MESSAGES_FORBIDDEN_CLIENT_SEND_TYPES = "message.forbidden_client_send_types";
|
||||
|
||||
@@ -11,9 +11,7 @@ package io.moquette.imhandler;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.proto.ProtoConstants;
|
||||
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;
|
||||
|
||||
@@ -30,7 +28,7 @@ public class DestroyUserHandler extends IMHandler<WFCMessage.IDBuf> {
|
||||
m_messagesStore.clearUserFriend(fromUser);
|
||||
m_messagesStore.clearUserGroups(fromUser);
|
||||
m_messagesStore.clearUserChannels(fromUser);
|
||||
m_messagesStore.destoryUser(fromUser);
|
||||
m_messagesStore.destroyUser(fromUser);
|
||||
|
||||
m_messagesStore.destroyRobot(fromUser);
|
||||
});
|
||||
|
||||
@@ -160,6 +160,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
private boolean mGroupAllowRobotCustomOperationNotification;
|
||||
private int mGroupVisibleQuitKickoffNotification;
|
||||
private int mSyncDataPartSize = 0;
|
||||
private boolean keepDisplayNameWhenDestroyUser = true;
|
||||
|
||||
private Set<Integer> mUserHideProperties = new HashSet<>();
|
||||
|
||||
@@ -418,6 +419,11 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
mSyncDataPartSize = Integer.parseInt(server.getConfig().getProperty(SYNC_Data_Part_Size, "0"));
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
try {
|
||||
keepDisplayNameWhenDestroyUser = Boolean.parseBoolean(server.getConfig().getProperty(USER_KEEP_DISPLAY_NAME_WHEN_DESTROY, "true"));
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -2487,25 +2493,41 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destoryUser(String userId) {
|
||||
public void destroyUser(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())
|
||||
.setName(userId)
|
||||
.setDeleted(1)
|
||||
.clearDisplayName()
|
||||
.clearAddress()
|
||||
.clearCompany()
|
||||
.clearEmail()
|
||||
.clearExtra()
|
||||
.clearMobile()
|
||||
.clearPortrait()
|
||||
.clearSocial()
|
||||
.build();
|
||||
if (keepDisplayNameWhenDestroyUser) {
|
||||
us = WFCMessage.User.newBuilder()
|
||||
.setUid(userId)
|
||||
.setUpdateDt(System.currentTimeMillis())
|
||||
.setName(userId)
|
||||
.setDeleted(1)
|
||||
.clearAddress()
|
||||
.clearCompany()
|
||||
.clearEmail()
|
||||
.clearExtra()
|
||||
.clearMobile()
|
||||
.clearPortrait()
|
||||
.clearSocial()
|
||||
.build();
|
||||
} else {
|
||||
us = WFCMessage.User.newBuilder()
|
||||
.setUid(userId)
|
||||
.setUpdateDt(System.currentTimeMillis())
|
||||
.setName(userId)
|
||||
.setDeleted(1)
|
||||
.clearDisplayName()
|
||||
.clearAddress()
|
||||
.clearCompany()
|
||||
.clearEmail()
|
||||
.clearExtra()
|
||||
.clearMobile()
|
||||
.clearPortrait()
|
||||
.clearSocial()
|
||||
.build();
|
||||
}
|
||||
|
||||
try {
|
||||
databaseStore.updateUser(us);
|
||||
|
||||
@@ -150,7 +150,7 @@ public interface IMessagesStore {
|
||||
|
||||
ErrorCode updateUserInfo(InputOutputUserInfo userInfo, int flag);
|
||||
void addUserInfo(WFCMessage.User user, String password) throws Exception;
|
||||
void destoryUser(String userId);
|
||||
void destroyUser(String userId);
|
||||
void updateUserInfo(WFCMessage.User user) throws Exception;
|
||||
WFCMessage.User getUserInfo(String userId);
|
||||
WFCMessage.User getUserInfoByName(String name);
|
||||
|
||||
Reference in New Issue
Block a user