Skip to content

Commit 8283f39

Browse files
feat: preserve Feishu account map on config updates
1 parent 1f22285 commit 8283f39

1 file changed

Lines changed: 11 additions & 17 deletions

File tree

‎agent/app/service/agents.go‎

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -803,26 +803,20 @@ func extractFeishuConfig(conf map[string]interface{}) dto.AgentFeishuConfig {
803803
}
804804

805805
func setFeishuConfig(conf map[string]interface{}, config dto.AgentFeishuConfig) {
806-
channels, ok := conf["channels"].(map[string]interface{})
807-
if !ok {
808-
channels = map[string]interface{}{}
809-
conf["channels"] = channels
810-
}
811-
feishu := map[string]interface{}{
812-
"enabled": config.Enabled,
813-
"dmPolicy": config.DmPolicy,
814-
"accounts": map[string]interface{}{
815-
"main": map[string]interface{}{
816-
"appId": config.AppID,
817-
"appSecret": config.AppSecret,
818-
"botName": config.BotName,
819-
},
820-
},
821-
}
806+
channels := ensureChildMap(conf, "channels")
807+
feishu := ensureChildMap(channels, "feishu")
808+
feishu["enabled"] = config.Enabled
809+
feishu["dmPolicy"] = config.DmPolicy
810+
811+
accounts := ensureChildMap(feishu, "accounts")
812+
main := ensureChildMap(accounts, "main")
813+
main["appId"] = config.AppID
814+
main["appSecret"] = config.AppSecret
815+
main["botName"] = config.BotName
816+
822817
if strings.EqualFold(config.DmPolicy, "open") {
823818
feishu["allowFrom"] = []string{"*"}
824819
}
825-
channels["feishu"] = feishu
826820
}
827821

828822
func setFeishuPluginEnabled(conf map[string]interface{}, enabled bool) {

0 commit comments

Comments
 (0)