mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-08-30 17:13:08 +08:00
fix(notify): add mobile verify (#20519)
Co-authored-by: 马鸿飞 <mahongfei@yunion.cn>
This commit is contained in:
+18
-14
@@ -89,13 +89,15 @@ func (cm *SConfigManager) ValidateCreateData(ctx context.Context, userCred mccli
|
||||
}
|
||||
driver := GetDriver(input.Type)
|
||||
// validate
|
||||
message, err := driver.ValidateConfig(ctx, api.NotifyConfig{
|
||||
SNotifyConfigContent: *input.Content,
|
||||
Attribution: input.Attribution,
|
||||
DomainId: input.ProjectDomainId,
|
||||
})
|
||||
if err != nil {
|
||||
return input, errors.Wrapf(err, message)
|
||||
if input.Type != api.MOBILE {
|
||||
message, err := driver.ValidateConfig(ctx, api.NotifyConfig{
|
||||
SNotifyConfigContent: *input.Content,
|
||||
Attribution: input.Attribution,
|
||||
DomainId: input.ProjectDomainId,
|
||||
})
|
||||
if err != nil {
|
||||
return input, errors.Wrapf(err, message)
|
||||
}
|
||||
}
|
||||
if len(input.Name) == 0 {
|
||||
input.Name = input.Type
|
||||
@@ -166,13 +168,15 @@ func (c *SConfig) ValidateUpdateData(ctx context.Context, userCred mcclient.Toke
|
||||
// check if changed
|
||||
if input.Content != nil {
|
||||
driver := GetDriver(c.Type)
|
||||
message, err := driver.ValidateConfig(ctx, api.NotifyConfig{
|
||||
DomainId: c.DomainId,
|
||||
Attribution: c.Attribution,
|
||||
SNotifyConfigContent: *input.Content,
|
||||
})
|
||||
if err != nil {
|
||||
return input, errors.Wrapf(err, message)
|
||||
if c.Type != api.MOBILE {
|
||||
message, err := driver.ValidateConfig(ctx, api.NotifyConfig{
|
||||
SNotifyConfigContent: *input.Content,
|
||||
Attribution: c.Attribution,
|
||||
DomainId: c.DomainId,
|
||||
})
|
||||
if err != nil {
|
||||
return input, errors.Wrapf(err, message)
|
||||
}
|
||||
}
|
||||
}
|
||||
return input, nil
|
||||
|
||||
@@ -53,7 +53,7 @@ func (smsSender *SMobileSender) ValidateConfig(ctx context.Context, config api.N
|
||||
if driver == nil {
|
||||
return "", errors.Wrap(errors.ErrNotFound, "driver disabled")
|
||||
}
|
||||
return "", nil
|
||||
return "", driver.Verify(&config)
|
||||
}
|
||||
|
||||
func (smsSender *SMobileSender) UpdateConfig(config api.NotifyConfig) error {
|
||||
|
||||
Reference in New Issue
Block a user