Browse Source

Added `Volo.Abp.Sms.TencentCloud` to `common.ps1`.

pull/21651/head
maliming 2 years ago
parent
commit
6cfd5af71a
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 5
      framework/src/Volo.Abp.Sms.TencentCloud/Volo/Abp/Sms/TencentCloud/AbpTencentCloudSmsOptions.cs
  2. 1
      framework/src/Volo.Abp.Sms.TencentCloud/Volo/Abp/Sms/TencentCloud/TencentCloudSmsProperties.cs
  3. 18
      framework/src/Volo.Abp.Sms.TencentCloud/Volo/Abp/Sms/TencentCloud/TencentCloudSmsSender.cs
  4. 4
      framework/test/Volo.Abp.Sms.TencenCloud.Tests/Volo/Abp/Sms/TencentCloud/AbpSmsTencentCloudTestsModule.cs
  5. 1
      nupkg/common.ps1

5
framework/src/Volo.Abp.Sms.TencentCloud/Volo/Abp/Sms/TencentCloud/AbpTencentCloudSmsOptions.cs

@ -3,9 +3,12 @@ namespace Volo.Abp.Sms.TencentCloud;
public class AbpTencentCloudSmsOptions public class AbpTencentCloudSmsOptions
{ {
public string SmsSdkAppId { get; set; } = default!; public string SmsSdkAppId { get; set; } = default!;
public string SecretKey { get; set; } = default!; public string SecretKey { get; set; } = default!;
public string SecretId { get; set; } = default!; public string SecretId { get; set; } = default!;
public string Endpoint { get; set; } = "sms.tencentcloudapi.com"; public string Endpoint { get; set; } = "sms.tencentcloudapi.com";
public string Region { get; set; } = "ap-guangzhou";
public string Region { get; set; } = "ap-guangzhou";
} }

1
framework/src/Volo.Abp.Sms.TencentCloud/Volo/Abp/Sms/TencentCloud/TencentCloudSmsProperties.cs

@ -3,5 +3,6 @@
public static class TencentCloudSmsProperties public static class TencentCloudSmsProperties
{ {
public const string SignName = "SignName"; public const string SignName = "SignName";
public const string TemplateId = "TemplateId"; public const string TemplateId = "TemplateId";
} }

18
framework/src/Volo.Abp.Sms.TencentCloud/Volo/Abp/Sms/TencentCloud/TencentCloudSmsSender.cs

@ -18,11 +18,11 @@ public class TencentCloudSmsSender : ISmsSender, ITransientDependency
Options = options.CurrentValue; Options = options.CurrentValue;
} }
public async Task SendAsync(SmsMessage smsMessage) public virtual async Task SendAsync(SmsMessage smsMessage)
{ {
var client = CreateClient(); var client = CreateClient();
var result = await client.SendSms(new SendSmsRequest() await client.SendSms(new SendSmsRequest()
{ {
SmsSdkAppId = Options.SmsSdkAppId, SmsSdkAppId = Options.SmsSdkAppId,
SignName = smsMessage.Properties.GetOrDefault(TencentCloudSmsProperties.SignName) as string, SignName = smsMessage.Properties.GetOrDefault(TencentCloudSmsProperties.SignName) as string,
@ -30,20 +30,22 @@ public class TencentCloudSmsSender : ISmsSender, ITransientDependency
TemplateParamSet = smsMessage.Text.Split(','), TemplateParamSet = smsMessage.Text.Split(','),
PhoneNumberSet = [smsMessage.PhoneNumber] PhoneNumberSet = [smsMessage.PhoneNumber]
}); });
} }
protected virtual SmsClient CreateClient() protected virtual SmsClient CreateClient()
{ {
var cred = new Credential { var credential = new Credential
{
SecretId = Options.SecretId, SecretId = Options.SecretId,
SecretKey = Options.SecretKey SecretKey = Options.SecretKey
}; };
var clientProfile = new ClientProfile(); var clientProfile = new ClientProfile
clientProfile.HttpProfile = new HttpProfile()
{ {
Endpoint = Options.Endpoint HttpProfile = new HttpProfile
{
Endpoint = Options.Endpoint
}
}; };
return new SmsClient(cred,Options.Region,clientProfile); return new SmsClient(credential, Options.Region, clientProfile);
} }
} }

4
framework/test/Volo.Abp.Sms.TencenCloud.Tests/Volo/Abp/Sms/TencentCloud/AbpSmsTencentCloudTestsModule.cs

@ -10,8 +10,6 @@ public class AbpSmsTencentCloudTestsModule : AbpModule
{ {
var configuration = context.Services.GetConfiguration(); var configuration = context.Services.GetConfiguration();
Configure<AbpTencentCloudSmsOptions>( Configure<AbpTencentCloudSmsOptions>(configuration.GetSection("AbpTencentCloudSms"));
configuration.GetSection("AbpTencentCloudSms")
);
} }
} }

1
nupkg/common.ps1

@ -232,6 +232,7 @@ $projects = (
"framework/src/Volo.Abp.Settings", "framework/src/Volo.Abp.Settings",
"framework/src/Volo.Abp.Sms", "framework/src/Volo.Abp.Sms",
"framework/src/Volo.Abp.Sms.Aliyun", "framework/src/Volo.Abp.Sms.Aliyun",
"framework/src/Volo.Abp.Sms.TencentCloud",
"framework/src/Volo.Abp.Specifications", "framework/src/Volo.Abp.Specifications",
"framework/src/Volo.Abp.TestBase", "framework/src/Volo.Abp.TestBase",
"framework/src/Volo.Abp.TextTemplating", "framework/src/Volo.Abp.TextTemplating",

Loading…
Cancel
Save