feat(im): add Yunzhijia integration
This commit is contained in:
+19
-4
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user