Merge branch 'feature/thirdparty-integrations' of https://github.com/ONLYOFFICE/CommunityServer-AspNetCore into feature/thirdparty-integrations
This commit is contained in:
commit
1da1cde38e
@ -91,33 +91,7 @@ namespace ASC.Core
|
||||
|
||||
public class TenantManager
|
||||
{
|
||||
private class TenantHolder
|
||||
{
|
||||
public Tenant Tenant;
|
||||
}
|
||||
|
||||
private static readonly AsyncLocal<TenantHolder> currentTenant = new AsyncLocal<TenantHolder>();
|
||||
|
||||
public Tenant CurrentTenant
|
||||
{
|
||||
get
|
||||
{
|
||||
return currentTenant.Value?.Tenant;
|
||||
}
|
||||
set
|
||||
{
|
||||
var holder = currentTenant.Value;
|
||||
if (holder != null)
|
||||
{
|
||||
holder.Tenant = null;
|
||||
}
|
||||
|
||||
if (value != null)
|
||||
{
|
||||
currentTenant.Value = new TenantHolder { Tenant = value };
|
||||
}
|
||||
}
|
||||
}
|
||||
private Tenant CurrentTenant { get; set; }
|
||||
|
||||
public const string CURRENT_TENANT = "CURRENT_TENANT";
|
||||
internal ITenantService TenantService { get; set; }
|
||||
@ -250,12 +224,13 @@ namespace ASC.Core
|
||||
}
|
||||
|
||||
public Tenant GetCurrentTenant(bool throwIfNotFound, HttpContext context)
|
||||
{
|
||||
Tenant tenant = null;
|
||||
{
|
||||
if (CurrentTenant != null)
|
||||
{
|
||||
return CurrentTenant;
|
||||
}
|
||||
|
||||
Tenant tenant = null;
|
||||
|
||||
if (context != null)
|
||||
{
|
||||
@ -266,10 +241,7 @@ namespace ASC.Core
|
||||
context.Items[CURRENT_TENANT] = tenant;
|
||||
}
|
||||
}
|
||||
if (tenant == null)
|
||||
{
|
||||
tenant = CallContext.GetData(CURRENT_TENANT) as Tenant;
|
||||
}
|
||||
|
||||
if (tenant == null && throwIfNotFound)
|
||||
{
|
||||
throw new Exception("Could not resolve current tenant :-(.");
|
||||
|
@ -167,13 +167,15 @@ class FilesRowContent extends React.PureComponent {
|
||||
|
||||
if (itemTitle.trim() === "") return this.completeAction(itemId);
|
||||
|
||||
let tab = item.fileExst ? window.open("about:blank", "_blank") : null;
|
||||
|
||||
!item.fileExst
|
||||
? createFolder(item.parentId, itemTitle)
|
||||
.then(() => this.completeAction(itemId))
|
||||
.finally(() => setIsLoading(false))
|
||||
: createFile(item.parentId, `${itemTitle}.${item.fileExst}`)
|
||||
.then((file) => {
|
||||
openDocEditor(file.id);
|
||||
openDocEditor(file.id, tab, file.webUrl);
|
||||
this.completeAction(itemId);
|
||||
})
|
||||
.finally(() => setIsLoading(false));
|
||||
|
@ -68,6 +68,7 @@ import {
|
||||
getMediaViewerId,
|
||||
getMediaViewerVisibility,
|
||||
getSelectedFolderParentId,
|
||||
getSelectedFolderProviderItem,
|
||||
getSelected,
|
||||
getSelectedFolderTitle,
|
||||
getSelection,
|
||||
@ -450,12 +451,16 @@ class SectionBodyContent extends React.Component {
|
||||
return window.open(this.props.selection[0].viewUrl, "_blank");
|
||||
};
|
||||
|
||||
openDocEditor = (id) => {
|
||||
openDocEditor = (id, tab = null, url = null) => {
|
||||
return this.props
|
||||
.addFileToRecentlyViewed(id)
|
||||
.then(() => console.log("Pushed to recently viewed"))
|
||||
.catch((e) => console.error(e))
|
||||
.finally(window.open(`./doceditor?fileId=${id}`, "_blank"));
|
||||
.finally(
|
||||
tab
|
||||
? (tab.location = url)
|
||||
: window.open(`./doceditor?fileId=${id}`, "_blank")
|
||||
);
|
||||
};
|
||||
|
||||
onClickLinkEdit = (e) => {
|
||||
@ -1433,7 +1438,7 @@ class SectionBodyContent extends React.Component {
|
||||
};
|
||||
|
||||
render() {
|
||||
console.log("Files Home SectionBodyContent render", this.props);
|
||||
//console.log("Files Home SectionBodyContent render", this.props);
|
||||
|
||||
const {
|
||||
viewer,
|
||||
@ -1457,6 +1462,7 @@ class SectionBodyContent extends React.Component {
|
||||
mediaViewerImageFormats,
|
||||
mediaViewerMediaFormats,
|
||||
tooltipValue,
|
||||
providerItem,
|
||||
} = this.props;
|
||||
|
||||
const {
|
||||
@ -1489,7 +1495,8 @@ class SectionBodyContent extends React.Component {
|
||||
});
|
||||
}
|
||||
|
||||
return (!fileAction.id && currentFolderCount === 0) || null ? (
|
||||
return (!fileAction.id && currentFolderCount === 0 && !providerItem) ||
|
||||
null ? (
|
||||
parentId === 0 ? (
|
||||
this.renderEmptyRootFolderContainer()
|
||||
) : (
|
||||
@ -1754,6 +1761,7 @@ const mapStateToProps = (state) => {
|
||||
myDocumentsId: getMyFolderId(state),
|
||||
organizationName: getOrganizationName(state),
|
||||
parentId: getSelectedFolderParentId(state),
|
||||
providerItem: getSelectedFolderProviderItem(state),
|
||||
privacyInstructions: getPrivacyInstructionsLink(state),
|
||||
selected: getSelected(state),
|
||||
selectedFolderId: getSelectedFolderId(state),
|
||||
|
@ -302,6 +302,10 @@ export const getSelectedFolderParentId = (state) => {
|
||||
return state.files.selectedFolder.parentId;
|
||||
};
|
||||
|
||||
export const getSelectedFolderProviderItem = (state) => {
|
||||
return state.files.selectedFolder.providerItem;
|
||||
};
|
||||
|
||||
export const getSelectedFolderNew = (state) => {
|
||||
return state.files.selectedFolder.new;
|
||||
};
|
||||
@ -835,7 +839,7 @@ export const getFilesList = (state) => {
|
||||
shared,
|
||||
title,
|
||||
updated,
|
||||
updatedBu,
|
||||
updatedBy,
|
||||
version,
|
||||
versionGroup,
|
||||
viewUrl,
|
||||
@ -909,7 +913,7 @@ export const getFilesList = (state) => {
|
||||
shared,
|
||||
title,
|
||||
updated,
|
||||
updatedBu,
|
||||
updatedBy,
|
||||
value,
|
||||
version,
|
||||
versionGroup,
|
||||
@ -983,7 +987,7 @@ export const getFilterSelectedItem = (state) => {
|
||||
|
||||
export const getPrivacyInstructionsLink = (state) => {
|
||||
return state.files.privacyInstructions;
|
||||
}
|
||||
};
|
||||
|
||||
export const getHeaderVisible = createSelector(
|
||||
getSelectionLength,
|
||||
@ -1083,11 +1087,14 @@ export const getAccessedSelected = createSelector(getSelection, (selection) => {
|
||||
});
|
||||
|
||||
export const getOperationsFolders = createSelector(
|
||||
getTreeFolders, (treeFolders) => {
|
||||
return treeFolders.filter(folder => (
|
||||
folder.rootFolderType === FolderType.USER ||
|
||||
folder.rootFolderType === FolderType.COMMON ||
|
||||
folder.rootFolderType === FolderType.Projects
|
||||
) && folder);
|
||||
getTreeFolders,
|
||||
(treeFolders) => {
|
||||
return treeFolders.filter(
|
||||
(folder) =>
|
||||
(folder.rootFolderType === FolderType.USER ||
|
||||
folder.rootFolderType === FolderType.COMMON ||
|
||||
folder.rootFolderType === FolderType.Projects) &&
|
||||
folder
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
|
@ -1327,7 +1327,7 @@ namespace ASC.Web.Files.Services.WCFService
|
||||
{
|
||||
ErrorIf(!folders.Any() && !files.Any(), FilesCommonResource.ErrorMassage_BadRequest);
|
||||
|
||||
return FileOperationsManager.Download(AuthContext.CurrentAccount.ID, TenantManager.CurrentTenant, folders, files, GetHttpHeaders());
|
||||
return FileOperationsManager.Download(AuthContext.CurrentAccount.ID, TenantManager.GetCurrentTenant(), folders, files, GetHttpHeaders());
|
||||
}
|
||||
|
||||
|
||||
@ -1431,7 +1431,7 @@ namespace ASC.Web.Files.Services.WCFService
|
||||
ItemList<FileOperationResult> result;
|
||||
if (foldersId.Any() || filesId.Any())
|
||||
{
|
||||
result = FileOperationsManager.MoveOrCopy(AuthContext.CurrentAccount.ID, TenantManager.CurrentTenant, foldersId, filesId, destFolderId, ic, resolve, !deleteAfter, GetHttpHeaders());
|
||||
result = FileOperationsManager.MoveOrCopy(AuthContext.CurrentAccount.ID, TenantManager.GetCurrentTenant(), foldersId, filesId, destFolderId, ic, resolve, !deleteAfter, GetHttpHeaders());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1443,16 +1443,16 @@ namespace ASC.Web.Files.Services.WCFService
|
||||
|
||||
public ItemList<FileOperationResult> DeleteFile(string action, T fileId, bool ignoreException = false, bool deleteAfter = false, bool immediately = false)
|
||||
{
|
||||
return FileOperationsManager.Delete(AuthContext.CurrentAccount.ID, TenantManager.CurrentTenant, new List<T>(), new List<T>() { fileId }, ignoreException, !deleteAfter, immediately, GetHttpHeaders());
|
||||
return FileOperationsManager.Delete(AuthContext.CurrentAccount.ID, TenantManager.GetCurrentTenant(), new List<T>(), new List<T>() { fileId }, ignoreException, !deleteAfter, immediately, GetHttpHeaders());
|
||||
}
|
||||
public ItemList<FileOperationResult> DeleteFolder(string action, T folderId, bool ignoreException = false, bool deleteAfter = false, bool immediately = false)
|
||||
{
|
||||
return FileOperationsManager.Delete(AuthContext.CurrentAccount.ID, TenantManager.CurrentTenant, new List<T>() { folderId }, new List<T>(), ignoreException, !deleteAfter, immediately, GetHttpHeaders());
|
||||
return FileOperationsManager.Delete(AuthContext.CurrentAccount.ID, TenantManager.GetCurrentTenant(), new List<T>() { folderId }, new List<T>(), ignoreException, !deleteAfter, immediately, GetHttpHeaders());
|
||||
}
|
||||
|
||||
public ItemList<FileOperationResult> DeleteItems(string action, List<JsonElement> files, List<JsonElement> folders, bool ignoreException = false, bool deleteAfter = false, bool immediately = false)
|
||||
{
|
||||
return FileOperationsManager.Delete(AuthContext.CurrentAccount.ID, TenantManager.CurrentTenant, folders, files, ignoreException, !deleteAfter, immediately, GetHttpHeaders());
|
||||
return FileOperationsManager.Delete(AuthContext.CurrentAccount.ID, TenantManager.GetCurrentTenant(), folders, files, ignoreException, !deleteAfter, immediately, GetHttpHeaders());
|
||||
}
|
||||
|
||||
public ItemList<FileOperationResult> EmptyTrash()
|
||||
@ -1463,7 +1463,7 @@ namespace ASC.Web.Files.Services.WCFService
|
||||
var foldersId = folderDao.GetFolders(trashId).Select(f => f.ID).ToList();
|
||||
var filesId = fileDao.GetFiles(trashId).ToList();
|
||||
|
||||
return FileOperationsManager.Delete(AuthContext.CurrentAccount.ID, TenantManager.CurrentTenant, foldersId, filesId, false, true, false, GetHttpHeaders());
|
||||
return FileOperationsManager.Delete(AuthContext.CurrentAccount.ID, TenantManager.GetCurrentTenant(), foldersId, filesId, false, true, false, GetHttpHeaders());
|
||||
}
|
||||
|
||||
public ItemList<FileOperationResult> CheckConversion(ItemList<ItemList<string>> filesInfoJSON)
|
||||
|
@ -95,7 +95,6 @@ namespace ASC.Web.Files.Core.Search
|
||||
{
|
||||
TenantManager.SetCurrentTenant(r.TenantId);
|
||||
fileDao.InitDocument(r);
|
||||
TenantManager.CurrentTenant = null;
|
||||
});
|
||||
Index(data);
|
||||
}
|
||||
|
@ -467,42 +467,41 @@ namespace ASC.Files.Thirdparty.ProviderDao
|
||||
|
||||
public void ReassignFiles(string[] fileIds, Guid newOwnerId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public List<File<string>> GetFiles(string[] parentIds, FilterType filterType, bool subjectGroup, Guid subjectID, string searchText, bool searchInContent)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return new List<File<string>>();
|
||||
}
|
||||
|
||||
public IEnumerable<File<string>> Search(string text, bool bunch)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool IsExistOnStorage(File<string> file)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void SaveEditHistory(File<string> file, string changes, Stream differenceStream)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
//Do nothing
|
||||
}
|
||||
|
||||
public List<EditHistory> GetEditHistory(DocumentServiceHelper documentServiceHelper, string fileId, int fileVersion)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return null;
|
||||
}
|
||||
|
||||
public Stream GetDifferenceStream(File<string> file)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool ContainChanges(string fileId, int fileVersion)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return false;
|
||||
}
|
||||
|
||||
public string GetUniqFilePath(File<string> file, string fileTitle)
|
||||
|
@ -289,7 +289,7 @@ namespace ASC.Web.Files
|
||||
}
|
||||
else
|
||||
{
|
||||
await DownloadFile(context, q);
|
||||
await DownloadFile(context, q.FirstOrDefault() ?? "");
|
||||
}
|
||||
}
|
||||
|
||||
@ -542,25 +542,23 @@ namespace ASC.Web.Files
|
||||
|
||||
private async Task<bool> SendStreamByChunksAsync(HttpContext context, long toRead, string title, Stream fileStream, bool flushed)
|
||||
{
|
||||
var cl = 0;
|
||||
//context.Response.Buffer = false;
|
||||
context.Response.Headers.Add("Connection", "Keep-Alive");
|
||||
context.Response.Headers.Add("Connection", "Keep-Alive");
|
||||
context.Response.ContentLength = toRead;
|
||||
context.Response.Headers.Add("Content-Disposition", ContentDispositionUtil.GetHeaderValue(title));
|
||||
context.Response.ContentType = MimeMapping.GetMimeMapping(title);
|
||||
|
||||
var bufferSize = Convert.ToInt32(Math.Min(Convert.ToInt64(32 * 1024), toRead)); // 32KB
|
||||
var bufferSize = Convert.ToInt32(Math.Min(32 * 1024, toRead)); // 32KB
|
||||
var buffer = new byte[bufferSize];
|
||||
while (toRead > 0)
|
||||
{
|
||||
var length = await fileStream.ReadAsync(buffer, 0, bufferSize);
|
||||
cl += length;
|
||||
await context.Response.Body.WriteAsync(buffer, 0, length, context.RequestAborted);
|
||||
await context.Response.Body.FlushAsync();
|
||||
flushed = true;
|
||||
toRead -= length;
|
||||
}
|
||||
|
||||
context.Response.Headers.Add("Content-Length", cl.ToString(CultureInfo.InvariantCulture));
|
||||
|
||||
return flushed;
|
||||
}
|
||||
@ -575,7 +573,7 @@ namespace ASC.Web.Files
|
||||
}
|
||||
else
|
||||
{
|
||||
await StreamFile(context, q);
|
||||
await StreamFile(context, q.FirstOrDefault() ?? "");
|
||||
}
|
||||
}
|
||||
|
||||
@ -864,7 +862,7 @@ namespace ASC.Web.Files
|
||||
}
|
||||
else
|
||||
{
|
||||
await DifferenceFile(context, q);
|
||||
await DifferenceFile(context, q.FirstOrDefault() ?? "");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1107,7 +1105,7 @@ namespace ASC.Web.Files
|
||||
}
|
||||
else
|
||||
{
|
||||
Redirect(context, q, q1);
|
||||
Redirect(context, q.FirstOrDefault() ?? "", q1.FirstOrDefault() ?? "");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,8 +36,6 @@ using System.ServiceModel.Security;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web;
|
||||
|
||||
using ARSoft.Tools.Net.Dns;
|
||||
|
||||
using ASC.Api.Collections;
|
||||
using ASC.Api.Core;
|
||||
using ASC.Api.Utils;
|
||||
@ -2355,11 +2353,11 @@ namespace ASC.Api.Settings
|
||||
[Read("telegramlink")]
|
||||
public object TelegramLink()
|
||||
{
|
||||
var currentLink = TelegramHelper.CurrentRegistrationLink(AuthContext.CurrentAccount.ID, TenantManager.CurrentTenant.TenantId);
|
||||
var currentLink = TelegramHelper.CurrentRegistrationLink(AuthContext.CurrentAccount.ID, Tenant.TenantId);
|
||||
|
||||
if (string.IsNullOrEmpty(currentLink))
|
||||
{
|
||||
var url = TelegramHelper.RegisterUser(AuthContext.CurrentAccount.ID, TenantManager.CurrentTenant.TenantId);
|
||||
var url = TelegramHelper.RegisterUser(AuthContext.CurrentAccount.ID, Tenant.TenantId);
|
||||
return url;
|
||||
}
|
||||
else
|
||||
@ -2375,7 +2373,7 @@ namespace ASC.Api.Settings
|
||||
[Read("telegramisconnected")]
|
||||
public object TelegramIsConnected()
|
||||
{
|
||||
return (int)TelegramHelper.UserIsConnected(AuthContext.CurrentAccount.ID, TenantManager.CurrentTenant.TenantId);
|
||||
return (int)TelegramHelper.UserIsConnected(AuthContext.CurrentAccount.ID, Tenant.TenantId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -2384,7 +2382,7 @@ namespace ASC.Api.Settings
|
||||
[Delete("telegramdisconnect")]
|
||||
public void TelegramDisconnect()
|
||||
{
|
||||
TelegramHelper.Disconnect(AuthContext.CurrentAccount.ID, TenantManager.CurrentTenant.TenantId);
|
||||
TelegramHelper.Disconnect(AuthContext.CurrentAccount.ID, Tenant.TenantId);
|
||||
}
|
||||
|
||||
private readonly int maxCount = 10;
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "asc-web-common",
|
||||
"version": "1.0.267",
|
||||
"version": "1.0.268",
|
||||
"description": "Ascensio System SIA common components and solutions library",
|
||||
"license": "AGPL-3.0",
|
||||
"files": [
|
||||
|
@ -38,7 +38,6 @@ const StyledArticle = styled.article`
|
||||
? props.pinned
|
||||
? `
|
||||
min-width: 240px;
|
||||
z-index: 400;
|
||||
`
|
||||
: `
|
||||
position: fixed !important;
|
||||
|
Loading…
Reference in New Issue
Block a user