ソースを参照

fix(tgbot): answer only the link callbacks that match nothing

#6493 was written against the if/else chain where every served link action
returned early, so its trailing answer ran only for an unrouted payload. #6489
had already turned that chain into a switch that falls through, so after the
merge every served link tap also got an error toast, while an unknown payload
still returned from the !ok branch unanswered.

Move the answer into the !ok branch, the one place nothing matched. This
turns TestClientLinkCallbackServesOwnClient and TestUnroutableCallbackIsAnswered
green again on main's go-test job.
Sanaei 11 時間 前
コミット
b98f947efe
1 ファイル変更3 行追加4 行削除
  1. 3 4
      internal/web/service/tgbot/tgbot_router.go

+ 3 - 4
internal/web/service/tgbot/tgbot_router.go

@@ -1318,6 +1318,9 @@ func (t *Tgbot) answerCallback(callbackQuery *telego.CallbackQuery, isAdmin bool
 	default:
 		action, email, ok := splitClientLinkCallback(callbackQuery.Data)
 		if !ok {
+			// Nothing matched: an unknown button still has to be answered, or it
+			// keeps spinning until Telegram times the callback out.
+			t.sendCallbackAnswerTgBot(callbackQuery.ID, t.I18nBot("tgbot.answers.errorOperation"))
 			return
 		}
 		// The keyboard outlives the chat it was sent to, so the email in it
@@ -1334,10 +1337,6 @@ func (t *Tgbot) answerCallback(callbackQuery *telego.CallbackQuery, isAdmin bool
 		case "client_qr_links":
 			t.sendClientQRLinks(chatId, email)
 		}
-
-		// Nothing matched: an unknown button still has to be answered, or it
-		// keeps spinning until Telegram times the callback out.
-		t.sendCallbackAnswerTgBot(callbackQuery.ID, t.I18nBot("tgbot.answers.errorOperation"))
 	}
 }