mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-12-18 20:04:17 +01:00
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:
parent
115d81a049
commit
8e50deea84
@ -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(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user