Browse Source

feat: optimize push service

pull/663/head
cKey 3 years ago
parent
commit
1fd6b5a996
  1. 57
      aspnet-core/LINGYUN.MicroService.All.sln
  2. 25
      aspnet-core/LINGYUN.MicroService.Common.sln
  3. 2
      aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/AbpNotificationModule.cs
  4. 5
      aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/INotificationPublishProvider.cs
  5. 22
      aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/NotificationPublishProvider.cs
  6. 33
      aspnet-core/modules/pushplus/LINGYUN.Abp.Notifications.PushPlus/LINGYUN/Abp/Notifications/NotificationDataExtensions.cs
  7. 43
      aspnet-core/modules/pushplus/LINGYUN.Abp.Notifications.PushPlus/LINGYUN/Abp/Notifications/NotificationDefinitionExtensions.cs
  8. 30
      aspnet-core/modules/pushplus/LINGYUN.Abp.Notifications.PushPlus/LINGYUN/Abp/Notifications/PushPlus/PushPlusNotificationPublishProvider.cs
  9. 10
      aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus/LINGYUN/Abp/PushPlus/Features/PushPlusFeatureDefinitionProvider.cs
  10. 20
      aspnet-core/modules/wechat/LINGYUN.Abp.Notifications.WeChat.MiniProgram/LINGYUN/Abp/Notifications/WeChat/MiniProgram/WeChatMiniProgramNotificationPublishProvider.cs
  11. 31
      aspnet-core/modules/wx-pusher/LINGYUN.Abp.Identity.WxPusher/LINGYUN/Abp/Identity/WxPusher/User/IdentityWxPusherUserStore.cs
  12. 3
      aspnet-core/modules/wx-pusher/LINGYUN.Abp.Notifications.WxPusher/FodyWeavers.xml
  13. 30
      aspnet-core/modules/wx-pusher/LINGYUN.Abp.Notifications.WxPusher/FodyWeavers.xsd
  14. 19
      aspnet-core/modules/wx-pusher/LINGYUN.Abp.Notifications.WxPusher/LINGYUN/Abp/Notifications/NotificationDataExtensions.cs
  15. 29
      aspnet-core/modules/wx-pusher/LINGYUN.Abp.Notifications.WxPusher/LINGYUN/Abp/Notifications/NotificationDefinitionExtensions.cs
  16. 2
      aspnet-core/modules/wx-pusher/LINGYUN.Abp.Notifications.WxPusher/LINGYUN/Abp/Notifications/WxPusher/AbpNotificationsWxPusherModule.cs
  17. 33
      aspnet-core/modules/wx-pusher/LINGYUN.Abp.Notifications.WxPusher/LINGYUN/Abp/Notifications/WxPusher/WxPusherNotificationPublishProvider.cs
  18. 4
      aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN/Abp/WxPusher/Features/WxPusherFeatureDefinitionProvider.cs
  19. 6
      aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN/Abp/WxPusher/Security/Claims/AbpWxPusherClaimTypes.cs
  20. 9
      aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN/Abp/WxPusher/User/IWxPusherUserStore.cs
  21. 7
      aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN/Abp/WxPusher/User/NullWxPusherUserStore.cs
  22. 2
      aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/LY.MicroService.RealtimeMessage.HttpApi.Host.csproj
  23. 4
      aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.cs
  24. 205
      aspnet-core/tests/LINGYUN.Abp.Notifications.Tests/LINGYUN/Abp/Notifications/FakeNotificationSender.cs
  25. 2
      aspnet-core/tests/LINGYUN.Abp.Notifications.Tests/LINGYUN/Abp/Notifications/NotificationsTestsNames.cs
  26. 20
      aspnet-core/tests/LINGYUN.Abp.Notifications.WxPusher.Tests/LINGYUN.Abp.Notifications.WxPusher.Tests.csproj
  27. 7
      aspnet-core/tests/LINGYUN.Abp.Notifications.WxPusher.Tests/LINGYUN/Abp/Notifications/WxPusher/AbpNotificationsWxPusherTestBase.cs
  28. 12
      aspnet-core/tests/LINGYUN.Abp.Notifications.WxPusher.Tests/LINGYUN/Abp/Notifications/WxPusher/AbpNotificationsWxPusherTestModule.cs
  29. 77
      aspnet-core/tests/LINGYUN.Abp.Notifications.WxPusher.Tests/LINGYUN/Abp/Notifications/WxPusher/NotificationSenderTests.cs
  30. 28
      aspnet-core/tests/LINGYUN.Abp.Notifications.WxPusher.Tests/LINGYUN/Abp/Notifications/WxPusher/NotificationsWxPusherTestsDefinitionProvider.cs
  31. 2
      aspnet-core/tests/LINGYUN.Abp.Notifications.WxPusher.Tests/Usings.cs

57
aspnet-core/LINGYUN.MicroService.All.sln

@ -442,7 +442,25 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.CachingManageme
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.CachingManagement.HttpApi", "modules\caching\LINGYUN.Abp.CachingManagement.HttpApi\LINGYUN.Abp.CachingManagement.HttpApi.csproj", "{B507D18B-770E-4581-854B-15579AC7074F}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.CachingManagement.HttpApi", "modules\caching\LINGYUN.Abp.CachingManagement.HttpApi\LINGYUN.Abp.CachingManagement.HttpApi.csproj", "{B507D18B-770E-4581-854B-15579AC7074F}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.DistributedLocking.Dapr", "modules\dapr\LINGYUN.Abp.DistributedLocking.Dapr\LINGYUN.Abp.DistributedLocking.Dapr.csproj", "{178AF3DE-1C24-41A9-8CA0-64A7D85DDFFE}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.DistributedLocking.Dapr", "modules\dapr\LINGYUN.Abp.DistributedLocking.Dapr\LINGYUN.Abp.DistributedLocking.Dapr.csproj", "{178AF3DE-1C24-41A9-8CA0-64A7D85DDFFE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "wx-pusher", "wx-pusher", "{53DF60C5-AE45-4FCE-9C9B-EE15F0E33BD4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.WxPusher", "modules\wx-pusher\LINGYUN.Abp.WxPusher\LINGYUN.Abp.WxPusher.csproj", "{7C4C266C-DC2A-4A48-AB87-185E284B86E9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Notifications.WxPusher", "modules\wx-pusher\LINGYUN.Abp.Notifications.WxPusher\LINGYUN.Abp.Notifications.WxPusher.csproj", "{0380623A-EC74-430B-AA59-A6D23BC5E108}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.WxPusher.SettingManagement", "modules\wx-pusher\LINGYUN.Abp.WxPusher.SettingManagement\LINGYUN.Abp.WxPusher.SettingManagement.csproj", "{C6BDAB62-0B82-4ED2-8455-2FEA1F1B1EAD}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Identity.WxPusher", "modules\wx-pusher\LINGYUN.Abp.Identity.WxPusher\LINGYUN.Abp.Identity.WxPusher.csproj", "{C9BB4BB2-97B8-4CDE-B961-2F0A4CB5D7B1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "pushplus", "pushplus", "{A8F1C9FA-4F16-43F9-8CC6-CCD124154440}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.PushPlus", "modules\pushplus\LINGYUN.Abp.PushPlus\LINGYUN.Abp.PushPlus.csproj", "{82CB7E17-ED5A-4D26-B116-BA7B4226E43C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.PushPlus.SettingManagement", "modules\pushplus\LINGYUN.Abp.PushPlus.SettingManagement\LINGYUN.Abp.PushPlus.SettingManagement.csproj", "{102C3711-135E-446D-9A35-AEFB79993CAA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Notifications.PushPlus", "modules\pushplus\LINGYUN.Abp.Notifications.PushPlus\LINGYUN.Abp.Notifications.PushPlus.csproj", "{2B7C1441-8801-4121-ABFB-03771E9DFE46}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -1154,6 +1172,34 @@ Global
{178AF3DE-1C24-41A9-8CA0-64A7D85DDFFE}.Debug|Any CPU.Build.0 = Debug|Any CPU {178AF3DE-1C24-41A9-8CA0-64A7D85DDFFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{178AF3DE-1C24-41A9-8CA0-64A7D85DDFFE}.Release|Any CPU.ActiveCfg = Release|Any CPU {178AF3DE-1C24-41A9-8CA0-64A7D85DDFFE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{178AF3DE-1C24-41A9-8CA0-64A7D85DDFFE}.Release|Any CPU.Build.0 = Release|Any CPU {178AF3DE-1C24-41A9-8CA0-64A7D85DDFFE}.Release|Any CPU.Build.0 = Release|Any CPU
{7C4C266C-DC2A-4A48-AB87-185E284B86E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7C4C266C-DC2A-4A48-AB87-185E284B86E9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7C4C266C-DC2A-4A48-AB87-185E284B86E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7C4C266C-DC2A-4A48-AB87-185E284B86E9}.Release|Any CPU.Build.0 = Release|Any CPU
{0380623A-EC74-430B-AA59-A6D23BC5E108}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0380623A-EC74-430B-AA59-A6D23BC5E108}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0380623A-EC74-430B-AA59-A6D23BC5E108}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0380623A-EC74-430B-AA59-A6D23BC5E108}.Release|Any CPU.Build.0 = Release|Any CPU
{C6BDAB62-0B82-4ED2-8455-2FEA1F1B1EAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C6BDAB62-0B82-4ED2-8455-2FEA1F1B1EAD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C6BDAB62-0B82-4ED2-8455-2FEA1F1B1EAD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C6BDAB62-0B82-4ED2-8455-2FEA1F1B1EAD}.Release|Any CPU.Build.0 = Release|Any CPU
{C9BB4BB2-97B8-4CDE-B961-2F0A4CB5D7B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C9BB4BB2-97B8-4CDE-B961-2F0A4CB5D7B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C9BB4BB2-97B8-4CDE-B961-2F0A4CB5D7B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C9BB4BB2-97B8-4CDE-B961-2F0A4CB5D7B1}.Release|Any CPU.Build.0 = Release|Any CPU
{82CB7E17-ED5A-4D26-B116-BA7B4226E43C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{82CB7E17-ED5A-4D26-B116-BA7B4226E43C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{82CB7E17-ED5A-4D26-B116-BA7B4226E43C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{82CB7E17-ED5A-4D26-B116-BA7B4226E43C}.Release|Any CPU.Build.0 = Release|Any CPU
{102C3711-135E-446D-9A35-AEFB79993CAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{102C3711-135E-446D-9A35-AEFB79993CAA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{102C3711-135E-446D-9A35-AEFB79993CAA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{102C3711-135E-446D-9A35-AEFB79993CAA}.Release|Any CPU.Build.0 = Release|Any CPU
{2B7C1441-8801-4121-ABFB-03771E9DFE46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2B7C1441-8801-4121-ABFB-03771E9DFE46}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2B7C1441-8801-4121-ABFB-03771E9DFE46}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2B7C1441-8801-4121-ABFB-03771E9DFE46}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -1371,6 +1417,15 @@ Global
{08CC528E-98D7-41D9-957D-9F9064645788} = {63FCC71F-1CEF-44D3-B95B-23EE58DE8C95} {08CC528E-98D7-41D9-957D-9F9064645788} = {63FCC71F-1CEF-44D3-B95B-23EE58DE8C95}
{B507D18B-770E-4581-854B-15579AC7074F} = {63FCC71F-1CEF-44D3-B95B-23EE58DE8C95} {B507D18B-770E-4581-854B-15579AC7074F} = {63FCC71F-1CEF-44D3-B95B-23EE58DE8C95}
{178AF3DE-1C24-41A9-8CA0-64A7D85DDFFE} = {DC33925B-264D-421B-96CC-46F853CBCC70} {178AF3DE-1C24-41A9-8CA0-64A7D85DDFFE} = {DC33925B-264D-421B-96CC-46F853CBCC70}
{53DF60C5-AE45-4FCE-9C9B-EE15F0E33BD4} = {C5CAD011-DF84-4914-939C-0C029DCEF26F}
{7C4C266C-DC2A-4A48-AB87-185E284B86E9} = {53DF60C5-AE45-4FCE-9C9B-EE15F0E33BD4}
{0380623A-EC74-430B-AA59-A6D23BC5E108} = {53DF60C5-AE45-4FCE-9C9B-EE15F0E33BD4}
{C6BDAB62-0B82-4ED2-8455-2FEA1F1B1EAD} = {53DF60C5-AE45-4FCE-9C9B-EE15F0E33BD4}
{C9BB4BB2-97B8-4CDE-B961-2F0A4CB5D7B1} = {53DF60C5-AE45-4FCE-9C9B-EE15F0E33BD4}
{A8F1C9FA-4F16-43F9-8CC6-CCD124154440} = {C5CAD011-DF84-4914-939C-0C029DCEF26F}
{82CB7E17-ED5A-4D26-B116-BA7B4226E43C} = {A8F1C9FA-4F16-43F9-8CC6-CCD124154440}
{102C3711-135E-446D-9A35-AEFB79993CAA} = {A8F1C9FA-4F16-43F9-8CC6-CCD124154440}
{2B7C1441-8801-4121-ABFB-03771E9DFE46} = {A8F1C9FA-4F16-43F9-8CC6-CCD124154440}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C95FDF91-16F2-4A8B-A4BE-0E62D1B66718} SolutionGuid = {C95FDF91-16F2-4A8B-A4BE-0E62D1B66718}

25
aspnet-core/LINGYUN.MicroService.Common.sln

@ -260,9 +260,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Notifications.W
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Identity.WxPusher", "modules\wx-pusher\LINGYUN.Abp.Identity.WxPusher\LINGYUN.Abp.Identity.WxPusher.csproj", "{30FA01ED-921A-4E7D-9E83-6719538FB866}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Identity.WxPusher", "modules\wx-pusher\LINGYUN.Abp.Identity.WxPusher\LINGYUN.Abp.Identity.WxPusher.csproj", "{30FA01ED-921A-4E7D-9E83-6719538FB866}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.WxPusher.SettingManagement", "modules\wx-pusher\LINGYUN.Abp.WxPusher.SettingManagement\LINGYUN.Abp.WxPusher.SettingManagement.csproj", "{E6FDAD7B-4A7F-4CEB-9891-F8FC4E556C36}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.WxPusher.SettingManagement", "modules\wx-pusher\LINGYUN.Abp.WxPusher.SettingManagement\LINGYUN.Abp.WxPusher.SettingManagement.csproj", "{E6FDAD7B-4A7F-4CEB-9891-F8FC4E556C36}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.PushPlus.SettingManagement", "modules\pushplus\LINGYUN.Abp.PushPlus.SettingManagement\LINGYUN.Abp.PushPlus.SettingManagement.csproj", "{4CBB4A0C-6D23-44DD-BAF4-49D69ED35839}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.PushPlus.SettingManagement", "modules\pushplus\LINGYUN.Abp.PushPlus.SettingManagement\LINGYUN.Abp.PushPlus.SettingManagement.csproj", "{4CBB4A0C-6D23-44DD-BAF4-49D69ED35839}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Notifications.WxPusher.Tests", "tests\LINGYUN.Abp.Notifications.WxPusher.Tests\LINGYUN.Abp.Notifications.WxPusher.Tests.csproj", "{C2801414-550F-4A25-AD8D-68AC508211DC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Notifications.Tests", "tests\LINGYUN.Abp.Notifications.Tests\LINGYUN.Abp.Notifications.Tests.csproj", "{868A1718-4970-48D2-A256-08EF468302D8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Notifications.WeChat.MiniProgram.Tests", "tests\LINGYUN.Abp.Notifications.WeChat.MiniProgram.Tests\LINGYUN.Abp.Notifications.WeChat.MiniProgram.Tests.csproj", "{B78E53AC-6BB8-402D-90CF-BEF1BD9558EB}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -678,6 +684,18 @@ Global
{4CBB4A0C-6D23-44DD-BAF4-49D69ED35839}.Debug|Any CPU.Build.0 = Debug|Any CPU {4CBB4A0C-6D23-44DD-BAF4-49D69ED35839}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4CBB4A0C-6D23-44DD-BAF4-49D69ED35839}.Release|Any CPU.ActiveCfg = Release|Any CPU {4CBB4A0C-6D23-44DD-BAF4-49D69ED35839}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4CBB4A0C-6D23-44DD-BAF4-49D69ED35839}.Release|Any CPU.Build.0 = Release|Any CPU {4CBB4A0C-6D23-44DD-BAF4-49D69ED35839}.Release|Any CPU.Build.0 = Release|Any CPU
{C2801414-550F-4A25-AD8D-68AC508211DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C2801414-550F-4A25-AD8D-68AC508211DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C2801414-550F-4A25-AD8D-68AC508211DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C2801414-550F-4A25-AD8D-68AC508211DC}.Release|Any CPU.Build.0 = Release|Any CPU
{868A1718-4970-48D2-A256-08EF468302D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{868A1718-4970-48D2-A256-08EF468302D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{868A1718-4970-48D2-A256-08EF468302D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{868A1718-4970-48D2-A256-08EF468302D8}.Release|Any CPU.Build.0 = Release|Any CPU
{B78E53AC-6BB8-402D-90CF-BEF1BD9558EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B78E53AC-6BB8-402D-90CF-BEF1BD9558EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B78E53AC-6BB8-402D-90CF-BEF1BD9558EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B78E53AC-6BB8-402D-90CF-BEF1BD9558EB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -809,6 +827,9 @@ Global
{30FA01ED-921A-4E7D-9E83-6719538FB866} = {7862CE70-76EF-4228-A703-C2E2A9704D14} {30FA01ED-921A-4E7D-9E83-6719538FB866} = {7862CE70-76EF-4228-A703-C2E2A9704D14}
{E6FDAD7B-4A7F-4CEB-9891-F8FC4E556C36} = {7862CE70-76EF-4228-A703-C2E2A9704D14} {E6FDAD7B-4A7F-4CEB-9891-F8FC4E556C36} = {7862CE70-76EF-4228-A703-C2E2A9704D14}
{4CBB4A0C-6D23-44DD-BAF4-49D69ED35839} = {0F5A2591-CE08-4184-A5F3-89F6FB3B2B10} {4CBB4A0C-6D23-44DD-BAF4-49D69ED35839} = {0F5A2591-CE08-4184-A5F3-89F6FB3B2B10}
{C2801414-550F-4A25-AD8D-68AC508211DC} = {B86C21A4-73B7-471E-B73A-B4B905EC9435}
{868A1718-4970-48D2-A256-08EF468302D8} = {B86C21A4-73B7-471E-B73A-B4B905EC9435}
{B78E53AC-6BB8-402D-90CF-BEF1BD9558EB} = {B86C21A4-73B7-471E-B73A-B4B905EC9435}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {06C707C6-02C0-411A-AD3B-2D0E13787CB8} SolutionGuid = {06C707C6-02C0-411A-AD3B-2D0E13787CB8}

2
aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/AbpNotificationModule.cs

@ -6,6 +6,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using Volo.Abp.BackgroundJobs; using Volo.Abp.BackgroundJobs;
using Volo.Abp.BackgroundWorkers; using Volo.Abp.BackgroundWorkers;
using Volo.Abp.EventBus;
using Volo.Abp.Json; using Volo.Abp.Json;
using Volo.Abp.Json.SystemTextJson; using Volo.Abp.Json.SystemTextJson;
using Volo.Abp.Localization; using Volo.Abp.Localization;
@ -23,6 +24,7 @@ namespace LINGYUN.Abp.Notifications
typeof(AbpJsonModule), typeof(AbpJsonModule),
typeof(AbpLocalizationModule), typeof(AbpLocalizationModule),
typeof(AbpRealTimeModule), typeof(AbpRealTimeModule),
typeof(AbpEventBusModule),
typeof(AbpTextTemplatingCoreModule))] typeof(AbpTextTemplatingCoreModule))]
public class AbpNotificationModule : AbpModule public class AbpNotificationModule : AbpModule
{ {

5
aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/INotificationPublishProvider.cs

@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace LINGYUN.Abp.Notifications namespace LINGYUN.Abp.Notifications
@ -18,6 +19,8 @@ namespace LINGYUN.Abp.Notifications
/// <param name="notification">通知信息</param> /// <param name="notification">通知信息</param>
/// <param name="identifiers">接收用户列表</param> /// <param name="identifiers">接收用户列表</param>
/// <returns></returns> /// <returns></returns>
Task PublishAsync(NotificationInfo notification, IEnumerable<UserIdentifier> identifiers); Task PublishAsync(
NotificationInfo notification,
IEnumerable<UserIdentifier> identifiers);
} }
} }

22
aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/NotificationPublishProvider.cs

@ -22,9 +22,27 @@ namespace LINGYUN.Abp.Notifications
public ICancellationTokenProvider CancellationTokenProvider => ServiceProvider.LazyGetService<ICancellationTokenProvider>(NullCancellationTokenProvider.Instance); public ICancellationTokenProvider CancellationTokenProvider => ServiceProvider.LazyGetService<ICancellationTokenProvider>(NullCancellationTokenProvider.Instance);
public async Task PublishAsync(NotificationInfo notification, IEnumerable<UserIdentifier> identifiers) public async Task PublishAsync(
NotificationInfo notification,
IEnumerable<UserIdentifier> identifiers)
{ {
await PublishAsync(notification, identifiers, CancellationTokenProvider.Token); if (await CanPublishAsync(notification))
{
await PublishAsync(
notification,
identifiers,
GetCancellationToken());
}
}
protected virtual Task<bool> CanPublishAsync(
NotificationInfo notification,
CancellationToken cancellationToken = default)
{
return Task.FromResult(true);
}
protected virtual CancellationToken GetCancellationToken(CancellationToken cancellationToken = default)
{
return CancellationTokenProvider.FallbackToProvider(cancellationToken);
} }
/// <summary> /// <summary>
/// 重写实现通知发布 /// 重写实现通知发布

33
aspnet-core/modules/pushplus/LINGYUN.Abp.Notifications.PushPlus/LINGYUN/Abp/Notifications/NotificationDataExtensions.cs

@ -0,0 +1,33 @@
namespace LINGYUN.Abp.Notifications;
public static class NotificationDataExtensions
{
private const string Prefix = "push-plus:";
private const string WebhookKey = Prefix + "webhook";
private const string CallbackUrlKey = Prefix + "callback";
public static void SetWebhook(
this NotificationData notificationData,
string url)
{
notificationData.TrySetData(WebhookKey, url);
}
public static string GetWebhookOrNull(
this NotificationData notificationData)
{
return notificationData.TryGetData(WebhookKey)?.ToString();
}
public static void SetCallbackUrl(
this NotificationData notificationData,
string callbackUrl)
{
notificationData.TrySetData(CallbackUrlKey, callbackUrl);
}
public static string GetCallbackUrlOrNull(
this NotificationData notificationData)
{
return notificationData.TryGetData(CallbackUrlKey)?.ToString();
}
}

43
aspnet-core/modules/pushplus/LINGYUN.Abp.Notifications.PushPlus/LINGYUN/Abp/Notifications/NotificationDefinitionExtensions.cs

@ -1,9 +1,44 @@
using LINGYUN.Abp.PushPlus.Channel; using LINGYUN.Abp.PushPlus.Channel;
using LINGYUN.Abp.PushPlus.Message;
using System; using System;
namespace LINGYUN.Abp.Notifications; namespace LINGYUN.Abp.Notifications;
public static class NotificationDefinitionExtensions public static class NotificationDefinitionExtensions
{ {
private const string Prefix = "push-plus:";
private const string TemplateKey = Prefix + "template";
private const string ChannelTypeKey = Prefix + "channel";
private const string TopicKey = Prefix + "topic";
/// <summary>
/// 设定消息模板
/// </summary>
/// <param name="notification"></param>
/// <param name="template"></param>
/// <returns></returns>
public static NotificationDefinition WithTemplate(
this NotificationDefinition notification,
PushPlusMessageTemplate template = PushPlusMessageTemplate.Text)
{
return notification.WithProperty(TemplateKey, template);
}
/// <summary>
/// 获取消息模板
/// </summary>
/// <param name="notification"></param>
/// <param name="defaultTemplate"></param>
/// <returns></returns>
public static PushPlusMessageTemplate GetTemplateOrDefault(
this NotificationDefinition notification,
PushPlusMessageTemplate defaultTemplate = PushPlusMessageTemplate.Text)
{
if (notification.Properties.TryGetValue(TemplateKey, out var defineTemplate) == true &&
defineTemplate is PushPlusMessageTemplate template)
{
return template;
}
return defaultTemplate;
}
/// <summary> /// <summary>
/// 设定消息发送通道 /// 设定消息发送通道
/// </summary> /// </summary>
@ -14,7 +49,7 @@ public static class NotificationDefinitionExtensions
this NotificationDefinition notification, this NotificationDefinition notification,
PushPlusChannelType channelType) PushPlusChannelType channelType)
{ {
return notification.WithProperty("channel", channelType); return notification.WithProperty(ChannelTypeKey, channelType);
} }
/// <summary> /// <summary>
/// 获取消息发送通道 /// 获取消息发送通道
@ -26,7 +61,7 @@ public static class NotificationDefinitionExtensions
this NotificationDefinition notification, this NotificationDefinition notification,
PushPlusChannelType defaultChannelType = PushPlusChannelType.WeChat) PushPlusChannelType defaultChannelType = PushPlusChannelType.WeChat)
{ {
if (notification.Properties.TryGetValue("channel", out var defineChannelType) == true && if (notification.Properties.TryGetValue(ChannelTypeKey, out var defineChannelType) == true &&
defineChannelType is PushPlusChannelType channelType) defineChannelType is PushPlusChannelType channelType)
{ {
return channelType; return channelType;
@ -47,7 +82,7 @@ public static class NotificationDefinitionExtensions
this NotificationDefinition notification, this NotificationDefinition notification,
string topic) string topic)
{ {
return notification.WithProperty("topic", topic); return notification.WithProperty(TopicKey, topic);
} }
/// <summary> /// <summary>
/// 获取消息群发群组编码 /// 获取消息群发群组编码
@ -59,7 +94,7 @@ public static class NotificationDefinitionExtensions
public static string GetTopicOrNull( public static string GetTopicOrNull(
this NotificationDefinition notification) this NotificationDefinition notification)
{ {
if (notification.Properties.TryGetValue("topic", out var topicDefine) == true) if (notification.Properties.TryGetValue(TopicKey, out var topicDefine) == true)
{ {
return topicDefine.ToString(); return topicDefine.ToString();
} }

30
aspnet-core/modules/pushplus/LINGYUN.Abp.Notifications.PushPlus/LINGYUN/Abp/Notifications/PushPlus/PushPlusNotificationPublishProvider.cs

@ -1,13 +1,16 @@
using LINGYUN.Abp.PushPlus.Channel; using LINGYUN.Abp.PushPlus.Channel;
using LINGYUN.Abp.PushPlus.Features;
using LINGYUN.Abp.PushPlus.Message; using LINGYUN.Abp.PushPlus.Message;
using LINGYUN.Abp.RealTime.Localization; using LINGYUN.Abp.RealTime.Localization;
using Microsoft.Extensions.Localization; using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Features;
using Volo.Abp.Localization; using Volo.Abp.Localization;
namespace LINGYUN.Abp.Notifications.PushPlus; namespace LINGYUN.Abp.Notifications.PushPlus;
@ -18,6 +21,8 @@ public class PushPlusNotificationPublishProvider : NotificationPublishProvider
public override string Name => ProviderName; public override string Name => ProviderName;
protected IFeatureChecker FeatureChecker { get; }
protected IPushPlusMessageSender PushPlusMessageSender { get; } protected IPushPlusMessageSender PushPlusMessageSender { get; }
protected IStringLocalizerFactory LocalizerFactory { get; } protected IStringLocalizerFactory LocalizerFactory { get; }
@ -27,17 +32,32 @@ public class PushPlusNotificationPublishProvider : NotificationPublishProvider
protected INotificationDefinitionManager NotificationDefinitionManager { get; } protected INotificationDefinitionManager NotificationDefinitionManager { get; }
public PushPlusNotificationPublishProvider( public PushPlusNotificationPublishProvider(
IFeatureChecker featureChecker,
IPushPlusMessageSender pushPlusMessageSender, IPushPlusMessageSender pushPlusMessageSender,
IStringLocalizerFactory localizerFactory, IStringLocalizerFactory localizerFactory,
IOptions<AbpLocalizationOptions> localizationOptions, IOptions<AbpLocalizationOptions> localizationOptions,
INotificationDefinitionManager notificationDefinitionManager) INotificationDefinitionManager notificationDefinitionManager)
{ {
FeatureChecker = featureChecker;
PushPlusMessageSender = pushPlusMessageSender; PushPlusMessageSender = pushPlusMessageSender;
LocalizerFactory = localizerFactory; LocalizerFactory = localizerFactory;
LocalizationOptions = localizationOptions.Value; LocalizationOptions = localizationOptions.Value;
NotificationDefinitionManager = notificationDefinitionManager; NotificationDefinitionManager = notificationDefinitionManager;
} }
protected async override Task<bool> CanPublishAsync(NotificationInfo notification, CancellationToken cancellationToken = default)
{
if (!await FeatureChecker.IsEnabledAsync(PushPlusFeatureNames.Message.Enable))
{
Logger.LogWarning(
"{0} cannot push messages because the feature {0} is not enabled",
Name,
PushPlusFeatureNames.Message.Enable);
return false;
}
return true;
}
protected async override Task PublishAsync( protected async override Task PublishAsync(
NotificationInfo notification, NotificationInfo notification,
IEnumerable<UserIdentifier> identifiers, IEnumerable<UserIdentifier> identifiers,
@ -53,6 +73,10 @@ public class PushPlusNotificationPublishProvider : NotificationPublishProvider
} }
var channel = notificationDefine?.GetChannelOrDefault(PushPlusChannelType.Email) var channel = notificationDefine?.GetChannelOrDefault(PushPlusChannelType.Email)
?? PushPlusChannelType.Email; ?? PushPlusChannelType.Email;
var template = notificationDefine?.GetTemplateOrDefault(PushPlusMessageTemplate.Text)
?? PushPlusMessageTemplate.Text;
var webhook = notification.Data.GetWebhookOrNull() ?? "";
var callbackUrl = notification.Data.GetCallbackUrlOrNull() ?? "";
if (!notification.Data.NeedLocalizer()) if (!notification.Data.NeedLocalizer())
{ {
@ -64,6 +88,9 @@ public class PushPlusNotificationPublishProvider : NotificationPublishProvider
message, message,
topic, topic,
channelType: channel, channelType: channel,
template: template,
webhook: webhook,
callbackUrl: callbackUrl,
cancellationToken: cancellationToken); cancellationToken: cancellationToken);
} }
else else
@ -81,6 +108,9 @@ public class PushPlusNotificationPublishProvider : NotificationPublishProvider
message, message,
topic, topic,
channelType: channel, channelType: channel,
template: template,
webhook: webhook,
callbackUrl: callbackUrl,
cancellationToken: cancellationToken); cancellationToken: cancellationToken);
} }
} }

10
aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus/LINGYUN/Abp/PushPlus/Features/PushPlusFeatureDefinitionProvider.cs

@ -14,7 +14,7 @@ public class PushPlusFeatureDefinitionProvider : FeatureDefinitionProvider
group.AddFeature( group.AddFeature(
name: PushPlusFeatureNames.Message.Enable, name: PushPlusFeatureNames.Message.Enable,
defaultValue: "true", defaultValue: "false",
displayName: L("Features:MessageEnable"), displayName: L("Features:MessageEnable"),
description: L("Features:MessageEnableDesc"), description: L("Features:MessageEnableDesc"),
valueType: new ToggleStringValueType(new BooleanValueValidator())); valueType: new ToggleStringValueType(new BooleanValueValidator()));
@ -35,7 +35,7 @@ public class PushPlusFeatureDefinitionProvider : FeatureDefinitionProvider
description: L("Features:Channel.WeChat")); description: L("Features:Channel.WeChat"));
weChatChannel.CreateChild( weChatChannel.CreateChild(
name: PushPlusFeatureNames.Channel.WeChat.Enable, name: PushPlusFeatureNames.Channel.WeChat.Enable,
defaultValue: "true", defaultValue: "false",
displayName: L("Features:Channel.WeChat.Enable"), displayName: L("Features:Channel.WeChat.Enable"),
description: L("Features:Channel.WeChat.EnableDesc"), description: L("Features:Channel.WeChat.EnableDesc"),
valueType: new ToggleStringValueType(new BooleanValueValidator())); valueType: new ToggleStringValueType(new BooleanValueValidator()));
@ -62,7 +62,7 @@ public class PushPlusFeatureDefinitionProvider : FeatureDefinitionProvider
description: L("Features:Channel.WeWork")); description: L("Features:Channel.WeWork"));
weWorkChannel.CreateChild( weWorkChannel.CreateChild(
name: PushPlusFeatureNames.Channel.WeWork.Enable, name: PushPlusFeatureNames.Channel.WeWork.Enable,
defaultValue: "true", defaultValue: "false",
displayName: L("Features:Channel.WeWork.Enable"), displayName: L("Features:Channel.WeWork.Enable"),
description: L("Features:Channel.WeWork.EnableDesc"), description: L("Features:Channel.WeWork.EnableDesc"),
valueType: new ToggleStringValueType(new BooleanValueValidator())); valueType: new ToggleStringValueType(new BooleanValueValidator()));
@ -89,7 +89,7 @@ public class PushPlusFeatureDefinitionProvider : FeatureDefinitionProvider
description: L("Features:Channel.Webhook")); description: L("Features:Channel.Webhook"));
webhookChannel.CreateChild( webhookChannel.CreateChild(
name: PushPlusFeatureNames.Channel.Webhook.Enable, name: PushPlusFeatureNames.Channel.Webhook.Enable,
defaultValue: "true", defaultValue: "false",
displayName: L("Features:Channel.Webhook.Enable"), displayName: L("Features:Channel.Webhook.Enable"),
description: L("Features:Channel.Webhook.EnableDesc"), description: L("Features:Channel.Webhook.EnableDesc"),
valueType: new ToggleStringValueType(new BooleanValueValidator())); valueType: new ToggleStringValueType(new BooleanValueValidator()));
@ -116,7 +116,7 @@ public class PushPlusFeatureDefinitionProvider : FeatureDefinitionProvider
description: L("Features:Channel.Email")); description: L("Features:Channel.Email"));
emailChannel.CreateChild( emailChannel.CreateChild(
name: PushPlusFeatureNames.Channel.Email.Enable, name: PushPlusFeatureNames.Channel.Email.Enable,
defaultValue: "true", defaultValue: "false",
displayName: L("Features:Channel.Email.Enable"), displayName: L("Features:Channel.Email.Enable"),
description: L("Features:Channel.Email.EnableDesc"), description: L("Features:Channel.Email.EnableDesc"),
valueType: new ToggleStringValueType(new BooleanValueValidator())); valueType: new ToggleStringValueType(new BooleanValueValidator()));

20
aspnet-core/modules/wechat/LINGYUN.Abp.Notifications.WeChat.MiniProgram/LINGYUN/Abp/Notifications/WeChat/MiniProgram/WeChatMiniProgramNotificationPublishProvider.cs

@ -1,4 +1,5 @@
using LINGYUN.Abp.WeChat.MiniProgram.Messages; using LINGYUN.Abp.WeChat.MiniProgram.Features;
using LINGYUN.Abp.WeChat.MiniProgram.Messages;
using LINGYUN.Abp.WeChat.Security.Claims; using LINGYUN.Abp.WeChat.Security.Claims;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
@ -6,6 +7,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Features;
namespace LINGYUN.Abp.Notifications.WeChat.MiniProgram namespace LINGYUN.Abp.Notifications.WeChat.MiniProgram
{ {
@ -16,16 +18,32 @@ namespace LINGYUN.Abp.Notifications.WeChat.MiniProgram
{ {
public const string ProviderName = NotificationProviderNames.WechatMiniProgram; public const string ProviderName = NotificationProviderNames.WechatMiniProgram;
public override string Name => ProviderName; public override string Name => ProviderName;
protected IFeatureChecker FeatureChecker { get; }
protected ISubscribeMessager SubscribeMessager { get; } protected ISubscribeMessager SubscribeMessager { get; }
protected AbpNotificationsWeChatMiniProgramOptions Options { get; } protected AbpNotificationsWeChatMiniProgramOptions Options { get; }
public WeChatMiniProgramNotificationPublishProvider( public WeChatMiniProgramNotificationPublishProvider(
IFeatureChecker featureChecker,
ISubscribeMessager subscribeMessager, ISubscribeMessager subscribeMessager,
IOptions<AbpNotificationsWeChatMiniProgramOptions> options) IOptions<AbpNotificationsWeChatMiniProgramOptions> options)
{ {
Options = options.Value; Options = options.Value;
FeatureChecker = featureChecker;
SubscribeMessager = subscribeMessager; SubscribeMessager = subscribeMessager;
} }
protected async override Task<bool> CanPublishAsync(NotificationInfo notification, CancellationToken cancellationToken = default)
{
if (!await FeatureChecker.IsEnabledAsync(WeChatMiniProgramFeatures.Messages.Enable))
{
Logger.LogWarning(
"{0} cannot push messages because the feature {0} is not enabled",
Name,
WeChatMiniProgramFeatures.Messages.Enable);
return false;
}
return true;
}
protected override async Task PublishAsync(NotificationInfo notification, IEnumerable<UserIdentifier> identifiers, CancellationToken cancellationToken = default) protected override async Task PublishAsync(NotificationInfo notification, IEnumerable<UserIdentifier> identifiers, CancellationToken cancellationToken = default)
{ {
// step1 默认微信openid绑定的就是username, // step1 默认微信openid绑定的就是username,

31
aspnet-core/modules/wx-pusher/LINGYUN.Abp.Identity.WxPusher/LINGYUN/Abp/Identity/WxPusher/User/IdentityWxPusherUserStore.cs

@ -30,12 +30,12 @@ public class IdentityWxPusherUserStore : IWxPusherUserStore
{ {
var user = await UserManager.FindByIdAsync(userId.ToString()); var user = await UserManager.FindByIdAsync(userId.ToString());
var userUidClaim = user?.Claims var userTopicClaim = user?.Claims
.Where(c => c.ClaimType.Equals(AbpWxPusherClaimTypes.Uid)) .Where(c => c.ClaimType.Equals(AbpWxPusherClaimTypes.Topic))
.FirstOrDefault(); .FirstOrDefault();
if (userUidClaim != null && if (userTopicClaim != null &&
int.TryParse(userUidClaim.ClaimValue, out var topic)) int.TryParse(userTopicClaim.ClaimValue, out var topic))
{ {
topics.Add(topic); topics.Add(topic);
} }
@ -43,4 +43,27 @@ public class IdentityWxPusherUserStore : IWxPusherUserStore
return topics.Distinct().ToList(); return topics.Distinct().ToList();
} }
public async virtual Task<List<string>> GetBindUidsAsync(
IEnumerable<Guid> userIds,
CancellationToken cancellationToken = default)
{
var uids = new List<string>();
foreach (var userId in userIds)
{
var user = await UserManager.FindByIdAsync(userId.ToString());
var userUidClaim = user?.Claims
.Where(c => c.ClaimType.Equals(AbpWxPusherClaimTypes.Uid))
.FirstOrDefault();
if (userUidClaim != null)
{
uids.Add(userUidClaim.ClaimValue);
}
}
return uids.Distinct().ToList();
}
} }

3
aspnet-core/modules/wx-pusher/LINGYUN.Abp.Notifications.WxPusher/FodyWeavers.xml

@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<ConfigureAwait />
</Weavers>

30
aspnet-core/modules/wx-pusher/LINGYUN.Abp.Notifications.WxPusher/FodyWeavers.xsd

@ -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>

19
aspnet-core/modules/wx-pusher/LINGYUN.Abp.Notifications.WxPusher/LINGYUN/Abp/Notifications/NotificationDataExtensions.cs

@ -0,0 +1,19 @@
namespace LINGYUN.Abp.Notifications;
public static class NotificationDataExtensions
{
private const string Prefix = "wx-pusher:";
private const string UrlKey = Prefix + "url";
public static void SetUrl(
this NotificationData notificationData,
string url)
{
notificationData.TrySetData(UrlKey, url);
}
public static string GetUrlOrNull(
this NotificationData notificationData)
{
return notificationData.TryGetData(UrlKey)?.ToString();
}
}

29
aspnet-core/modules/wx-pusher/LINGYUN.Abp.Notifications.WxPusher/LINGYUN/Abp/Notifications/NotificationDefinitionExtensions.cs

@ -8,6 +8,7 @@ public static class NotificationDefinitionExtensions
private const string Prefix = "wx-pusher:"; private const string Prefix = "wx-pusher:";
private const string ContentTypeKey = Prefix + "contentType"; private const string ContentTypeKey = Prefix + "contentType";
private const string TopicKey = Prefix + "topic"; private const string TopicKey = Prefix + "topic";
private const string UrlKey = Prefix + "url";
/// <summary> /// <summary>
/// 设定消息内容类型 /// 设定消息内容类型
/// </summary> /// </summary>
@ -71,4 +72,32 @@ public static class NotificationDefinitionExtensions
return new List<int>(); return new List<int>();
} }
/// <summary>
/// 用户点击标题跳转页面
/// </summary>
/// <param name="notification">群组编码</param>
/// <param name="url"></param>
/// <returns>
/// <see cref="NotificationDefinition"/>
/// </returns>
public static NotificationDefinition WithUrl(
this NotificationDefinition notification,
string url)
{
return notification.WithProperty(UrlKey, url);
}
/// <summary>
/// 获取标题跳转页面
/// </summary>
/// <param name="notification"></param>
public static string GetUrlOrNull(
this NotificationDefinition notification)
{
if (notification.Properties.TryGetValue(UrlKey, out var urlDefine))
{
return urlDefine.ToString();
}
return null;
}
} }

2
aspnet-core/modules/wx-pusher/LINGYUN.Abp.Notifications.WxPusher/LINGYUN/Abp/Notifications/WxPusher/AbpNotificationsWxPusherModule.cs

@ -6,7 +6,7 @@ namespace LINGYUN.Abp.Notifications.WxPusher;
[DependsOn( [DependsOn(
typeof(AbpNotificationModule), typeof(AbpNotificationModule),
typeof(AbpWxPusherModule))] typeof(AbpWxPusherModule))]
public class AbpNotificationsPushPlusModule : AbpModule public class AbpNotificationsWxPusherModule : AbpModule
{ {
public override void ConfigureServices(ServiceConfigurationContext context) public override void ConfigureServices(ServiceConfigurationContext context)
{ {

33
aspnet-core/modules/wx-pusher/LINGYUN.Abp.Notifications.WxPusher/LINGYUN/Abp/Notifications/WxPusher/WxPusherNotificationPublishProvider.cs

@ -1,13 +1,16 @@
using LINGYUN.Abp.RealTime.Localization; using LINGYUN.Abp.RealTime.Localization;
using LINGYUN.Abp.WxPusher.Features;
using LINGYUN.Abp.WxPusher.Messages; using LINGYUN.Abp.WxPusher.Messages;
using LINGYUN.Abp.WxPusher.User; using LINGYUN.Abp.WxPusher.User;
using Microsoft.Extensions.Localization; using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Features;
using Volo.Abp.Localization; using Volo.Abp.Localization;
namespace LINGYUN.Abp.Notifications.WxPusher; namespace LINGYUN.Abp.Notifications.WxPusher;
@ -18,6 +21,8 @@ public class WxPusherNotificationPublishProvider : NotificationPublishProvider
public override string Name => ProviderName; public override string Name => ProviderName;
protected IFeatureChecker FeatureChecker { get; }
protected IWxPusherUserStore WxPusherUserStore { get; } protected IWxPusherUserStore WxPusherUserStore { get; }
protected IWxPusherMessageSender WxPusherMessageSender { get; } protected IWxPusherMessageSender WxPusherMessageSender { get; }
@ -29,12 +34,14 @@ public class WxPusherNotificationPublishProvider : NotificationPublishProvider
protected INotificationDefinitionManager NotificationDefinitionManager { get; } protected INotificationDefinitionManager NotificationDefinitionManager { get; }
public WxPusherNotificationPublishProvider( public WxPusherNotificationPublishProvider(
IFeatureChecker featureChecker,
IWxPusherUserStore wxPusherUserStore, IWxPusherUserStore wxPusherUserStore,
IWxPusherMessageSender wxPusherMessageSender, IWxPusherMessageSender wxPusherMessageSender,
IStringLocalizerFactory localizerFactory, IStringLocalizerFactory localizerFactory,
IOptions<AbpLocalizationOptions> localizationOptions, IOptions<AbpLocalizationOptions> localizationOptions,
INotificationDefinitionManager notificationDefinitionManager) INotificationDefinitionManager notificationDefinitionManager)
{ {
FeatureChecker = featureChecker;
WxPusherUserStore = wxPusherUserStore; WxPusherUserStore = wxPusherUserStore;
WxPusherMessageSender = wxPusherMessageSender; WxPusherMessageSender = wxPusherMessageSender;
LocalizerFactory = localizerFactory; LocalizerFactory = localizerFactory;
@ -42,17 +49,31 @@ public class WxPusherNotificationPublishProvider : NotificationPublishProvider
NotificationDefinitionManager = notificationDefinitionManager; NotificationDefinitionManager = notificationDefinitionManager;
} }
protected async override Task<bool> CanPublishAsync(NotificationInfo notification, CancellationToken cancellationToken = default)
{
if (!await FeatureChecker.IsEnabledAsync(WxPusherFeatureNames.Message.Enable))
{
Logger.LogWarning(
"{0} cannot push messages because the feature {1} is not enabled",
Name,
WxPusherFeatureNames.Message.Enable);
return false;
}
return true;
}
protected async override Task PublishAsync( protected async override Task PublishAsync(
NotificationInfo notification, NotificationInfo notification,
IEnumerable<UserIdentifier> identifiers, IEnumerable<UserIdentifier> identifiers,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
var topics = await WxPusherUserStore var subscribeUserIds = identifiers.Select(x => x.UserId);
.GetSubscribeTopicsAsync(
identifiers.Select(x => x.UserId), var topics = await WxPusherUserStore.GetSubscribeTopicsAsync(subscribeUserIds, cancellationToken);
cancellationToken); var uids = await WxPusherUserStore.GetBindUidsAsync(subscribeUserIds, cancellationToken);
var notificationDefine = NotificationDefinitionManager.GetOrNull(notification.Name); var notificationDefine = NotificationDefinitionManager.GetOrNull(notification.Name);
var url = notification.Data.GetUrlOrNull() ?? notificationDefine?.GetUrlOrNull();
var topicDefine = notificationDefine?.GetTopics(); var topicDefine = notificationDefine?.GetTopics();
if (topicDefine.Any()) if (topicDefine.Any())
{ {
@ -71,6 +92,8 @@ public class WxPusherNotificationPublishProvider : NotificationPublishProvider
summary: title, summary: title,
contentType: contentType, contentType: contentType,
topicIds: topics, topicIds: topics,
uids: uids,
url: url,
cancellationToken: cancellationToken); cancellationToken: cancellationToken);
} }
else else
@ -88,6 +111,8 @@ public class WxPusherNotificationPublishProvider : NotificationPublishProvider
summary: title, summary: title,
contentType: contentType, contentType: contentType,
topicIds: topics, topicIds: topics,
uids: uids,
url: url,
cancellationToken: cancellationToken); cancellationToken: cancellationToken);
} }
} }

4
aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN/Abp/WxPusher/Features/WxPusherFeatureDefinitionProvider.cs

@ -14,7 +14,7 @@ public class WxPusherFeatureDefinitionProvider : FeatureDefinitionProvider
displayName: L("Features:WxPusher")); displayName: L("Features:WxPusher"));
group.AddFeature( group.AddFeature(
name: WxPusherFeatureNames.Enable, name: WxPusherFeatureNames.Enable,
defaultValue: "true", defaultValue: "false",
displayName: L("Features:WxPusherEnable"), displayName: L("Features:WxPusherEnable"),
description: L("Features:WxPusherEnableDesc"), description: L("Features:WxPusherEnableDesc"),
valueType: new ToggleStringValueType(new BooleanValueValidator())); valueType: new ToggleStringValueType(new BooleanValueValidator()));
@ -26,7 +26,7 @@ public class WxPusherFeatureDefinitionProvider : FeatureDefinitionProvider
message.CreateChild( message.CreateChild(
name: WxPusherFeatureNames.Message.Enable, name: WxPusherFeatureNames.Message.Enable,
defaultValue: "true", defaultValue: "false",
displayName: L("Features:MessageEnable"), displayName: L("Features:MessageEnable"),
description: L("Features:MessageEnableDesc"), description: L("Features:MessageEnableDesc"),
valueType: new ToggleStringValueType(new BooleanValueValidator())); valueType: new ToggleStringValueType(new BooleanValueValidator()));

6
aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN/Abp/WxPusher/Security/Claims/AbpWxPusherClaimTypes.cs

@ -5,5 +5,9 @@ public static class AbpWxPusherClaimTypes
/// <summary> /// <summary>
/// 用户的唯一标识 /// 用户的唯一标识
/// </summary> /// </summary>
public static string Uid { get; set; } = "wx-pusher-uid"; public static string Uid { get; set; } = "wxp-uid";
/// <summary>
/// 用户订阅topic
/// </summary>
public static string Topic { get; set; } = "wxp-topic";
} }

9
aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN/Abp/WxPusher/User/IWxPusherUserStore.cs

@ -16,4 +16,13 @@ public interface IWxPusherUserStore
Task<List<int>> GetSubscribeTopicsAsync( Task<List<int>> GetSubscribeTopicsAsync(
IEnumerable<Guid> userIds, IEnumerable<Guid> userIds,
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
/// <summary>
/// 获取绑定用户uid列表
/// </summary>
/// <param name="userIds"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<List<string>> GetBindUidsAsync(
IEnumerable<Guid> userIds,
CancellationToken cancellationToken = default);
} }

7
aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN/Abp/WxPusher/User/NullWxPusherUserStore.cs

@ -19,4 +19,11 @@ public sealed class NullWxPusherUserStore : IWxPusherUserStore
{ {
return Task.FromResult(new List<int>()); return Task.FromResult(new List<int>());
} }
public Task<List<string>> GetBindUidsAsync(
IEnumerable<Guid> userIds,
CancellationToken cancellationToken = default)
{
return Task.FromResult(new List<string>());
}
} }

2
aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/LY.MicroService.RealtimeMessage.HttpApi.Host.csproj

@ -55,6 +55,7 @@
<ProjectReference Include="..\..\modules\common\LINGYUN.Abp.Notifications.Sms\LINGYUN.Abp.Notifications.Sms.csproj" /> <ProjectReference Include="..\..\modules\common\LINGYUN.Abp.Notifications.Sms\LINGYUN.Abp.Notifications.Sms.csproj" />
<ProjectReference Include="..\..\modules\identity\LINGYUN.Abp.Identity.EntityFrameworkCore\LINGYUN.Abp.Identity.EntityFrameworkCore.csproj" /> <ProjectReference Include="..\..\modules\identity\LINGYUN.Abp.Identity.EntityFrameworkCore\LINGYUN.Abp.Identity.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\modules\localization\LINGYUN.Abp.AspNetCore.Mvc.Localization\LINGYUN.Abp.AspNetCore.Mvc.Localization.csproj" /> <ProjectReference Include="..\..\modules\localization\LINGYUN.Abp.AspNetCore.Mvc.Localization\LINGYUN.Abp.AspNetCore.Mvc.Localization.csproj" />
<ProjectReference Include="..\..\modules\pushplus\LINGYUN.Abp.Notifications.PushPlus\LINGYUN.Abp.Notifications.PushPlus.csproj" />
<ProjectReference Include="..\..\modules\task-management\LINGYUN.Abp.BackgroundTasks.Quartz\LINGYUN.Abp.BackgroundTasks.Quartz.csproj" /> <ProjectReference Include="..\..\modules\task-management\LINGYUN.Abp.BackgroundTasks.Quartz\LINGYUN.Abp.BackgroundTasks.Quartz.csproj" />
<ProjectReference Include="..\..\modules\task-management\LINGYUN.Abp.BackgroundTasks.DistributedLocking\LINGYUN.Abp.BackgroundTasks.DistributedLocking.csproj" /> <ProjectReference Include="..\..\modules\task-management\LINGYUN.Abp.BackgroundTasks.DistributedLocking\LINGYUN.Abp.BackgroundTasks.DistributedLocking.csproj" />
<ProjectReference Include="..\..\modules\task-management\LINGYUN.Abp.BackgroundTasks.ExceptionHandling\LINGYUN.Abp.BackgroundTasks.ExceptionHandling.csproj" /> <ProjectReference Include="..\..\modules\task-management\LINGYUN.Abp.BackgroundTasks.ExceptionHandling\LINGYUN.Abp.BackgroundTasks.ExceptionHandling.csproj" />
@ -71,6 +72,7 @@
<ProjectReference Include="..\..\modules\text-templating\LINGYUN.Abp.TextTemplating.EntityFrameworkCore\LINGYUN.Abp.TextTemplating.EntityFrameworkCore.csproj" /> <ProjectReference Include="..\..\modules\text-templating\LINGYUN.Abp.TextTemplating.EntityFrameworkCore\LINGYUN.Abp.TextTemplating.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\modules\wechat\LINGYUN.Abp.Identity.WeChat\LINGYUN.Abp.Identity.WeChat.csproj" /> <ProjectReference Include="..\..\modules\wechat\LINGYUN.Abp.Identity.WeChat\LINGYUN.Abp.Identity.WeChat.csproj" />
<ProjectReference Include="..\..\modules\wechat\LINGYUN.Abp.Notifications.WeChat.MiniProgram\LINGYUN.Abp.Notifications.WeChat.MiniProgram.csproj" /> <ProjectReference Include="..\..\modules\wechat\LINGYUN.Abp.Notifications.WeChat.MiniProgram\LINGYUN.Abp.Notifications.WeChat.MiniProgram.csproj" />
<ProjectReference Include="..\..\modules\wx-pusher\LINGYUN.Abp.Notifications.WxPusher\LINGYUN.Abp.Notifications.WxPusher.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

4
aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.cs

@ -42,6 +42,8 @@ using Volo.Abp.Modularity;
using Volo.Abp.PermissionManagement.EntityFrameworkCore; using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using Volo.Abp.SettingManagement.EntityFrameworkCore; using Volo.Abp.SettingManagement.EntityFrameworkCore;
using Volo.Abp.TextTemplating.Scriban; using Volo.Abp.TextTemplating.Scriban;
using LINGYUN.Abp.Notifications.PushPlus;
using LINGYUN.Abp.Notifications.WxPusher;
namespace LY.MicroService.RealtimeMessage; namespace LY.MicroService.RealtimeMessage;
@ -76,6 +78,8 @@ namespace LY.MicroService.RealtimeMessage;
typeof(AbpNotificationsSmsModule), typeof(AbpNotificationsSmsModule),
typeof(AbpNotificationsEmailingModule), typeof(AbpNotificationsEmailingModule),
typeof(AbpNotificationsSignalRModule), typeof(AbpNotificationsSignalRModule),
typeof(AbpNotificationsWxPusherModule),
typeof(AbpNotificationsPushPlusModule),
typeof(AbpNotificationsWeChatMiniProgramModule), typeof(AbpNotificationsWeChatMiniProgramModule),
typeof(AbpNotificationsExceptionHandlingModule), typeof(AbpNotificationsExceptionHandlingModule),
typeof(AbpTextTemplatingScribanModule), typeof(AbpTextTemplatingScribanModule),

205
aspnet-core/tests/LINGYUN.Abp.Notifications.Tests/LINGYUN/Abp/Notifications/FakeNotificationSender.cs

@ -0,0 +1,205 @@
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Json;
using Volo.Abp.TextTemplating;
namespace LINGYUN.Abp.Notifications;
[Dependency(ReplaceServices = true)]
public class FakeNotificationSender : INotificationSender, ITransientDependency
{
public ILogger<FakeNotificationSender> Logger { get; set; }
protected AbpNotificationOptions Options { get; }
protected IJsonSerializer JsonSerializer { get; }
protected ITemplateRenderer TemplateRenderer { get; }
protected INotificationStore NotificationStore { get; }
protected IStringLocalizerFactory StringLocalizerFactory { get; }
protected INotificationDefinitionManager NotificationDefinitionManager { get; }
protected INotificationSubscriptionManager NotificationSubscriptionManager { get; }
protected INotificationPublishProviderManager NotificationPublishProviderManager { get; }
public FakeNotificationSender(
IJsonSerializer jsonSerializer,
ITemplateRenderer templateRenderer,
IStringLocalizerFactory stringLocalizerFactory,
IOptions<AbpNotificationOptions> options,
INotificationStore notificationStore,
INotificationDefinitionManager notificationDefinitionManager,
INotificationSubscriptionManager notificationSubscriptionManager,
INotificationPublishProviderManager notificationPublishProviderManager)
{
Options = options.Value;
JsonSerializer = jsonSerializer;
TemplateRenderer = templateRenderer;
StringLocalizerFactory = stringLocalizerFactory;
NotificationStore = notificationStore;
NotificationDefinitionManager = notificationDefinitionManager;
NotificationSubscriptionManager = notificationSubscriptionManager;
NotificationPublishProviderManager = notificationPublishProviderManager;
Logger = NullLogger<FakeNotificationSender>.Instance;
}
public async virtual Task<string> SendNofiterAsync(
string name,
NotificationData data,
IEnumerable<UserIdentifier> users = null,
Guid? tenantId = null,
NotificationSeverity severity = NotificationSeverity.Info)
{
var notification = NotificationDefinitionManager.GetOrNull(name);
if (notification == null)
{
return "";
}
var notificationInfo = new NotificationInfo
{
Name = notification.Name,
CreationTime = DateTime.Now,
Data = data,
Severity = severity,
Lifetime = notification.NotificationLifetime,
TenantId = tenantId,
Type = notification.NotificationType
};
notificationInfo.SetId(DateTimeOffset.Now.ToUnixTimeMilliseconds());
notificationInfo.Data = NotificationDataConverter.Convert(notificationInfo.Data);
Logger.LogDebug($"Persistent notification {notificationInfo.Name}");
await NotificationStore.InsertNotificationAsync(notificationInfo);
var providers = Enumerable.Reverse(NotificationPublishProviderManager.Providers);
if (notification.Providers.Any())
{
providers = providers.Where(p => notification.Providers.Contains(p.Name));
}
await PublishFromProvidersAsync(
providers,
users ?? new List<UserIdentifier>(),
notificationInfo);
return notificationInfo.Id;
}
public async virtual Task<string> SendNofiterAsync(
string name,
NotificationTemplate template,
IEnumerable<UserIdentifier> users = null,
Guid? tenantId = null,
NotificationSeverity severity = NotificationSeverity.Info)
{
var notification = NotificationDefinitionManager.GetOrNull(name);
if (notification == null)
{
return "";
}
var notificationInfo = new NotificationInfo
{
Name = notification.Name,
TenantId = tenantId,
Severity = severity,
Type = notification.NotificationType,
CreationTime = DateTime.Now,
Lifetime = notification.NotificationLifetime,
};
notificationInfo.SetId(DateTimeOffset.Now.ToUnixTimeMilliseconds());
var title = notification.DisplayName.Localize(StringLocalizerFactory);
var message = await TemplateRenderer.RenderAsync(
templateName: name,
model: template.ExtraProperties);
var notificationData = new NotificationData();
notificationData.WriteStandardData(
title: title,
message: message,
createTime: notificationInfo.CreationTime,
formUser: "Fake User");
notificationData.ExtraProperties.AddIfNotContains(template.ExtraProperties);
notificationInfo.Data = notificationData;
Logger.LogDebug($"Persistent notification {notificationInfo.Name}");
// 持久化通知
await NotificationStore.InsertNotificationAsync(notificationInfo);
var providers = Enumerable.Reverse(NotificationPublishProviderManager.Providers);
// 过滤用户指定提供者
if (notification.Providers.Any())
{
providers = providers.Where(p => notification.Providers.Contains(p.Name));
}
await PublishFromProvidersAsync(
providers,
users ?? new List<UserIdentifier>(),
notificationInfo);
return notificationInfo.Id;
}
/// <summary>
/// 指定提供者发布通知
/// </summary>
/// <param name="providers">提供者列表</param>
/// <param name="notificationInfo">通知信息</param>
/// <returns></returns>
protected async Task PublishFromProvidersAsync(
IEnumerable<INotificationPublishProvider> providers,
IEnumerable<UserIdentifier> users,
NotificationInfo notificationInfo)
{
foreach (var provider in providers)
{
await PublishAsync(provider, notificationInfo, users);
}
}
/// <summary>
/// 发布通知
/// </summary>
/// <param name="provider">通知发布者</param>
/// <param name="notificationInfo">通知信息</param>
/// <param name="subscriptionUserIdentifiers">订阅用户列表</param>
/// <returns></returns>
protected async Task PublishAsync(
INotificationPublishProvider provider,
NotificationInfo notificationInfo,
IEnumerable<UserIdentifier> subscriptionUserIdentifiers)
{
Logger.LogDebug($"Sending notification with provider {provider.Name}");
var notifacationDataMapping = Options.NotificationDataMappings
.GetMapItemOrDefault(provider.Name, notificationInfo.Name);
if (notifacationDataMapping != null)
{
notificationInfo.Data = notifacationDataMapping.MappingFunc(notificationInfo.Data);
}
// 发布
await provider.PublishAsync(notificationInfo, subscriptionUserIdentifiers);
Logger.LogDebug($"Send notification {notificationInfo.Name} with provider {provider.Name} was successful");
}
}

2
aspnet-core/tests/LINGYUN.Abp.Notifications.Tests/LINGYUN/Abp/Notifications/NotificationsTestsNames.cs

@ -2,7 +2,7 @@
{ {
public static class NotificationsTestsNames public static class NotificationsTestsNames
{ {
public const string GroupName = "Abp.Notifications"; public const string GroupName = "Abp.NotificationTests";
public const string Test1 = GroupName + ".Test1"; public const string Test1 = GroupName + ".Test1";

20
aspnet-core/tests/LINGYUN.Abp.Notifications.WxPusher.Tests/LINGYUN.Abp.Notifications.WxPusher.Tests.csproj

@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace />
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\modules\wx-pusher\LINGYUN.Abp.Notifications.WxPusher\LINGYUN.Abp.Notifications.WxPusher.csproj" />
<ProjectReference Include="..\LINGYUN.Abp.TestBase\LINGYUN.Abp.TestsBase.csproj" />
<ProjectReference Include="..\LINGYUN.Abp.WxPusher.Tests\LINGYUN.Abp.WxPusher.Tests.csproj" />
<ProjectReference Include="..\LINGYUN.Abp.Notifications.Tests\LINGYUN.Abp.Notifications.Tests.csproj" />
</ItemGroup>
</Project>

7
aspnet-core/tests/LINGYUN.Abp.Notifications.WxPusher.Tests/LINGYUN/Abp/Notifications/WxPusher/AbpNotificationsWxPusherTestBase.cs

@ -0,0 +1,7 @@
using LINGYUN.Abp.Tests;
namespace LINGYUN.Abp.Notifications.WxPusher;
public abstract class AbpNotificationsWxPusherTestBase : AbpTestsBase<AbpNotificationsWxPusherTestModule>
{
}

12
aspnet-core/tests/LINGYUN.Abp.Notifications.WxPusher.Tests/LINGYUN/Abp/Notifications/WxPusher/AbpNotificationsWxPusherTestModule.cs

@ -0,0 +1,12 @@
using LINGYUN.Abp.WxPusher;
using Volo.Abp.Modularity;
namespace LINGYUN.Abp.Notifications.WxPusher;
[DependsOn(
typeof(AbpNotificationsWxPusherModule),
typeof(AbpWxPusherTestModule),
typeof(AbpNotificationsTestsModule))]
public class AbpNotificationsWxPusherTestModule : AbpModule
{
}

77
aspnet-core/tests/LINGYUN.Abp.Notifications.WxPusher.Tests/LINGYUN/Abp/Notifications/WxPusher/NotificationSenderTests.cs

@ -0,0 +1,77 @@
using System;
using System.Threading.Tasks;
namespace LINGYUN.Abp.Notifications.WxPusher;
public class NotificationSenderTests : AbpNotificationsWxPusherTestBase
{
protected INotificationSender NotificationSender { get; }
public NotificationSenderTests()
{
NotificationSender = GetRequiredService<INotificationSender>();
}
[Theory]
[InlineData(
"Title from the Xunit unit test",
"Text content from the Xunit unit test. \r\n Click the link at the top to redirect baidu site.")]
public async Task Send_Text_Test(
string title,
string message)
{
var notificationData = new NotificationData();
notificationData.WriteStandardData(
title,
message,
DateTime.Now,
"xUnit Test");
notificationData.SetUrl("https://www.baidu.com/");
await NotificationSender.SendNofiterAsync(
NotificationsTestsNames.Test1,
notificationData);
}
[Theory]
[InlineData(
"Title from the Xunit unit test",
"<h>Html content from the Xunit unit test.</h> <br /> <a href=\"https://www.baidu.com/\">Click to redirect baidu site.</a>")]
public async Task Send_Html_Test(
string title,
string message)
{
var notificationData = new NotificationData();
notificationData.WriteStandardData(
title,
message,
DateTime.Now,
"xUnit Test");
notificationData.SetUrl("https://www.baidu.com/");
await NotificationSender.SendNofiterAsync(
NotificationsTestsNames.Test2,
notificationData);
}
[Theory]
[InlineData(
"Title from the Xunit unit test",
"**Markdown content from the Xunit unit test.** <br /> <a href=\"https://www.baidu.com/\">Click to redirect baidu site.</a>")]
public async Task Send_Markdown_Test(
string title,
string message)
{
var notificationData = new NotificationData();
notificationData.WriteStandardData(
title,
message,
DateTime.Now,
"xUnit Test");
notificationData.SetUrl("https://www.baidu.com/");
await NotificationSender.SendNofiterAsync(
NotificationsTestsNames.Test3,
notificationData);
}
}

28
aspnet-core/tests/LINGYUN.Abp.Notifications.WxPusher.Tests/LINGYUN/Abp/Notifications/WxPusher/NotificationsWxPusherTestsDefinitionProvider.cs

@ -0,0 +1,28 @@
using LINGYUN.Abp.WxPusher.Messages;
using System.Collections.Generic;
using System.Linq;
namespace LINGYUN.Abp.Notifications.WxPusher;
public class NotificationsWxPusherTestsDefinitionProvider : NotificationDefinitionProvider
{
public override void Define(INotificationDefinitionContext context)
{
var group = context.GetGroupOrNull(NotificationsTestsNames.GroupName);
var nt1 = group.Notifications.FirstOrDefault(n => n.Name.Equals(NotificationsTestsNames.Test1));
nt1.WithProviders(WxPusherNotificationPublishProvider.ProviderName)
.WithContentType(MessageContentType.Text)
.WithTopics(new List<int> { 7182 });
var nt2 = group.Notifications.FirstOrDefault(n => n.Name.Equals(NotificationsTestsNames.Test2));
nt2.WithProviders(WxPusherNotificationPublishProvider.ProviderName)
.WithContentType(MessageContentType.Html)
.WithTopics(new List<int> { 7182 });
var nt3 = group.Notifications.FirstOrDefault(n => n.Name.Equals(NotificationsTestsNames.Test3));
nt3.WithProviders(WxPusherNotificationPublishProvider.ProviderName)
.WithContentType(MessageContentType.Markdown)
.WithTopics(new List<int> { 7182 });
}
}

2
aspnet-core/tests/LINGYUN.Abp.Notifications.WxPusher.Tests/Usings.cs

@ -0,0 +1,2 @@
global using Xunit;
global using Shouldly;
Loading…
Cancel
Save