refactor(channel): drop dead require_mention block in checkAccess

This commit is contained in:
matevip 2026-05-20 10:13:59 +08:00
parent 8d91197a46
commit 2f90052430

View File

@ -417,7 +417,10 @@ public abstract class AbstractChannelAdapter implements ChannelAdapter {
* - dm_policy / group_policy控制私聊/群聊是否开放
* - allow_from用户白名单
* - deny_message拒绝时的提示消息
* - require_mention群聊中是否需要 @机器人
* <p>
* Note: {@code require_mention} is honored by individual channel adapters
* (Feishu reads the SDK's mentions field, etc.) rather than at this layer,
* because reliable mention detection is platform-specific.
*/
protected boolean checkAccess(ChannelMessage message) {
boolean isDM = isDirectMessage(message);
@ -433,18 +436,7 @@ public abstract class AbstractChannelAdapter implements ChannelAdapter {
return false;
}
// 2. 群聊中检查 require_mention需要 @机器人才响应
// 如果已设置 botPrefixshouldProcess() 已处理此处处理 configJson 中的 require_mention
if (!isDM && getConfigBoolean("require_mention", false)) {
String botPrefix = channelEntity.getBotPrefix();
if (botPrefix == null || botPrefix.isBlank()) {
// 设置了 require_mention 但没有 botPrefix无法判断 mention放行
log.debug("[{}] require_mention=true but no botPrefix configured, allowing", getChannelType());
}
// 如果有 botPrefixshouldProcess() 已经过滤过非 mention 消息此处放行
}
// 3. 检查 allow_from 白名单
// 2. 检查 allow_from 白名单
List<String> allowFrom = getConfigList("allow_from");
if (!allowFrom.isEmpty()) {
if (!allowFrom.contains(message.getSenderId())) {