MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / extractDingTalkConfig

Function extractDingTalkConfig

agent/app/service/agents_channels.go:1072–1146  ·  view source on GitHub ↗
(conf map[string]interface{})

Source from the content-addressed store, hash-verified

1070}
1071
1072func extractDingTalkConfig(conf map[string]interface{}) dto.AgentDingTalkConfig {
1073 result := dto.AgentDingTalkConfig{
1074 Enabled: true,
1075 DmPolicy: "open",
1076 GroupPolicy: "disabled",
1077 AllowFrom: []string{},
1078 GroupAllowFrom: []string{},
1079 SeparateSessionByConversation: true,
1080 GroupSessionScope: "group",
1081 SharedMemoryAcrossConversations: false,
1082 AsyncMode: false,
1083 AckText: "任务已接收,处理中...",
1084 }
1085 dingtalk := getChannelConfig(conf, "dingtalk-connector")
1086 if len(dingtalk) == 0 {
1087 return result
1088 }
1089 if enabled, ok := dingtalk["enabled"].(bool); ok {
1090 result.Enabled = enabled
1091 }
1092 if dmPolicy := extractStringValue(dingtalk["dmPolicy"]); dmPolicy != "" {
1093 if dmPolicy == "pairing" {
1094 result.DmPolicy = "open"
1095 } else {
1096 result.DmPolicy = dmPolicy
1097 }
1098 }
1099 if groupPolicy := extractStringValue(dingtalk["groupPolicy"]); groupPolicy != "" {
1100 result.GroupPolicy = groupPolicy
1101 }
1102 result.AllowFrom = extractStringList(dingtalk["allowFrom"])
1103 result.GroupAllowFrom = extractStringList(dingtalk["groupAllowFrom"])
1104 if separateSessionByConversation, ok := dingtalk["separateSessionByConversation"].(bool); ok {
1105 result.SeparateSessionByConversation = separateSessionByConversation
1106 }
1107 if groupSessionScope := extractStringValue(dingtalk["groupSessionScope"]); groupSessionScope != "" {
1108 result.GroupSessionScope = groupSessionScope
1109 }
1110 if sharedMemoryAcrossConversations, ok := dingtalk["sharedMemoryAcrossConversations"].(bool); ok {
1111 result.SharedMemoryAcrossConversations = sharedMemoryAcrossConversations
1112 }
1113 if asyncMode, ok := dingtalk["asyncMode"].(bool); ok {
1114 result.AsyncMode = asyncMode
1115 }
1116 if ackText := extractStringValue(dingtalk["ackText"]); ackText != "" {
1117 result.AckText = ackText
1118 }
1119 accounts := childMap(dingtalk, "accounts")
1120 if len(accounts) == 0 {
1121 clientID := extractStringValue(dingtalk["clientId"])
1122 clientSecret := extractStringValue(dingtalk["clientSecret"])
1123 if clientID != "" || clientSecret != "" {
1124 accounts["default"] = map[string]interface{}{
1125 "enabled": extractBoolValue(dingtalk["enabled"], true),
1126 "clientId": clientID,
1127 "clientSecret": clientSecret,
1128 }
1129 }

Callers 2

GetDingTalkConfigMethod · 0.85

Calls 6

getChannelConfigFunction · 0.85
extractStringValueFunction · 0.85
extractStringListFunction · 0.85
childMapFunction · 0.85
extractBoolValueFunction · 0.85
sortedChildKeysFunction · 0.85

Tested by

no test coverage detected