mirror of https://github.com/abpframework/abp.git
committed by
GitHub
18 changed files with 334 additions and 1 deletions
@ -0,0 +1,3 @@ |
|||||
|
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
||||
|
<ConfigureAwait ContinueOnCapturedContext="false"/> |
||||
|
</Weavers> |
||||
@ -0,0 +1,30 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
||||
|
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
||||
|
<xs:element name="Weavers"> |
||||
|
<xs:complexType> |
||||
|
<xs:all> |
||||
|
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
||||
|
<xs:complexType> |
||||
|
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
</xs:all> |
||||
|
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
</xs:schema> |
||||
@ -0,0 +1,3 @@ |
|||||
|
{ |
||||
|
"role": "lib.framework" |
||||
|
} |
||||
@ -0,0 +1,63 @@ |
|||||
|
{ |
||||
|
"name": "Volo.Abp.Sms.TencentCloud", |
||||
|
"hash": "", |
||||
|
"contents": [ |
||||
|
{ |
||||
|
"namespace": "Volo.Abp.Sms.TencentCloud", |
||||
|
"dependsOnModules": [ |
||||
|
{ |
||||
|
"declaringAssemblyName": "Volo.Abp.Sms", |
||||
|
"namespace": "Volo.Abp.Sms", |
||||
|
"name": "AbpSmsModule" |
||||
|
} |
||||
|
], |
||||
|
"implementingInterfaces": [ |
||||
|
{ |
||||
|
"name": "IAbpModule", |
||||
|
"namespace": "Volo.Abp.Modularity", |
||||
|
"declaringAssemblyName": "Volo.Abp.Core", |
||||
|
"fullName": "Volo.Abp.Modularity.IAbpModule" |
||||
|
}, |
||||
|
{ |
||||
|
"name": "IOnPreApplicationInitialization", |
||||
|
"namespace": "Volo.Abp.Modularity", |
||||
|
"declaringAssemblyName": "Volo.Abp.Core", |
||||
|
"fullName": "Volo.Abp.Modularity.IOnPreApplicationInitialization" |
||||
|
}, |
||||
|
{ |
||||
|
"name": "IOnApplicationInitialization", |
||||
|
"namespace": "Volo.Abp", |
||||
|
"declaringAssemblyName": "Volo.Abp.Core", |
||||
|
"fullName": "Volo.Abp.IOnApplicationInitialization" |
||||
|
}, |
||||
|
{ |
||||
|
"name": "IOnPostApplicationInitialization", |
||||
|
"namespace": "Volo.Abp.Modularity", |
||||
|
"declaringAssemblyName": "Volo.Abp.Core", |
||||
|
"fullName": "Volo.Abp.Modularity.IOnPostApplicationInitialization" |
||||
|
}, |
||||
|
{ |
||||
|
"name": "IOnApplicationShutdown", |
||||
|
"namespace": "Volo.Abp", |
||||
|
"declaringAssemblyName": "Volo.Abp.Core", |
||||
|
"fullName": "Volo.Abp.IOnApplicationShutdown" |
||||
|
}, |
||||
|
{ |
||||
|
"name": "IPreConfigureServices", |
||||
|
"namespace": "Volo.Abp.Modularity", |
||||
|
"declaringAssemblyName": "Volo.Abp.Core", |
||||
|
"fullName": "Volo.Abp.Modularity.IPreConfigureServices" |
||||
|
}, |
||||
|
{ |
||||
|
"name": "IPostConfigureServices", |
||||
|
"namespace": "Volo.Abp.Modularity", |
||||
|
"declaringAssemblyName": "Volo.Abp.Core", |
||||
|
"fullName": "Volo.Abp.Modularity.IPostConfigureServices" |
||||
|
} |
||||
|
], |
||||
|
"contentType": "abpModule", |
||||
|
"name": "AbpSmsTencentCloudModule", |
||||
|
"summary": null |
||||
|
} |
||||
|
] |
||||
|
} |
||||
@ -0,0 +1,26 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
<Import Project="..\..\..\configureawait.props" /> |
||||
|
<Import Project="..\..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0;net9.0</TargetFrameworks> |
||||
|
<Nullable>enable</Nullable> |
||||
|
<WarningsAsErrors>Nullable</WarningsAsErrors> |
||||
|
<AssemblyName>Volo.Abp.Sms.TencentCloud</AssemblyName> |
||||
|
<PackageId>Volo.Abp.Sms.TencentCloud</PackageId> |
||||
|
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback> |
||||
|
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> |
||||
|
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> |
||||
|
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> |
||||
|
<RootNamespace /> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\Volo.Abp.Sms\Volo.Abp.Sms.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="TencentCloudSDK.Sms" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,15 @@ |
|||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Volo.Abp.Modularity; |
||||
|
|
||||
|
namespace Volo.Abp.Sms.TencentCloud; |
||||
|
|
||||
|
[DependsOn(typeof(AbpSmsModule))] |
||||
|
public class AbpSmsTencentCloudModule : AbpModule |
||||
|
{ |
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
var configuration = context.Services.GetConfiguration(); |
||||
|
|
||||
|
Configure<AbpTencentCloudSmsOptions>(configuration.GetSection("AbpTencentCloudSms")); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,14 @@ |
|||||
|
namespace Volo.Abp.Sms.TencentCloud; |
||||
|
|
||||
|
public class AbpTencentCloudSmsOptions |
||||
|
{ |
||||
|
public string SmsSdkAppId { get; set; } = default!; |
||||
|
|
||||
|
public string SecretKey { get; set; } = default!; |
||||
|
|
||||
|
public string SecretId { get; set; } = default!; |
||||
|
|
||||
|
public string Endpoint { get; set; } = "sms.tencentcloudapi.com"; |
||||
|
|
||||
|
public string Region { get; set; } = "ap-guangzhou"; |
||||
|
} |
||||
@ -0,0 +1,8 @@ |
|||||
|
namespace Volo.Abp.Sms.TencentCloud; |
||||
|
|
||||
|
public static class TencentCloudSmsProperties |
||||
|
{ |
||||
|
public const string SignName = "SignName"; |
||||
|
|
||||
|
public const string TemplateId = "TemplateId"; |
||||
|
} |
||||
@ -0,0 +1,51 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.Extensions.Options; |
||||
|
using TencentCloud.Common; |
||||
|
using TencentCloud.Common.Profile; |
||||
|
using TencentCloud.Sms.V20210111; |
||||
|
using TencentCloud.Sms.V20210111.Models; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
|
namespace Volo.Abp.Sms.TencentCloud; |
||||
|
|
||||
|
public class TencentCloudSmsSender : ISmsSender, ITransientDependency |
||||
|
{ |
||||
|
protected AbpTencentCloudSmsOptions Options { get; } |
||||
|
|
||||
|
public TencentCloudSmsSender(IOptionsMonitor<AbpTencentCloudSmsOptions> options) |
||||
|
{ |
||||
|
Options = options.CurrentValue; |
||||
|
} |
||||
|
|
||||
|
public virtual async Task SendAsync(SmsMessage smsMessage) |
||||
|
{ |
||||
|
var client = CreateClient(); |
||||
|
|
||||
|
await client.SendSms(new SendSmsRequest() |
||||
|
{ |
||||
|
SmsSdkAppId = Options.SmsSdkAppId, |
||||
|
SignName = smsMessage.Properties.GetOrDefault(TencentCloudSmsProperties.SignName) as string, |
||||
|
TemplateId = smsMessage.Properties.GetOrDefault(TencentCloudSmsProperties.TemplateId) as string, |
||||
|
TemplateParamSet = smsMessage.Text.Split(','), |
||||
|
PhoneNumberSet = [smsMessage.PhoneNumber] |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
protected virtual SmsClient CreateClient() |
||||
|
{ |
||||
|
var credential = new Credential |
||||
|
{ |
||||
|
SecretId = Options.SecretId, |
||||
|
SecretKey = Options.SecretKey |
||||
|
}; |
||||
|
var clientProfile = new ClientProfile |
||||
|
{ |
||||
|
HttpProfile = new HttpProfile |
||||
|
{ |
||||
|
Endpoint = Options.Endpoint |
||||
|
} |
||||
|
}; |
||||
|
return new SmsClient(credential, Options.Region, clientProfile); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,3 @@ |
|||||
|
{ |
||||
|
"role": "lib.test" |
||||
|
} |
||||
@ -0,0 +1,26 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<Import Project="..\..\..\common.test.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>net9.0</TargetFramework> |
||||
|
<RootNamespace /> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\..\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" /> |
||||
|
<ProjectReference Include="..\..\src\Volo.Abp.Sms.TencentCloud\Volo.Abp.Sms.TencentCloud.csproj" /> |
||||
|
<ProjectReference Include="..\..\src\Volo.Abp.Sms\Volo.Abp.Sms.csproj" /> |
||||
|
<ProjectReference Include="..\AbpTestBase\AbpTestBase.csproj" /> |
||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" /> |
||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<None Remove="appsettings.json" /> |
||||
|
<Content Include="appsettings.json"> |
||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
||||
|
</Content> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,11 @@ |
|||||
|
using Volo.Abp.Testing; |
||||
|
|
||||
|
namespace Volo.Abp.Sms.TencentCloud; |
||||
|
|
||||
|
public class AbpSmsTencentCloudTestBase : AbpIntegratedTest<AbpSmsTencentCloudTestsModule> |
||||
|
{ |
||||
|
protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options) |
||||
|
{ |
||||
|
options.UseAutofac(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,15 @@ |
|||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Volo.Abp.Modularity; |
||||
|
|
||||
|
namespace Volo.Abp.Sms.TencentCloud; |
||||
|
|
||||
|
[DependsOn(typeof(AbpSmsTencentCloudModule))] |
||||
|
public class AbpSmsTencentCloudTestsModule : AbpModule |
||||
|
{ |
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
var configuration = context.Services.GetConfiguration(); |
||||
|
|
||||
|
Configure<AbpTencentCloudSmsOptions>(configuration.GetSection("AbpTencentCloudSms")); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,36 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Volo.Abp.Sms.TencentCloud; |
||||
|
|
||||
|
public class TencentCloudSmsSenderTests : AbpSmsTencentCloudTestBase |
||||
|
{ |
||||
|
private readonly ISmsSender _smsSender; |
||||
|
private readonly IConfiguration _configuration; |
||||
|
|
||||
|
public TencentCloudSmsSenderTests() |
||||
|
{ |
||||
|
_configuration = GetRequiredService<IConfiguration>(); |
||||
|
_smsSender = GetRequiredService<ISmsSender>(); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public async Task SendSms_Test() |
||||
|
{ |
||||
|
var config = _configuration.GetSection("AbpTencentCloudSms"); |
||||
|
|
||||
|
// Please fill in the real parameters in the appsettings.json file.
|
||||
|
if (config["SecretId"] == "<Enter your SecretId from TencentCloud>") |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
var msg = new SmsMessage(config["TargetPhoneNumber"], |
||||
|
config["TemplateParam"]); |
||||
|
msg.Properties.Add(TencentCloudSmsProperties.SignName, config["SignName"]); |
||||
|
msg.Properties.Add(TencentCloudSmsProperties.TemplateId, config["TemplateId"]); |
||||
|
|
||||
|
await _smsSender.SendAsync(msg); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,13 @@ |
|||||
|
{ |
||||
|
"AbpTencentCloudSms": { |
||||
|
"SecretId": "<Enter your SecretId from TencentCloud>", |
||||
|
"SecretKey": "<Enter your SecretKey from TencentCloud>", |
||||
|
"Region": "<Enter your Region from TencentCloud>", |
||||
|
"SmsSdkAppId": "<Enter your SmsSdkAppId from TencentCloud>", |
||||
|
"Endpoint": "<Enter your EndPoint from TencentCloud>", |
||||
|
"TargetPhoneNumber": "<Enter the target phone number to receive the SMS>", |
||||
|
"SignName": "<Enter the SignName from TencentCloud>", |
||||
|
"TemplateId": "<Enter the TemplateId you need to send>", |
||||
|
"TemplateParam": "<Enter the template parameters,split by ','>" |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue