可以系统设置里设置那么名字不能被使用

This commit is contained in:
heavyrian2012
2025-08-05 17:11:00 +08:00
parent bee03cd2f8
commit 2d7f344b1a
11 changed files with 100 additions and 29 deletions
@@ -1 +1 @@
CREATE INDEX `user_gid_mid_dt_index` ON `t_group_member` (`_gid`, `_mid`, `_dt`);
CREATE INDEX `user_gid_dt_index` ON `t_group_member` (`_gid`, `_dt`);
+1
View File
@@ -0,0 +1 @@
insert into t_settings(`id`, `_value`,`_desc`) values (2, '文件传输助手,客服,官方', '禁止使用名称,如果有多个,以英文逗号隔开。直接修改数据库,不用重启IM服务');
@@ -0,0 +1,2 @@
DROP INDEX `user_gid_mid_dt_index` ON `t_group_member`;
CREATE INDEX `user_gid_dt_index` ON `t_group_member` (`_gid`, `_dt`);
+1
View File
@@ -0,0 +1 @@
insert into t_settings(`id`, `_value`,`_desc`) values (2, '文件传输助手,客服,官方', '禁止使用名称,如果有多个,以英文逗号隔开。直接修改数据库,不用重启IM服务');
@@ -69,10 +69,16 @@ public class CreateGroupHandler extends GroupHandler<WFCMessage.CreateGroupReque
return ErrorCode.INVALID_PARAMETER;
}
if(!m_messagesStore.isSensitiveOnlyMessage() && !isAdmin && !StringUtil.isNullOrEmpty(request.getGroup().getGroupInfo().getName())) {
Set<String> matched = m_messagesStore.handleSensitiveWord(request.getGroup().getGroupInfo().getName());
if (matched != null && !matched.isEmpty()) {
return ErrorCode.ERROR_CODE_SENSITIVE_MATCHED;
if(!isAdmin && !StringUtil.isNullOrEmpty(request.getGroup().getGroupInfo().getName())) {
if(!m_messagesStore.isSensitiveOnlyMessage()) {
Set<String> matched = m_messagesStore.handleSensitiveWord(request.getGroup().getGroupInfo().getName());
if (matched != null && !matched.isEmpty()) {
return ErrorCode.ERROR_CODE_SENSITIVE_MATCHED;
}
}
if(!m_messagesStore.isAllowName(request.getGroup().getGroupInfo().getName())) {
return ErrorCode.ERROR_CODE_NOT_RIGHT;
}
}
@@ -34,10 +34,16 @@ public class ModifyGroupAliasHandler extends GroupHandler<WFCMessage.ModifyGroup
return ErrorCode.ERROR_CODE_NOT_RIGHT;
}
if (!m_messagesStore.isSensitiveOnlyMessage() && !isAdmin && !StringUtil.isNullOrEmpty(request.getAlias())) {
Set<String> matched = m_messagesStore.handleSensitiveWord(request.getAlias());
if (matched != null && !matched.isEmpty()) {
return ErrorCode.ERROR_CODE_SENSITIVE_MATCHED;
if (!isAdmin && !StringUtil.isNullOrEmpty(request.getAlias())) {
if(!m_messagesStore.isSensitiveOnlyMessage()) {
Set<String> matched = m_messagesStore.handleSensitiveWord(request.getAlias());
if (matched != null && !matched.isEmpty()) {
return ErrorCode.ERROR_CODE_SENSITIVE_MATCHED;
}
}
if(!m_messagesStore.isAllowName(request.getAlias())) {
return ErrorCode.ERROR_CODE_NOT_RIGHT;
}
}
@@ -32,10 +32,16 @@ public class ModifyGroupMemberAliasHandler extends GroupHandler<WFCMessage.Modif
if(request.hasNotifyContent() && request.getNotifyContent().getType() > 0 && requestSourceType == ProtoConstants.RequestSourceType.Request_From_Robot && !m_messagesStore.isAllowRobotCustomGroupNotification()) {
return ErrorCode.ERROR_CODE_NOT_RIGHT;
}
if (!m_messagesStore.isSensitiveOnlyMessage() && !isAdmin && !StringUtil.isNullOrEmpty(request.getAlias())) {
Set<String> matched = m_messagesStore.handleSensitiveWord(request.getAlias());
if (matched != null && !matched.isEmpty()) {
return ErrorCode.ERROR_CODE_SENSITIVE_MATCHED;
if (!isAdmin && !StringUtil.isNullOrEmpty(request.getAlias())) {
if(!m_messagesStore.isSensitiveOnlyMessage()) {
Set<String> matched = m_messagesStore.handleSensitiveWord(request.getAlias());
if (matched != null && !matched.isEmpty()) {
return ErrorCode.ERROR_CODE_SENSITIVE_MATCHED;
}
}
if(!m_messagesStore.isAllowName(request.getAlias())) {
return ErrorCode.ERROR_CODE_NOT_RIGHT;
}
}
@@ -1980,10 +1980,16 @@ public class MemoryMessagesStore implements IMessagesStore {
return ErrorCode.ERROR_CODE_NOT_RIGHT;
}
if (!mSensitiveOnlyMessage && modifyType == Modify_Group_Name && !StringUtil.isNullOrEmpty(value)) {
Set<String> matched = handleSensitiveWord(value);
if (matched != null && !matched.isEmpty()) {
return ErrorCode.ERROR_CODE_SENSITIVE_MATCHED;
if (modifyType == Modify_Group_Name && !StringUtil.isNullOrEmpty(value)) {
if(!mSensitiveOnlyMessage) {
Set<String> matched = handleSensitiveWord(value);
if (matched != null && !matched.isEmpty()) {
return ErrorCode.ERROR_CODE_SENSITIVE_MATCHED;
}
}
if(!isAllowName(value)) {
return ErrorCode.ERROR_CODE_NOT_RIGHT;
}
}
}
@@ -2822,12 +2828,19 @@ public class MemoryMessagesStore implements IMessagesStore {
) {
switch (entry.getType()) {
case Modify_DisplayName:
if(!mSensitiveOnlyMessage) {
Set<String> matched = handleSensitiveWord(entry.getValue());
if (matched != null && !matched.isEmpty()) {
return ErrorCode.ERROR_CODE_SENSITIVE_MATCHED;
if(!StringUtil.isNullOrEmpty(entry.getValue())) {
if (!mSensitiveOnlyMessage) {
Set<String> matched = handleSensitiveWord(entry.getValue());
if (matched != null && !matched.isEmpty()) {
return ErrorCode.ERROR_CODE_SENSITIVE_MATCHED;
}
}
if(!isAllowName(entry.getValue())) {
return ErrorCode.ERROR_CODE_NOT_RIGHT;
}
}
builder.setDisplayName(entry.getValue());
modified = true;
break;
@@ -3919,6 +3932,25 @@ public class MemoryMessagesStore implements IMessagesStore {
return ErrorCode.ERROR_CODE_SUCCESS;
}
@Override
public boolean isAllowName(String name) {
if(StringUtil.isNullOrEmpty(name)) {
return true;
}
name = name.trim();
SystemSettingPojo notAllowNameSetting = getSystemSetting(ProtoConstants.SystemSettingType.NOT_ALLOW_USER_NAMES);
if (notAllowNameSetting != null && !StringUtil.isNullOrEmpty(notAllowNameSetting.value)) {
String[] ss = notAllowNameSetting.value.split(",");
for (String s : ss) {
if(name.contains(s.trim())) {
return false;
}
}
}
return true;
}
@Override
public ErrorCode handleJoinChatroom(String userId, String clientId, String chatroomId) {
IMap<String, WFCMessage.ChatroomInfo> chatroomInfoMap = m_Server.getHazelcastInstance().getMap(CHATROOMS);
@@ -190,6 +190,8 @@ public interface IMessagesStore {
ErrorCode setFriendAliasRequest(String fromUser, String targetUserId, String alias, long[] head);
ErrorCode setFriendExtraRequest(String fromUser, String targetUserId, String extra, long[] head);
boolean isAllowName(String name);
ErrorCode handleJoinChatroom(String userId, String clientId, String chatroomId);
ErrorCode handleQuitChatroom(String userId, String clientId, String chatroomId);