[backend/federation] Make sure DateTime objects are being converted to Utc when (de)serializing activities
This commit is contained in:
parent
8d158cc7b9
commit
2858f66ad4
3 changed files with 13 additions and 2 deletions
|
@ -40,6 +40,16 @@ public static class MvcBuilderExtensions
|
|||
return builder;
|
||||
}
|
||||
|
||||
public static IMvcBuilder ConfigureNewtonsoftJson(this IMvcBuilder builder)
|
||||
{
|
||||
Newtonsoft.Json.JsonConvert.DefaultSettings = () => new Newtonsoft.Json.JsonSerializerSettings
|
||||
{
|
||||
DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc
|
||||
};
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
public static IMvcBuilder AddModelBindingProviders(this IMvcBuilder builder)
|
||||
{
|
||||
builder.Services.AddOptions<MvcOptions>()
|
||||
|
|
|
@ -56,12 +56,12 @@ public static class LdHelpers
|
|||
|
||||
public static readonly JsonSerializerSettings JsonSerializerSettings = new()
|
||||
{
|
||||
NullValueHandling = NullValueHandling.Ignore, DateTimeZoneHandling = DateTimeZoneHandling.Local
|
||||
NullValueHandling = NullValueHandling.Ignore, DateTimeZoneHandling = DateTimeZoneHandling.Utc
|
||||
};
|
||||
|
||||
private static readonly JsonSerializer JsonSerializer = new()
|
||||
{
|
||||
NullValueHandling = NullValueHandling.Ignore, DateTimeZoneHandling = DateTimeZoneHandling.Local
|
||||
NullValueHandling = NullValueHandling.Ignore, DateTimeZoneHandling = DateTimeZoneHandling.Utc
|
||||
};
|
||||
|
||||
private static IEnumerable<string> ASForceArray => ["tag", "attachment", "to", "cc", "bcc", "bto"];
|
||||
|
|
|
@ -12,6 +12,7 @@ builder.Configuration.AddCustomConfiguration();
|
|||
|
||||
builder.Services.AddControllers()
|
||||
.AddNewtonsoftJson() //TODO: remove once dotNetRdf switches to System.Text.Json (or we switch to LinkedData.NET)
|
||||
.ConfigureNewtonsoftJson()
|
||||
.AddMultiFormatter()
|
||||
.AddModelBindingProviders()
|
||||
.AddValueProviderFactories()
|
||||
|
|
Loading…
Add table
Reference in a new issue