diff --git a/products/ASC.Files/Core/ApiModels/ResponseDto/DocServiceUrlDto.cs b/products/ASC.Files/Core/ApiModels/ResponseDto/DocServiceUrlDto.cs new file mode 100644 index 00000000000..39c16263494 --- /dev/null +++ b/products/ASC.Files/Core/ApiModels/ResponseDto/DocServiceUrlDto.cs @@ -0,0 +1,48 @@ +// (c) Copyright Ascensio System SIA 2010-2023 +// +// This program is a free software product. +// You can redistribute it and/or modify it under the terms +// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software +// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended +// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of +// any third-party rights. +// +// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see +// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html +// +// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021. +// +// The interactive user interfaces in modified source and object code versions of the Program must +// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3. +// +// Pursuant to Section 7(b) of the License you must retain the original Product logo when +// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under +// trademark law for use of our trademarks. +// +// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing +// 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 + +namespace ASC.Files.Core.ApiModels.ResponseDto; + +public class DocServiceUrlDto +{ + /// System.String, System + public required string Version { get; set; } + + /// System.String, System + public required string DocServiceUrlApi { get; set; } + + /// System.String, System + public required string DocServiceUrl { get; set; } + + /// System.String, System + public required string DocServiceUrlInternal { get; set; } + + /// System.String, System + public required string DocServicePortalUrl { get; set; } + + /// System.Boolean, System + public required bool IsDefault { get; set; } +} \ No newline at end of file diff --git a/products/ASC.Files/Core/Helpers/FilesLinkUtility.cs b/products/ASC.Files/Core/Helpers/FilesLinkUtility.cs index 1db2636a695..d8f6d9e6828 100644 --- a/products/ASC.Files/Core/Helpers/FilesLinkUtility.cs +++ b/products/ASC.Files/Core/Helpers/FilesLinkUtility.cs @@ -145,7 +145,7 @@ public string DocServiceUrlInternal } } - SetUrlSetting(InternalUrlKey, value); + SetUrlSetting(InternalUrlKey, DocServiceUrlInternal != value ? value : null); } } @@ -447,7 +447,12 @@ private string GetUrlSetting(string key, out bool isDefault) private string GetDefaultUrlSetting(string key) { - return _configuration[$"files:docservice:url:{key}"]; + var value = _configuration[$"files:docservice:url:{key}"]; + if (!string.IsNullOrEmpty(value)) + { + value = value.TrimEnd('/') + "/"; + } + return value; } private void SetUrlSetting(string key, string value) diff --git a/products/ASC.Files/Server/Api/EditorController.cs b/products/ASC.Files/Server/Api/EditorController.cs index cf1748df524..693cd936b6a 100644 --- a/products/ASC.Files/Server/Api/EditorController.cs +++ b/products/ASC.Files/Server/Api/EditorController.cs @@ -356,7 +356,7 @@ public EditorController( /// PUT /// list [HttpPut("docservice")] - public async Task> CheckDocServiceUrl(CheckDocServiceUrlRequestDto inDto) + public async Task CheckDocServiceUrl(CheckDocServiceUrlRequestDto inDto) { await _permissionContext.DemandPermissionsAsync(SecurityConstants.EditPortalSettings); @@ -375,12 +375,7 @@ public async Task> CheckDocServiceUrl(CheckDocServiceUrlRequ await _documentServiceConnector.CheckDocServiceUrlAsync(); - return new[] - { - _filesLinkUtility.DocServiceUrl, - _filesLinkUtility.DocServiceUrlInternal, - _filesLinkUtility.DocServicePortalUrl - }; + return await GetDocServiceUrlAsync(false); } /// @@ -396,7 +391,7 @@ public async Task> CheckDocServiceUrl(CheckDocServiceUrlRequ /// false [AllowAnonymous] [HttpGet("docservice")] - public async Task GetDocServiceUrlAsync(bool version) + public async Task GetDocServiceUrlAsync(bool version) { var url = _commonLinkUtility.GetFullAbsolutePath(_filesLinkUtility.DocServiceApiUrl); @@ -407,14 +402,14 @@ public async Task GetDocServiceUrlAsync(bool version) dsVersion = await _documentServiceConnector.GetVersionAsync(); } - return new + return new DocServiceUrlDto { - version = dsVersion, - docServiceUrlApi = url, - _filesLinkUtility.DocServiceUrl, - _filesLinkUtility.DocServiceUrlInternal, - _filesLinkUtility.DocServicePortalUrl, - _filesLinkUtility.IsDefault + Version = dsVersion, + DocServiceUrlApi = url, + DocServiceUrl = _filesLinkUtility.DocServiceUrl, + DocServiceUrlInternal =_filesLinkUtility.DocServiceUrlInternal, + DocServicePortalUrl = _filesLinkUtility.DocServicePortalUrl, + IsDefault = _filesLinkUtility.IsDefault }; } } \ No newline at end of file