(conf map[string]interface{})
| 610 | } |
| 611 | |
| 612 | func extractFeishuConfig(conf map[string]interface{}) dto.AgentFeishuConfig { |
| 613 | result := dto.AgentFeishuConfig{ |
| 614 | Enabled: true, |
| 615 | ThreadSession: true, |
| 616 | ReplyMode: "auto", |
| 617 | Streaming: false, |
| 618 | RequireMention: "true", |
| 619 | GroupPolicy: "open", |
| 620 | GroupAllowFrom: []string{}, |
| 621 | Bots: []dto.AgentFeishuBot{}, |
| 622 | } |
| 623 | feishu := getChannelConfig(conf, "feishu") |
| 624 | if len(feishu) == 0 { |
| 625 | return result |
| 626 | } |
| 627 | result.Enabled = extractFeishuPluginEnabled(conf, extractBoolValue(feishu["enabled"], result.Enabled)) |
| 628 | if threadSession, ok := feishu["threadSession"].(bool); ok { |
| 629 | result.ThreadSession = threadSession |
| 630 | } |
| 631 | if replyMode := extractStringValue(feishu["replyMode"]); replyMode != "" { |
| 632 | result.ReplyMode = replyMode |
| 633 | } |
| 634 | if streaming, ok := feishu["streaming"].(bool); ok { |
| 635 | result.Streaming = streaming |
| 636 | } |
| 637 | result.RequireMention = extractRequireMentionValue(feishu["requireMention"], result.RequireMention) |
| 638 | if groupPolicy := extractStringValue(feishu["groupPolicy"]); groupPolicy != "" { |
| 639 | result.GroupPolicy = groupPolicy |
| 640 | } |
| 641 | result.GroupAllowFrom = extractStringList(feishu["groupAllowFrom"]) |
| 642 | defaultBot := defaultFeishuBot() |
| 643 | defaultBot.Enabled = extractBoolValue(feishu["enabled"], defaultBot.Enabled) |
| 644 | defaultBot.Name = extractDisplayName(feishu, "", "default") |
| 645 | defaultBot.AppID = extractStringValue(feishu["appId"]) |
| 646 | defaultBot.AppSecret = extractStringValue(feishu["appSecret"]) |
| 647 | if dmPolicy := extractStringValue(feishu["dmPolicy"]); dmPolicy != "" { |
| 648 | defaultBot.DmPolicy = dmPolicy |
| 649 | } |
| 650 | if _, ok := feishu["allowFrom"]; ok { |
| 651 | defaultBot.AllowFrom = extractStringList(feishu["allowFrom"]) |
| 652 | } |
| 653 | accounts := childMap(feishu, "accounts") |
| 654 | defaultAccount := childMap(accounts, "default") |
| 655 | if defaultBot.Name == "Default" { |
| 656 | defaultBot.Name = extractDisplayName(defaultAccount, extractStringValue(defaultAccount["botName"]), "Default") |
| 657 | } |
| 658 | if defaultBot.DmPolicy == "pairing" { |
| 659 | if dmPolicy := extractStringValue(defaultAccount["dmPolicy"]); dmPolicy != "" { |
| 660 | defaultBot.DmPolicy = dmPolicy |
| 661 | } |
| 662 | } |
| 663 | if len(defaultBot.AllowFrom) == 0 { |
| 664 | if _, ok := defaultAccount["allowFrom"]; ok { |
| 665 | defaultBot.AllowFrom = extractStringList(defaultAccount["allowFrom"]) |
| 666 | } |
| 667 | } |
| 668 | baseEnabled := defaultBot.Enabled |
| 669 | baseDmPolicy := defaultBot.DmPolicy |
no test coverage detected