Skip to content

Commit

Permalink
Merge pull request #122 from ONLYOFFICE/bugfix/65568
Browse files Browse the repository at this point in the history
Bug 65568
  • Loading branch information
AlexeySafronov authored Dec 27, 2023
2 parents 0bdb53b + 21d334f commit 575e325
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 17 deletions.
48 changes: 48 additions & 0 deletions products/ASC.Files/Core/ApiModels/ResponseDto/DocServiceUrlDto.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <type>System.String, System</type>
public required string Version { get; set; }

/// <type>System.String, System</type>
public required string DocServiceUrlApi { get; set; }

/// <type>System.String, System</type>
public required string DocServiceUrl { get; set; }

/// <type>System.String, System</type>
public required string DocServiceUrlInternal { get; set; }

/// <type>System.String, System</type>
public required string DocServicePortalUrl { get; set; }

/// <type>System.Boolean, System</type>
public required bool IsDefault { get; set; }
}
9 changes: 7 additions & 2 deletions products/ASC.Files/Core/Helpers/FilesLinkUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public string DocServiceUrlInternal
}
}

SetUrlSetting(InternalUrlKey, value);
SetUrlSetting(InternalUrlKey, DocServiceUrlInternal != value ? value : null);
}
}

Expand Down Expand Up @@ -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)
Expand Down
25 changes: 10 additions & 15 deletions products/ASC.Files/Server/Api/EditorController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ public EditorController(
/// <httpMethod>PUT</httpMethod>
/// <collection>list</collection>
[HttpPut("docservice")]
public async Task<IEnumerable<string>> CheckDocServiceUrl(CheckDocServiceUrlRequestDto inDto)
public async Task<DocServiceUrlDto> CheckDocServiceUrl(CheckDocServiceUrlRequestDto inDto)
{
await _permissionContext.DemandPermissionsAsync(SecurityConstants.EditPortalSettings);

Expand All @@ -375,12 +375,7 @@ public async Task<IEnumerable<string>> CheckDocServiceUrl(CheckDocServiceUrlRequ

await _documentServiceConnector.CheckDocServiceUrlAsync();

return new[]
{
_filesLinkUtility.DocServiceUrl,
_filesLinkUtility.DocServiceUrlInternal,
_filesLinkUtility.DocServicePortalUrl
};
return await GetDocServiceUrlAsync(false);
}

/// <summary>
Expand All @@ -396,7 +391,7 @@ public async Task<IEnumerable<string>> CheckDocServiceUrl(CheckDocServiceUrlRequ
/// <visible>false</visible>
[AllowAnonymous]
[HttpGet("docservice")]
public async Task<object> GetDocServiceUrlAsync(bool version)
public async Task<DocServiceUrlDto> GetDocServiceUrlAsync(bool version)
{
var url = _commonLinkUtility.GetFullAbsolutePath(_filesLinkUtility.DocServiceApiUrl);

Expand All @@ -407,14 +402,14 @@ public async Task<object> 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
};
}
}

0 comments on commit 575e325

Please sign in to comment.