feat(automation): close delayed action parity

This commit is contained in:
2026-06-05 21:42:10 +08:00
parent 43aa2f81eb
commit ddf2694ed3
7 changed files with 464 additions and 39 deletions
@@ -426,8 +426,10 @@ func actionArrayToMap(actionName string, values []interface{}) map[string]interf
switch actionName {
case "assign_agent":
params["assignee_id"] = first
case "assign_team", "send_email_to_team":
case "assign_team":
params["team_id"] = first
case "send_email_to_team":
params["team_ids"] = values
case "add_label", "remove_label":
params["labels"] = valuesToStrings(values)
case "change_status":
@@ -450,7 +452,7 @@ func actionArrayToMap(actionName string, values []interface{}) map[string]interf
return params
}
func chatwootActionParams(action automation.Action) []interface{} {
func chatwootActionParams(action automation.Action) interface{} {
params := action.ActionParams
if params == nil {
return []interface{}{}
@@ -458,8 +460,13 @@ func chatwootActionParams(action automation.Action) []interface{} {
switch action.ActionName {
case "assign_agent":
return compactValues(params["assignee_id"], params["agent_id"])
case "assign_team", "send_email_to_team":
case "assign_team":
return compactValues(params["team_id"])
case "send_email_to_team":
return gin.H{
"team_ids": valuesToInterfaces(firstNonNil(params["team_ids"], params["team_id"])),
"message": firstNonNil(params["message"], params["content"]),
}
case "add_label", "remove_label":
if labels, ok := params["labels"]; ok {
return valuesToInterfaces(labels)
@@ -487,6 +494,15 @@ func chatwootActionParams(action automation.Action) []interface{} {
}
}
func firstNonNil(values ...interface{}) interface{} {
for _, value := range values {
if value != nil {
return value
}
}
return nil
}
func firstValue(values []interface{}) interface{} {
if len(values) == 0 {
return nil
@@ -513,6 +529,18 @@ func valuesToInterfaces(value interface{}) []interface{} {
result = append(result, item)
}
return result
case []uint:
result := make([]interface{}, 0, len(typed))
for _, item := range typed {
result = append(result, item)
}
return result
case []int:
result := make([]interface{}, 0, len(typed))
for _, item := range typed {
result = append(result, item)
}
return result
case nil:
return []interface{}{}
default: