mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 14:19:49 +08:00
fix(notify): fix mobile validate (#20510)
Co-authored-by: 马鸿飞 <mahongfei@yunion.cn>
This commit is contained in:
@@ -226,6 +226,10 @@ type SNotifyConfigContent struct {
|
||||
//AppSecret string
|
||||
AppKey string
|
||||
// sms
|
||||
VerifiyCode string
|
||||
AlertsCode string
|
||||
ErrorCode string
|
||||
PhoneNumber string
|
||||
AccessKeyId string
|
||||
AccessKeySecret string
|
||||
ServiceUrl string
|
||||
|
||||
@@ -39,11 +39,11 @@ func (d *SAliyunSMSDriver) Name() string {
|
||||
}
|
||||
|
||||
func (d *SAliyunSMSDriver) Verify(config *api.NotifyConfig) error {
|
||||
err := d.Send(api.SSMSSendParams{}, true, config)
|
||||
if err == ErrSignnameInvalid || err == ErrSignatureDoesNotMatch || err == ErrAccessKeyIdNotFound {
|
||||
return nil
|
||||
}
|
||||
return errors.Wrap(err, "Verify")
|
||||
return d.Send(api.SSMSSendParams{
|
||||
RemoteTemplate: config.VerifiyCode,
|
||||
To: config.PhoneNumber,
|
||||
RemoteTemplateParam: api.SRemoteTemplateParam{Code: "0000"},
|
||||
}, true, config)
|
||||
}
|
||||
|
||||
func (d *SAliyunSMSDriver) Send(args api.SSMSSendParams, isVerify bool, config *api.NotifyConfig) error {
|
||||
@@ -64,9 +64,8 @@ func (d *SAliyunSMSDriver) sendSms(args api.SSMSSendParams) error {
|
||||
// lock and update
|
||||
client, err := sdk.NewClientWithAccessKey("default", args.AppKey, args.AppSecret)
|
||||
if err != nil {
|
||||
return err
|
||||
return errors.Wrap(err, "NewClientWithAccessKey")
|
||||
}
|
||||
|
||||
m := parser.FindStringSubmatch(args.To)
|
||||
if len(m) > 0 {
|
||||
if m[1] == "86" {
|
||||
|
||||
@@ -45,11 +45,11 @@ func (d *SHuaweiSMSDriver) Name() string {
|
||||
}
|
||||
|
||||
func (d *SHuaweiSMSDriver) Verify(config *api.NotifyConfig) error {
|
||||
err := d.Send(api.SSMSSendParams{}, true, config)
|
||||
if err == ErrSignnameInvalid || err == ErrSignatureDoesNotMatch || err == ErrAccessKeyIdNotFound {
|
||||
return nil
|
||||
}
|
||||
return errors.Wrap(err, "Verify")
|
||||
return d.Send(api.SSMSSendParams{
|
||||
RemoteTemplate: config.VerifiyCode,
|
||||
To: config.PhoneNumber,
|
||||
RemoteTemplateParam: api.SRemoteTemplateParam{Code: "0000"},
|
||||
}, true, config)
|
||||
}
|
||||
|
||||
func (d *SHuaweiSMSDriver) Send(args api.SSMSSendParams, isVerify bool, config *api.NotifyConfig) error {
|
||||
@@ -62,7 +62,6 @@ func (d *SHuaweiSMSDriver) Send(args api.SSMSSendParams, isVerify bool, config *
|
||||
args.AppSecret = models.ConfigMap[api.MOBILE].Content.AccessKeySecret
|
||||
args.Signature = models.ConfigMap[api.MOBILE].Content.Signature
|
||||
}
|
||||
|
||||
args.TemplateId = strings.Split(args.RemoteTemplate, "/")[1]
|
||||
args.From = strings.Split(args.RemoteTemplate, "/")[0]
|
||||
return d.sendSms(args)
|
||||
|
||||
Reference in New Issue
Block a user