Browse Source

Merge pull request #924 from colinin/fix-notifications

fix(notifications): 发送邮件通知时需要转换markdown格式.
pull/930/head
yx lin 2 years ago
committed by GitHub
parent
commit
1f7c93b385
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      aspnet-core/Directory.Build.props
  2. 1
      aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Emailing/LINGYUN.Abp.Notifications.Emailing.csproj
  3. 12
      aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Emailing/LINGYUN/Abp/Notifications/Emailing/EmailingNotificationPublishProvider.cs

1
aspnet-core/Directory.Build.props

@ -36,6 +36,7 @@
<SixLaborsImageSharpDrawingPackageVersion>2.0.1</SixLaborsImageSharpDrawingPackageVersion> <SixLaborsImageSharpDrawingPackageVersion>2.0.1</SixLaborsImageSharpDrawingPackageVersion>
<SwashbuckleAspNetCorePackageVersion>6.5.0</SwashbuckleAspNetCorePackageVersion> <SwashbuckleAspNetCorePackageVersion>6.5.0</SwashbuckleAspNetCorePackageVersion>
<PollyPackageVersion>8.2.0</PollyPackageVersion> <PollyPackageVersion>8.2.0</PollyPackageVersion>
<MarkdigPackageVersion>0.34.0</MarkdigPackageVersion>
<MicrosoftPackageVersion>8.0.*</MicrosoftPackageVersion> <MicrosoftPackageVersion>8.0.*</MicrosoftPackageVersion>
<MicrosoftEntityFrameworkCorePackageVersion>8.0.0</MicrosoftEntityFrameworkCorePackageVersion> <MicrosoftEntityFrameworkCorePackageVersion>8.0.0</MicrosoftEntityFrameworkCorePackageVersion>
<XunitPackageVersion>2.6.1</XunitPackageVersion> <XunitPackageVersion>2.6.1</XunitPackageVersion>

1
aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Emailing/LINGYUN.Abp.Notifications.Emailing.csproj

@ -10,6 +10,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Volo.Abp.Emailing" Version="$(VoloAbpPackageVersion)" /> <PackageReference Include="Volo.Abp.Emailing" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Markdig" Version="$(MarkdigPackageVersion)" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

12
aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Emailing/LINGYUN/Abp/Notifications/Emailing/EmailingNotificationPublishProvider.cs

@ -1,5 +1,6 @@
using LINGYUN.Abp.Identity; using LINGYUN.Abp.Identity;
using LINGYUN.Abp.RealTime.Localization; using LINGYUN.Abp.RealTime.Localization;
using Markdig;
using Microsoft.Extensions.Localization; using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
@ -59,6 +60,11 @@ public class EmailingNotificationPublishProvider : NotificationPublishProvider
{ {
var title = notification.Data.TryGetData("title").ToString(); var title = notification.Data.TryGetData("title").ToString();
var message = notification.Data.TryGetData("message").ToString(); var message = notification.Data.TryGetData("message").ToString();
// markdown进行处理
if (notification.ContentType == NotificationContentType.Markdown)
{
message = Markdown.ToHtml(message);
}
await EmailSender.SendAsync(emailAddress, title, message); await EmailSender.SendAsync(emailAddress, title, message);
} }
@ -92,6 +98,12 @@ public class EmailingNotificationPublishProvider : NotificationPublishProvider
} }
} }
// markdown进行处理
if (notification.ContentType == NotificationContentType.Markdown)
{
message = Markdown.ToHtml(message);
}
await EmailSender.SendAsync(emailAddress, title, message); await EmailSender.SendAsync(emailAddress, title, message);
} }
} }

Loading…
Cancel
Save