mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 15:42:48 -05:00
Encode into b64 to avoid illegal xml encoding when sending to Azure (#1425)
* Encode into b64 to avoid illegal xml encoding when sending to Azure
* Revert "Encode into b64 to avoid illegal xml encoding when sending to Azure"
This reverts commit d50de941da
.
* HtmlEncode strings if they use multi-byte characters
* Add serializer to event processor
* Rename to used class
* Formatting
* PR feedback
This commit is contained in:
@ -12,11 +12,13 @@ using Azure.Storage.Queues.Models;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Admin.HostedServices
|
||||
{
|
||||
public class AzureQueueMailHostedService : IHostedService
|
||||
{
|
||||
private readonly JsonSerializer _jsonSerializer;
|
||||
private readonly ILogger<AzureQueueMailHostedService> _logger;
|
||||
private readonly GlobalSettings _globalSettings;
|
||||
private readonly IMailService _mailService;
|
||||
@ -33,6 +35,11 @@ namespace Bit.Admin.HostedServices
|
||||
_logger = logger;
|
||||
_mailService = mailService;
|
||||
_globalSettings = globalSettings;
|
||||
|
||||
_jsonSerializer = JsonSerializer.Create(new JsonSerializerSettings
|
||||
{
|
||||
Converters = new[] { new EncodedStringConverter() },
|
||||
});
|
||||
}
|
||||
|
||||
public Task StartAsync(CancellationToken cancellationToken)
|
||||
@ -72,7 +79,7 @@ namespace Bit.Admin.HostedServices
|
||||
var token = JToken.Parse(message.MessageText);
|
||||
if (token is JArray)
|
||||
{
|
||||
foreach (var mailQueueMessage in token.ToObject<List<MailQueueMessage>>())
|
||||
foreach (var mailQueueMessage in token.ToObject<List<MailQueueMessage>>(_jsonSerializer))
|
||||
{
|
||||
await _mailService.SendEnqueuedMailMessageAsync(mailQueueMessage);
|
||||
}
|
||||
|
Reference in New Issue
Block a user