From 9a8247fa784289ba1fcf7f4f08d1fd8350c170af Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Sat, 13 Jun 2026 10:56:02 +0200 Subject: [PATCH] fix(tgbot): clear legacy panelProxy/tgBotProxy settings on upgrade v3.3.1 removed the Panel Proxy URL field from the UI but left the stored panelProxy/tgBotProxy values in the DB. The Telegram bot still reads tgBotProxy directly, so a stale value masked the panelOutbound egress fallback. Add a one-off seeder to drop both rows. Closes #5266 --- internal/database/db.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/internal/database/db.go b/internal/database/db.go index 53150f579..858be4d6e 100644 --- a/internal/database/db.go +++ b/internal/database/db.go @@ -200,7 +200,7 @@ func runSeeders(isUsersEmpty bool) error { } if empty && isUsersEmpty { - seeders := []string{"UserPasswordHash", "ClientsTable", "InboundClientsArrayFix", "InboundClientTgIdFix", "InboundClientSubIdFix", "FreedomFinalRulesReverseFix", "ApiTokensHash"} + seeders := []string{"UserPasswordHash", "ClientsTable", "InboundClientsArrayFix", "InboundClientTgIdFix", "InboundClientSubIdFix", "FreedomFinalRulesReverseFix", "ApiTokensHash", "LegacyProxySettingsCleanup"} for _, name := range seeders { if err := db.Create(&model.HistoryOfSeeders{SeederName: name}).Error; err != nil { return err @@ -286,9 +286,27 @@ func runSeeders(isUsersEmpty bool) error { return err } } + + if !slices.Contains(seedersHistory, "LegacyProxySettingsCleanup") { + if err := clearLegacyProxySettings(); err != nil { + return err + } + } return nil } +// clearLegacyProxySettings drops the deprecated panelProxy/tgBotProxy rows so a +// stale tgBotProxy no longer masks the panelOutbound egress fallback. +func clearLegacyProxySettings() error { + return db.Transaction(func(tx *gorm.DB) error { + if err := tx.Where("key IN ?", []string{"panelProxy", "tgBotProxy"}). + Delete(&model.Setting{}).Error; err != nil { + return err + } + return tx.Create(&model.HistoryOfSeeders{SeederName: "LegacyProxySettingsCleanup"}).Error + }) +} + func normalizeInboundClientTgId() error { var inbounds []model.Inbound if err := db.Find(&inbounds).Error; err != nil {