Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
zhaoyunxing 2026-03-18 22:17:40 +08:00 committed by GitHub
parent 316e29f208
commit 052b8f1b0a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -198,14 +198,20 @@ func (c *DingTalkChannel) onChatBotMessageReceived(
} }
// Try to create and deliver card (optional feature) // Try to create and deliver card (optional feature)
// If it fails, log the error but continue with normal message handling // Only attempt this if a card template is configured; otherwise, fall back silently
if cardID, err := c.tryCardCreateAndDeliver(ctx, data); err != nil { if c.config.CardTemplateID != "" {
logger.WarnC("dingtalk", "Failed to create or deliver card, falling back to direct reply") // If it fails, log the error but continue with normal message handling
// Store the session webhook for this chat so we can reply later if cardID, err := c.tryCardCreateAndDeliver(ctx, data); err != nil {
c.sessionWebhooks.Store(chatID, data.SessionWebhook) logger.WarnC("dingtalk", "Failed to create or deliver card, falling back to direct reply")
// Store the session webhook for this chat so we can reply later
c.sessionWebhooks.Store(chatID, data.SessionWebhook)
} else {
chatID = data.MsgId
c.cardInstanceIDs.Store(chatID, cardID)
}
} else { } else {
chatID = data.MsgId // Card feature not configured; just store the session webhook for direct replies
c.cardInstanceIDs.Store(chatID, cardID) c.sessionWebhooks.Store(chatID, data.SessionWebhook)
} }
// Handle the message through the base channel // Handle the message through the base channel