From 15cf81e1bd6eeaeb9cc18771f539b9b21a0331e7 Mon Sep 17 00:00:00 2001 From: krau <71133316+krau@users.noreply.github.com> Date: Thu, 6 Nov 2025 16:04:31 +0800 Subject: [PATCH] fix: remove unnecessary chat ID validation and constant usage in Save method --- storage/telegram/telegram.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/storage/telegram/telegram.go b/storage/telegram/telegram.go index a19ebd8..b192359 100644 --- a/storage/telegram/telegram.go +++ b/storage/telegram/telegram.go @@ -12,7 +12,6 @@ import ( "github.com/duke-git/lancet/v2/slice" "github.com/duke-git/lancet/v2/validator" "github.com/gabriel-vasile/mimetype" - "github.com/gotd/td/constant" "github.com/gotd/td/telegram/message" "github.com/gotd/td/telegram/message/styling" "github.com/gotd/td/telegram/uploader" @@ -94,10 +93,6 @@ func (t *Telegram) Save(ctx context.Context, r io.Reader, storagePath string) er // id不合法时使用配置文件中的 chat_id log.FromContext(ctx).Warnf("Failed to parse chat ID from path, using configured chat_id: %s", err) cid = chatID - } else { - if cid > constant.MaxTDLibChannelID || cid > constant.MaxTDLibChatID || cid > constant.MaxTDLibUserID { - cid = chatID - } } chatID = cid } @@ -108,10 +103,6 @@ func (t *Telegram) Save(ctx context.Context, r io.Reader, storagePath string) er if filename == "" { filename = xid.New().String() + mtype.Extension() } - - if chatID < 0 { - chatID = chatID - constant.ZeroTDLibChannelID - } peer := tctx.PeerStorage.GetInputPeerById(chatID) if peer == nil { return fmt.Errorf("failed to get input peer for chat ID %d", chatID)