Remove redundant user and channel access checks

Eliminated duplicate access restriction logic for user and channel IDs in TelegramPipelineBot. The code now relies on the earlier user ID check, simplifying message handling and reducing unnecessary authorization checks.
This commit is contained in:
Ludy87
2025-12-09 10:57:34 +01:00
parent 115d81a049
commit 8e50deea84

View File

@@ -151,7 +151,7 @@ public class TelegramPipelineBot extends TelegramLongPollingBot {
+ " channel id={}",
chat.getId());
}
if (from == null || !allowUserIDs.contains(from.getId().longValue())) {
if (from == null || !allowUserIDs.contains(from.getId())) {
log.info(
"Ignoring message {} from channel id={} due to user access"
+ " restrictions",
@@ -172,23 +172,6 @@ public class TelegramPipelineBot extends TelegramLongPollingBot {
// private chats
}
}
boolean userAllowed =
!telegramProperties.getEnableAllowUserIDs()
|| (from != null && allowUserIDs.contains(from.getId()));
boolean channelAllowed =
!telegramProperties.getEnableAllowChannelIDs()
|| allowChannelIDs.contains(chat.getId());
if (!userAllowed && !channelAllowed) {
log.info(
"Ignoring message {} from user id={} in chat id={} due to access restrictions",
message.getMessageId(),
from != null ? from.getId() : "unknown",
chat.getId());
sendMessage(
chat.getId(),
"You are not authorized to use this bot. Please contact the administrator.");
return;
}
}
if (from != null) {
log.info(