mirror of
https://github.com/bitwarden/server.git
synced 2025-07-02 00:22:50 -05:00
Parse enqueued mail message model to object (#1742)
* Parse enqueued mail message model to object The model of an MailQueueMessage is of type object to enable enqueueing of any message. However, this means the we are not able to parse a serialized json object back into the original object. Provide the model type to enable this deserialization * Use ExpandoObject for deserialized queue message model
This commit is contained in:
19
src/Core/Utilities/ExpandoObjectJsonConverter.cs
Normal file
19
src/Core/Utilities/ExpandoObjectJsonConverter.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Dynamic;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Bit.Core.Utilities
|
||||
{
|
||||
public class ExpandoObjectJsonConverter : JsonConverter
|
||||
{
|
||||
public override bool CanWrite => false;
|
||||
public override bool CanConvert(Type objectType) => true;
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
{
|
||||
return serializer.Deserialize<ExpandoObject>(reader);
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) => throw new NotImplementedException();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user