From 51fd85d781aca3b01c97c1c205ccad326c1f317a Mon Sep 17 00:00:00 2001 From: Sukhorukov Anton Date: Thu, 14 Nov 2024 16:02:01 +0300 Subject: [PATCH] fix Bugs 71659 and 71656 --- common/ASC.Api.Core/Core/BaseStartup.cs | 1 + common/services/ASC.Data.Backup/Api/BackupController.cs | 2 +- common/services/ASC.Data.Backup/ApiModels/BackupDto.cs | 1 + common/services/ASC.Data.Backup/ApiModels/BackupRestoreDto.cs | 3 ++- .../services/ASC.Data.Backup/ApiModels/BackupScheduleDto.cs | 4 +++- common/services/ASC.Data.Backup/GlobalUsings.cs | 2 ++ web/ASC.Web.Api/ApiModels/RequestsDto/TfaRequestsDto.cs | 1 + 7 files changed, 11 insertions(+), 3 deletions(-) diff --git a/common/ASC.Api.Core/Core/BaseStartup.cs b/common/ASC.Api.Core/Core/BaseStartup.cs index 61731f9c060..0438d6c5633 100644 --- a/common/ASC.Api.Core/Core/BaseStartup.cs +++ b/common/ASC.Api.Core/Core/BaseStartup.cs @@ -341,6 +341,7 @@ bool EnableNoLimiter(IPAddress address) { options.JsonSerializerOptions.WriteIndented = false; options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull; + options.JsonSerializerOptions.NumberHandling = JsonNumberHandling.AllowReadingFromString; }; services.AddControllers().AddJsonOptions(jsonOptions); diff --git a/common/services/ASC.Data.Backup/Api/BackupController.cs b/common/services/ASC.Data.Backup/Api/BackupController.cs index e44b81c3a43..777460cba1f 100644 --- a/common/services/ASC.Data.Backup/Api/BackupController.cs +++ b/common/services/ASC.Data.Backup/Api/BackupController.cs @@ -91,7 +91,7 @@ public async Task CreateBackupScheduleAsync(BackupScheduleDto inDto) { Period = inDto.CronParams.Period ?? BackupPeriod.EveryDay, Hour = inDto.CronParams.Hour, - Day = inDto.CronParams.Day + Day = inDto.CronParams.Day.HasValue ? inDto.CronParams.Day.Value : 0 }; if(backupStored is > 30 or < 1) { diff --git a/common/services/ASC.Data.Backup/ApiModels/BackupDto.cs b/common/services/ASC.Data.Backup/ApiModels/BackupDto.cs index a92029fd7cc..76c16c3c583 100644 --- a/common/services/ASC.Data.Backup/ApiModels/BackupDto.cs +++ b/common/services/ASC.Data.Backup/ApiModels/BackupDto.cs @@ -34,6 +34,7 @@ public class BackupDto /// /// Storage type /// + [JsonConverter(typeof(JsonStringEnumConverter))] public BackupStorageType? StorageType { get; set; } /// diff --git a/common/services/ASC.Data.Backup/ApiModels/BackupRestoreDto.cs b/common/services/ASC.Data.Backup/ApiModels/BackupRestoreDto.cs index 6a50d1e4a3e..03d59c8f543 100644 --- a/common/services/ASC.Data.Backup/ApiModels/BackupRestoreDto.cs +++ b/common/services/ASC.Data.Backup/ApiModels/BackupRestoreDto.cs @@ -39,7 +39,8 @@ public class BackupRestoreDto /// /// Storage type /// - public int? StorageType { get; set; } + [JsonConverter(typeof(JsonStringEnumConverter))] + public BackupStorageType? StorageType { get; set; } /// /// Storage parameters diff --git a/common/services/ASC.Data.Backup/ApiModels/BackupScheduleDto.cs b/common/services/ASC.Data.Backup/ApiModels/BackupScheduleDto.cs index 5e0ec3175fd..3addc17c083 100644 --- a/common/services/ASC.Data.Backup/ApiModels/BackupScheduleDto.cs +++ b/common/services/ASC.Data.Backup/ApiModels/BackupScheduleDto.cs @@ -34,6 +34,7 @@ public class BackupScheduleDto /// /// Storage type /// + [JsonConverter(typeof(JsonStringEnumConverter))] public BackupStorageType? StorageType { get; set; } /// @@ -65,6 +66,7 @@ public class Cron /// /// Period /// + [JsonConverter(typeof(JsonStringEnumConverter))] public BackupPeriod? Period { get; set; } /// @@ -77,5 +79,5 @@ public class Cron /// Day /// [SwaggerSchemaCustom(Example = 0)] - public int Day { get; set; } + public int? Day { get; set; } } diff --git a/common/services/ASC.Data.Backup/GlobalUsings.cs b/common/services/ASC.Data.Backup/GlobalUsings.cs index d8fe4944034..2538a90ab34 100644 --- a/common/services/ASC.Data.Backup/GlobalUsings.cs +++ b/common/services/ASC.Data.Backup/GlobalUsings.cs @@ -24,6 +24,8 @@ // content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 // International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode +global using System.Text.Json.Serialization; + global using ASC.Api.Collections; global using ASC.Api.Core; global using ASC.Api.Core.Extensions; diff --git a/web/ASC.Web.Api/ApiModels/RequestsDto/TfaRequestsDto.cs b/web/ASC.Web.Api/ApiModels/RequestsDto/TfaRequestsDto.cs index 33b26d919a8..78bd8afa05f 100644 --- a/web/ASC.Web.Api/ApiModels/RequestsDto/TfaRequestsDto.cs +++ b/web/ASC.Web.Api/ApiModels/RequestsDto/TfaRequestsDto.cs @@ -34,6 +34,7 @@ public class TfaRequestsDto /// /// TFA type (None, Sms, or App) /// + [JsonConverter(typeof(JsonStringEnumConverter))] public TfaRequestsDtoType? Type { get; set; } ///