feat(im): add Yunzhijia integration

This commit is contained in:
jacentsao
2026-07-20 13:52:27 +08:00
committed by lyingbug
parent 83da0903b6
commit 150c07368b
21 changed files with 1377 additions and 12 deletions
+19 -4
View File
@@ -15,7 +15,7 @@ import (
// validIMPlatforms is the set of supported IM platforms.
var validIMPlatforms = map[string]bool{
"wecom": true, "feishu": true, "lark": true, "slack": true, "telegram": true, "dingtalk": true,
"mattermost": true, "wechat": true, "qqbot": true,
"mattermost": true, "wechat": true, "qqbot": true, "yunzhijia": true,
}
// invalidIMPlatformError is the 400 message listing the accepted platforms. It
@@ -97,7 +97,7 @@ func (h *IMHandler) CreateIMChannel(c *gin.Context) {
channel.OutputMode = "full"
} else {
if channel.Mode == "" {
if channel.Platform == "mattermost" {
if channel.Platform == "mattermost" || channel.Platform == "yunzhijia" {
channel.Mode = "webhook"
} else {
channel.Mode = "websocket"
@@ -328,6 +328,21 @@ func (h *IMHandler) ToggleIMChannel(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"data": channel})
}
func writeIMCallbackACK(c *gin.Context, platform string) {
if platform == "yunzhijia" {
c.JSON(http.StatusOK, gin.H{
"success": true,
"data": gin.H{
"type": 2,
"content": "",
},
})
return
}
c.JSON(http.StatusOK, gin.H{"success": true})
}
// ── Callback handlers ──
// IMCallback handles IM platform callback requests for a specific channel.
@@ -404,12 +419,12 @@ func (h *IMHandler) IMCallback(c *gin.Context) {
} else {
logger.Infof(ctx, "[IM] Callback parsed no message to process platform=%s path_channel_id=%s", channel.Platform, channelID)
}
c.JSON(http.StatusOK, gin.H{"success": true})
writeIMCallbackACK(c, channel.Platform)
return
}
// Respond immediately to avoid platform timeout
c.JSON(http.StatusOK, gin.H{"success": true})
writeIMCallbackACK(c, channel.Platform)
// Detach from gin request context
asyncCtx := context.WithoutCancel(ctx)