From 8e50deea84e5ca4129b78e360b4bb01e6c87855f Mon Sep 17 00:00:00 2001 From: Ludy87 Date: Tue, 9 Dec 2025 10:57:34 +0100 Subject: [PATCH] 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. --- .../service/telegram/TelegramPipelineBot.java | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/app/core/src/main/java/stirling/software/SPDF/service/telegram/TelegramPipelineBot.java b/app/core/src/main/java/stirling/software/SPDF/service/telegram/TelegramPipelineBot.java index d5030bbce..94b5500a7 100644 --- a/app/core/src/main/java/stirling/software/SPDF/service/telegram/TelegramPipelineBot.java +++ b/app/core/src/main/java/stirling/software/SPDF/service/telegram/TelegramPipelineBot.java @@ -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(