handleUpdateTelegramModel updates only the AI model used for Telegram replies (no token re-entry needed)
(c *gin.Context)
| 82 | |
| 83 | // handleUpdateTelegramModel updates only the AI model used for Telegram replies (no token re-entry needed) |
| 84 | func (s *Server) handleUpdateTelegramModel(c *gin.Context) { |
| 85 | var req struct { |
| 86 | ModelID string `json:"model_id"` |
| 87 | } |
| 88 | if err := c.ShouldBindJSON(&req); err != nil { |
| 89 | c.JSON(http.StatusBadRequest, gin.H{"error": "invalid request"}) |
| 90 | return |
| 91 | } |
| 92 | |
| 93 | cfg, err := s.store.TelegramConfig().Get() |
| 94 | if err != nil { |
| 95 | c.JSON(http.StatusBadRequest, gin.H{"error": "no Telegram config found, save a bot token first"}) |
| 96 | return |
| 97 | } |
| 98 | |
| 99 | if err := s.store.TelegramConfig().Save(cfg.BotToken, req.ModelID); err != nil { |
| 100 | c.JSON(http.StatusInternalServerError, gin.H{"error": "failed to save model config"}) |
| 101 | return |
| 102 | } |
| 103 | |
| 104 | c.JSON(http.StatusOK, gin.H{"success": true, "model_id": req.ModelID}) |
| 105 | } |
nothing calls this directly
no test coverage detected