(v1Setting *v1pb.AppIMSetting)
| 388 | } |
| 389 | |
| 390 | func convertAppIMSetting(v1Setting *v1pb.AppIMSetting) (*storepb.AppIMSetting, error) { |
| 391 | if v1Setting == nil { |
| 392 | return nil, nil |
| 393 | } |
| 394 | |
| 395 | storeSetting := &storepb.AppIMSetting{} |
| 396 | findIMType := map[v1pb.WebhookType]bool{} |
| 397 | for _, setting := range v1Setting.Settings { |
| 398 | if findIMType[setting.Type] { |
| 399 | return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("duplicate im type %v", setting.Type.String())) |
| 400 | } |
| 401 | findIMType[setting.Type] = true |
| 402 | |
| 403 | imSetting := &storepb.AppIMSetting_IMSetting{ |
| 404 | Type: storepb.WebhookType(setting.Type), |
| 405 | } |
| 406 | // Handle based on Type field since protobuf-es may serialize oneof incorrectly. |
| 407 | // The oneof payload type may not match the Type field due to serialization issues. |
| 408 | switch setting.Type { |
| 409 | case v1pb.WebhookType_SLACK: |
| 410 | imSetting.Payload = &storepb.AppIMSetting_IMSetting_Slack{ |
| 411 | Slack: &storepb.AppIMSetting_Slack{ |
| 412 | Token: setting.GetSlack().GetToken(), |
| 413 | }, |
| 414 | } |
| 415 | case v1pb.WebhookType_FEISHU: |
| 416 | imSetting.Payload = &storepb.AppIMSetting_IMSetting_Feishu{ |
| 417 | Feishu: &storepb.AppIMSetting_Feishu{ |
| 418 | AppId: setting.GetFeishu().GetAppId(), |
| 419 | AppSecret: setting.GetFeishu().GetAppSecret(), |
| 420 | }, |
| 421 | } |
| 422 | case v1pb.WebhookType_WECOM: |
| 423 | imSetting.Payload = &storepb.AppIMSetting_IMSetting_Wecom{ |
| 424 | Wecom: &storepb.AppIMSetting_Wecom{ |
| 425 | CorpId: setting.GetWecom().GetCorpId(), |
| 426 | AgentId: setting.GetWecom().GetAgentId(), |
| 427 | Secret: setting.GetWecom().GetSecret(), |
| 428 | }, |
| 429 | } |
| 430 | case v1pb.WebhookType_LARK: |
| 431 | imSetting.Payload = &storepb.AppIMSetting_IMSetting_Lark{ |
| 432 | Lark: &storepb.AppIMSetting_Lark{ |
| 433 | AppId: setting.GetLark().GetAppId(), |
| 434 | AppSecret: setting.GetLark().GetAppSecret(), |
| 435 | }, |
| 436 | } |
| 437 | case v1pb.WebhookType_DINGTALK: |
| 438 | imSetting.Payload = &storepb.AppIMSetting_IMSetting_Dingtalk{ |
| 439 | Dingtalk: &storepb.AppIMSetting_DingTalk{ |
| 440 | ClientId: setting.GetDingtalk().GetClientId(), |
| 441 | ClientSecret: setting.GetDingtalk().GetClientSecret(), |
| 442 | RobotCode: setting.GetDingtalk().GetRobotCode(), |
| 443 | }, |
| 444 | } |
| 445 | case v1pb.WebhookType_TEAMS: |
| 446 | imSetting.Payload = &storepb.AppIMSetting_IMSetting_Teams{ |
| 447 | Teams: &storepb.AppIMSetting_Teams{ |
no test coverage detected