fix(video): 火山方舟 - 解耦可信素材并修复音频组合参考 (#302)
This commit is contained in:
@@ -60,15 +60,19 @@ func (s *Service) prepareArkPrivateAssetReferences(ctx context.Context, userID s
|
||||
if !hasOwnedReference {
|
||||
return nil
|
||||
}
|
||||
if taskID := taskExecutionID(ctx); taskID != "" {
|
||||
_ = s.repo.UpdateTaskProgress(taskID, "同步方舟可信素材", 36)
|
||||
}
|
||||
settingRecord, setting, err := s.readArkPrivateAssetSetting()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !setting.Enabled || setting.AccessKeyID == "" || setting.AccessKeySecret == "" {
|
||||
return errors.New("方舟可信素材库尚未配置,请由管理员在方舟素材库设置中填写启用的 IAM AK/SK")
|
||||
automaticSyncEnabled, err := arkPrivateAssetAutomaticSyncEnabled(setting)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !automaticSyncEnabled {
|
||||
return nil
|
||||
}
|
||||
if taskID := taskExecutionID(ctx); taskID != "" {
|
||||
_ = s.repo.UpdateTaskProgress(taskID, "同步方舟可信素材", 36)
|
||||
}
|
||||
for index := range input.ReferenceImages {
|
||||
reference := &input.ReferenceImages[index]
|
||||
@@ -106,6 +110,18 @@ func isArkPrivateAssetVideoConfig(config providerConfig) bool {
|
||||
return config.InterfaceType == string(model.ChannelInterfaceVolcengineArkVideo) || isArkPlanVideoConfig(config)
|
||||
}
|
||||
|
||||
func arkPrivateAssetAutomaticSyncEnabled(setting arkPrivateAssetSettingValue) (bool, error) {
|
||||
// 可信素材同步是可选增强能力。管理员未启用时保持原始参考 URL,
|
||||
// 继续执行常规火山方舟视频请求。
|
||||
if !setting.Enabled {
|
||||
return false, nil
|
||||
}
|
||||
if setting.AccessKeyID == "" || setting.AccessKeySecret == "" {
|
||||
return false, errors.New("方舟可信素材库尚未配置,请由管理员在方舟素材库设置中填写启用的 IAM AK/SK")
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func arkPrivateAssetResourceID(reference providerMedia) string {
|
||||
if !strings.HasPrefix(reference.StorageKey, "resource:") {
|
||||
return ""
|
||||
|
||||
@@ -96,6 +96,18 @@ func TestArkPrivateAssetControlPlaneDisablesGenerationAnalytics(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestArkPrivateAssetAutomaticSyncIsOptionalWhenSettingDisabled(t *testing.T) {
|
||||
enabled, err := arkPrivateAssetAutomaticSyncEnabled(arkPrivateAssetSettingValue{})
|
||||
if err != nil || enabled {
|
||||
t.Fatalf("arkPrivateAssetAutomaticSyncEnabled() = %v, %v; want false, nil", enabled, err)
|
||||
}
|
||||
|
||||
_, err = arkPrivateAssetAutomaticSyncEnabled(arkPrivateAssetSettingValue{Enabled: true})
|
||||
if err == nil || !strings.Contains(err.Error(), "尚未配置") {
|
||||
t.Fatalf("enabled incomplete setting error = %v, want configuration error", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestArkPrivateAssetSettingsEncryptSecret(t *testing.T) {
|
||||
svc := &Service{dataDir: t.TempDir()}
|
||||
value, err := arkPrivateAssetSettingFromRequest(ArkPrivateAssetSettingRequest{
|
||||
|
||||
Reference in New Issue
Block a user