Merge branch 'feature/filter-loader' of github.com:ONLYOFFICE/AppServer into feature/filter-loader
This commit is contained in:
commit
515bd0d05f
@ -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 :-(.");
|
||||
|
@ -97,7 +97,7 @@ server {
|
||||
}
|
||||
|
||||
location /api/2.0 {
|
||||
location ~* /(files|encryption) {
|
||||
location ~* /(files|encryption|privacyroom) {
|
||||
proxy_pass http://localhost:5007;
|
||||
proxy_set_header X-REWRITER-URL $X_REWRITER_URL;
|
||||
}
|
||||
|
@ -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));
|
||||
|
@ -451,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) => {
|
||||
|
@ -83,8 +83,10 @@ namespace ASC.Files.Core
|
||||
{
|
||||
Logger.ErrorFormat("GetBreadCrumbs {0} with null", session.FolderId);
|
||||
return default;
|
||||
}
|
||||
return f.ID;
|
||||
}
|
||||
if (f is Folder<string> f1) return (T)Convert.ChangeType(f1.ID, typeof(T));
|
||||
if (f is Folder<int> f2) return (T)Convert.ChangeType(f2.ID, typeof(T));
|
||||
return (T)Convert.ChangeType(0, typeof(T));
|
||||
})
|
||||
: new List<T> { session.FolderId };
|
||||
|
||||
|
@ -227,7 +227,7 @@ namespace ASC.Web.Files.Services.WCFService
|
||||
}
|
||||
}
|
||||
|
||||
public ItemList<T> GetPath(T folderId)
|
||||
public ItemList<object> GetPath(T folderId)
|
||||
{
|
||||
var folderDao = GetFolderDao();
|
||||
var folder = folderDao.GetFolder(folderId);
|
||||
@ -235,7 +235,12 @@ namespace ASC.Web.Files.Services.WCFService
|
||||
ErrorIf(folder == null, FilesCommonResource.ErrorMassage_FolderNotFound);
|
||||
ErrorIf(!FileSecurity.CanRead(folder), FilesCommonResource.ErrorMassage_SecurityException_ViewFolder);
|
||||
|
||||
return new ItemList<T>(EntryManager.GetBreadCrumbs(folderId, folderDao).Select(f => f.ID));
|
||||
return new ItemList<object>(EntryManager.GetBreadCrumbs(folderId, folderDao).Select(f =>
|
||||
{
|
||||
if (f is Folder<string> f1) return (object)f1.ID;
|
||||
if (f is Folder<int> f2) return f2.ID;
|
||||
return 0;
|
||||
}));
|
||||
}
|
||||
|
||||
public DataWrapper<T> GetFolderItems(T parentId, int from, int count, FilterType filter, bool subjectGroup, string ssubject, string searchText, bool searchInContent, bool withSubfolders, OrderBy orderBy)
|
||||
@ -296,7 +301,8 @@ namespace ASC.Web.Files.Services.WCFService
|
||||
var prevVisible = breadCrumbs.ElementAtOrDefault(breadCrumbs.Count() - 2);
|
||||
if (prevVisible != null)
|
||||
{
|
||||
parent.ParentFolderID = prevVisible.ID;
|
||||
if (prevVisible is Folder<string> f1) parent.ParentFolderID = (T)Convert.ChangeType(f1.ID, typeof(T));
|
||||
if (prevVisible is Folder<int> f2) parent.ParentFolderID = (T)Convert.ChangeType(f2.ID, typeof(T));
|
||||
}
|
||||
|
||||
parent.Shareable = FileSharing.CanSetAccess(parent)
|
||||
@ -309,7 +315,12 @@ namespace ASC.Web.Files.Services.WCFService
|
||||
{
|
||||
Total = total,
|
||||
Entries = new ItemList<FileEntry>(entries.ToList()),
|
||||
FolderPathParts = new ItemList<T>(breadCrumbs.Select(f => f.ID)),
|
||||
FolderPathParts = new ItemList<object>(breadCrumbs.Select(f =>
|
||||
{
|
||||
if (f is Folder<string> f1) return (object)f1.ID;
|
||||
if (f is Folder<int> f2) return f2.ID;
|
||||
return 0;
|
||||
})),
|
||||
FolderInfo = parent,
|
||||
New = FileMarker.GetRootFoldersIdMarkedAsNew(parentId)
|
||||
};
|
||||
@ -579,27 +590,27 @@ namespace ASC.Web.Files.Services.WCFService
|
||||
|
||||
if (fileWrapper.TemplateId.Equals(default(T)))
|
||||
{
|
||||
var culture = UserManager.GetUsers(AuthContext.CurrentAccount.ID).GetCulture();
|
||||
var storeTemplate = GetStoreTemplate();
|
||||
var culture = UserManager.GetUsers(AuthContext.CurrentAccount.ID).GetCulture();
|
||||
var storeTemplate = GetStoreTemplate();
|
||||
|
||||
var path = FileConstant.NewDocPath + culture + "/";
|
||||
if (!storeTemplate.IsDirectory(path))
|
||||
{
|
||||
path = FileConstant.NewDocPath + "default/";
|
||||
}
|
||||
var path = FileConstant.NewDocPath + culture + "/";
|
||||
if (!storeTemplate.IsDirectory(path))
|
||||
{
|
||||
path = FileConstant.NewDocPath + "default/";
|
||||
}
|
||||
|
||||
path += "new" + fileExt;
|
||||
path += "new" + fileExt;
|
||||
|
||||
try
|
||||
{
|
||||
using var stream = storeTemplate.GetReadStream("", path);
|
||||
file.ContentLength = stream.CanSeek ? stream.Length : storeTemplate.GetFileSize(path);
|
||||
file = fileDao.SaveFile(file, stream);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw GenerateException(e);
|
||||
}
|
||||
try
|
||||
{
|
||||
using var stream = storeTemplate.GetReadStream("", path);
|
||||
file.ContentLength = stream.CanSeek ? stream.Length : storeTemplate.GetFileSize(path);
|
||||
file = fileDao.SaveFile(file, stream);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw GenerateException(e);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1316,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());
|
||||
}
|
||||
|
||||
|
||||
@ -1420,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
|
||||
{
|
||||
@ -1432,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()
|
||||
@ -1452,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)
|
||||
@ -2253,46 +2264,46 @@ namespace ASC.Web.Files.Services.WCFService
|
||||
{
|
||||
if (services.TryAddScoped<FileStorageService<string>>())
|
||||
{
|
||||
services.TryAddScoped<FileStorageService<int>>();
|
||||
//services.TryAddScoped<IFileStorageService, FileStorageService>();
|
||||
return services
|
||||
.AddGlobalService()
|
||||
.AddGlobalStoreService()
|
||||
.AddGlobalFolderHelperService()
|
||||
.AddAuthContextService()
|
||||
.AddUserManagerService()
|
||||
.AddFilesLinkUtilityService()
|
||||
.AddBaseCommonLinkUtilityService()
|
||||
.AddCoreBaseSettingsService()
|
||||
.AddCustomNamingPeopleService()
|
||||
.AddDisplayUserSettingsService()
|
||||
.AddPathProviderService()
|
||||
.AddDaoFactoryService()
|
||||
.AddFileMarkerService()
|
||||
.AddFilesSettingsHelperService()
|
||||
.AddFileUtilityService()
|
||||
.AddFileSecurityService()
|
||||
.AddFilesMessageService()
|
||||
.AddFileShareLinkService()
|
||||
.AddDocumentServiceConnectorService()
|
||||
.AddEntryManagerService()
|
||||
.AddDocumentServiceHelperService()
|
||||
.AddThirdpartyConfigurationService()
|
||||
.AddUrlShortener()
|
||||
.AddDocuSignHelperService()
|
||||
.AddDocuSignTokenService()
|
||||
.AddFileConverterService()
|
||||
.AddNotifyClientService()
|
||||
.AddFileSharingService()
|
||||
.AddDocumentServiceTrackerHelperService()
|
||||
.AddSocketManagerService()
|
||||
.AddFileOperationsManagerHelperService()
|
||||
.AddFileSharingAceHelperService()
|
||||
.AddTenantManagerService();
|
||||
}
|
||||
services.TryAddScoped<FileStorageService<int>>();
|
||||
//services.TryAddScoped<IFileStorageService, FileStorageService>();
|
||||
return services
|
||||
.AddGlobalService()
|
||||
.AddGlobalStoreService()
|
||||
.AddGlobalFolderHelperService()
|
||||
.AddAuthContextService()
|
||||
.AddUserManagerService()
|
||||
.AddFilesLinkUtilityService()
|
||||
.AddBaseCommonLinkUtilityService()
|
||||
.AddCoreBaseSettingsService()
|
||||
.AddCustomNamingPeopleService()
|
||||
.AddDisplayUserSettingsService()
|
||||
.AddPathProviderService()
|
||||
.AddDaoFactoryService()
|
||||
.AddFileMarkerService()
|
||||
.AddFilesSettingsHelperService()
|
||||
.AddFileUtilityService()
|
||||
.AddFileSecurityService()
|
||||
.AddFilesMessageService()
|
||||
.AddFileShareLinkService()
|
||||
.AddDocumentServiceConnectorService()
|
||||
.AddEntryManagerService()
|
||||
.AddDocumentServiceHelperService()
|
||||
.AddThirdpartyConfigurationService()
|
||||
.AddUrlShortener()
|
||||
.AddDocuSignHelperService()
|
||||
.AddDocuSignTokenService()
|
||||
.AddFileConverterService()
|
||||
.AddNotifyClientService()
|
||||
.AddFileSharingService()
|
||||
.AddDocumentServiceTrackerHelperService()
|
||||
.AddSocketManagerService()
|
||||
.AddFileOperationsManagerHelperService()
|
||||
.AddFileSharingAceHelperService()
|
||||
.AddTenantManagerService();
|
||||
}
|
||||
|
||||
return services;
|
||||
}
|
||||
return services;
|
||||
}
|
||||
}
|
||||
|
||||
public class FileModel<T>
|
||||
|
@ -95,7 +95,6 @@ namespace ASC.Web.Files.Core.Search
|
||||
{
|
||||
TenantManager.SetCurrentTenant(r.TenantId);
|
||||
fileDao.InitDocument(r);
|
||||
TenantManager.CurrentTenant = null;
|
||||
});
|
||||
Index(data);
|
||||
}
|
||||
|
@ -127,6 +127,7 @@ namespace ASC.Files.Thirdparty
|
||||
{
|
||||
if (services.TryAddScoped<IProviderDao, ProviderAccountDao>())
|
||||
{
|
||||
services.TryAddScoped<CachedProviderAccountDao>();
|
||||
services.TryAddSingleton<CachedProviderAccountDaoNotify>();
|
||||
|
||||
return services
|
||||
|
@ -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)
|
||||
@ -529,7 +528,7 @@ namespace ASC.Files.Thirdparty.ProviderDao
|
||||
{
|
||||
if (services.TryAddScoped<ProviderFileDao>())
|
||||
{
|
||||
services.TryAddScoped<File<string>>();
|
||||
services.TryAddTransient<File<string>>();
|
||||
services.TryAddScoped<IFileDao<string>, ProviderFileDao>();
|
||||
|
||||
return services
|
||||
|
@ -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() ?? "");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ namespace ASC.Web.Files.Configuration
|
||||
Additional = new Dictionary<string, object>
|
||||
{
|
||||
{ "Author", r.CreateByString.HtmlEncode() },
|
||||
{ "Path", FolderPathBuilder(EntryManager.GetBreadCrumbs(r.FolderID, folderDao)) },
|
||||
{ "Path", FolderPathBuilder<int>(EntryManager.GetBreadCrumbs(r.FolderID, folderDao)) },
|
||||
{ "Size", FileSizeComment.FilesSizeToString(r.ContentLength) }
|
||||
}
|
||||
}
|
||||
@ -157,7 +157,7 @@ namespace ASC.Web.Files.Configuration
|
||||
Additional = new Dictionary<string, object>
|
||||
{
|
||||
{ "Author", f.CreateByString.HtmlEncode() },
|
||||
{ "Path", FolderPathBuilder(EntryManager.GetBreadCrumbs(f.ID, folderDao)) },
|
||||
{ "Path", FolderPathBuilder<int>(EntryManager.GetBreadCrumbs(f.ID, folderDao)) },
|
||||
{ "IsFolder", true }
|
||||
}
|
||||
});
|
||||
@ -165,7 +165,7 @@ namespace ASC.Web.Files.Configuration
|
||||
return result.Concat(resultFolder).ToArray();
|
||||
}
|
||||
|
||||
private static string FolderPathBuilder<T>(IEnumerable<Folder<T>> folders)
|
||||
private static string FolderPathBuilder<T>(IEnumerable<FileEntry> folders)
|
||||
{
|
||||
var titles = folders.Select(f => f.Title).ToList();
|
||||
const string separator = " \\ ";
|
||||
|
9
products/ASC.Files/Core/Model/PrivacyRoomModel.cs
Normal file
9
products/ASC.Files/Core/Model/PrivacyRoomModel.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace ASC.Files.Core.Model
|
||||
{
|
||||
public class PrivacyRoomModel
|
||||
{
|
||||
public string PublicKey { get; set; }
|
||||
public string PrivateKeyEnc { get; set; }
|
||||
public bool Enable { get; set; }
|
||||
}
|
||||
}
|
@ -37,7 +37,7 @@ namespace ASC.Web.Files.Services.WCFService
|
||||
public int Total { get; set; }
|
||||
|
||||
[JsonPropertyName("path_parts")]
|
||||
public ItemList<T> FolderPathParts { get; set; }
|
||||
public ItemList<object> FolderPathParts { get; set; }
|
||||
|
||||
[JsonPropertyName("folder_info")]
|
||||
public Folder<T> FolderInfo { get; set; }
|
||||
|
@ -112,18 +112,18 @@ namespace ASC.Web.Files.Utils
|
||||
AuthContext = authContext;
|
||||
}
|
||||
|
||||
public List<Folder<T>> GetBreadCrumbs<T>(T folderId)
|
||||
public List<FileEntry> GetBreadCrumbs<T>(T folderId)
|
||||
{
|
||||
var folderDao = DaoFactory.GetFolderDao<T>();
|
||||
return GetBreadCrumbs(folderId, folderDao);
|
||||
}
|
||||
|
||||
public List<Folder<T>> GetBreadCrumbs<T>(T folderId, IFolderDao<T> folderDao)
|
||||
public List<FileEntry> GetBreadCrumbs<T>(T folderId, IFolderDao<T> folderDao)
|
||||
{
|
||||
if (folderId == null) return new List<Folder<T>>();
|
||||
var breadCrumbs = FileSecurity.FilterRead(folderDao.GetParentFolders(folderId)).ToList();
|
||||
if (folderId == null) return new List<FileEntry>();
|
||||
var breadCrumbs = FileSecurity.FilterRead(folderDao.GetParentFolders(folderId)).Cast<FileEntry>().ToList();
|
||||
|
||||
var firstVisible = breadCrumbs.ElementAtOrDefault(0);
|
||||
var firstVisible = breadCrumbs.ElementAtOrDefault(0) as Folder<T>;
|
||||
|
||||
var rootId = 0;
|
||||
if (firstVisible == null)
|
||||
@ -160,10 +160,12 @@ namespace ASC.Web.Files.Utils
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var folderDaoInt = DaoFactory.GetFolderDao<int>();
|
||||
|
||||
if (rootId != 0)
|
||||
{
|
||||
breadCrumbs.Insert(0, folderDao.GetFolder((T)Convert.ChangeType(rootId, typeof(T))));
|
||||
breadCrumbs.Insert(0, folderDaoInt.GetFolder(rootId));
|
||||
}
|
||||
|
||||
return breadCrumbs;
|
||||
@ -715,12 +717,12 @@ namespace ASC.Web.Files.Utils
|
||||
}
|
||||
|
||||
|
||||
public List<Folder<T>> GetBreadCrumbs<T>(T folderId)
|
||||
public List<FileEntry> GetBreadCrumbs<T>(T folderId)
|
||||
{
|
||||
return BreadCrumbsManager.GetBreadCrumbs(folderId);
|
||||
}
|
||||
|
||||
public List<Folder<T>> GetBreadCrumbs<T>(T folderId, IFolderDao<T> folderDao)
|
||||
public List<FileEntry> GetBreadCrumbs<T>(T folderId, IFolderDao<T> folderDao)
|
||||
{
|
||||
return BreadCrumbsManager.GetBreadCrumbs(folderId, folderDao);
|
||||
}
|
||||
|
@ -880,13 +880,13 @@ namespace ASC.Api.Documents
|
||||
/// <category>Folders</category>
|
||||
/// <returns>Parent folders</returns>
|
||||
[Read("folder/{folderId}/path", DisableFormat = true)]
|
||||
public IEnumerable<FolderWrapper<string>> GetFolderPath(string folderId)
|
||||
public IEnumerable<FileEntryWrapper> GetFolderPath(string folderId)
|
||||
{
|
||||
return FilesControllerHelperString.GetFolderPath(folderId);
|
||||
}
|
||||
|
||||
[Read("folder/{folderId:int}/path")]
|
||||
public IEnumerable<FolderWrapper<int>> GetFolderPath(int folderId)
|
||||
public IEnumerable<FileEntryWrapper> GetFolderPath(int folderId)
|
||||
{
|
||||
return FilesControllerHelperInt.GetFolderPath(folderId);
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ using ASC.Core;
|
||||
using ASC.Core.Billing;
|
||||
using ASC.Core.Common.Settings;
|
||||
using ASC.Core.Users;
|
||||
using ASC.Files.Core.Model;
|
||||
using ASC.MessagingSystem;
|
||||
using ASC.Web.Api.Routing;
|
||||
using ASC.Web.Core.PublicResources;
|
||||
@ -46,7 +47,7 @@ namespace ASC.Api.Documents
|
||||
{
|
||||
[DefaultRoute]
|
||||
[ApiController]
|
||||
public class PrivacyRoomApi : ControllerBase
|
||||
public class PrivacyRoomController : ControllerBase
|
||||
{
|
||||
private AuthContext AuthContext { get; }
|
||||
private PermissionContext PermissionContext { get; }
|
||||
@ -58,7 +59,7 @@ namespace ASC.Api.Documents
|
||||
private MessageService MessageService { get; }
|
||||
private ILog Log { get; }
|
||||
|
||||
public PrivacyRoomApi(
|
||||
public PrivacyRoomController(
|
||||
AuthContext authContext,
|
||||
PermissionContext permissionContext,
|
||||
SettingsManager settingsManager,
|
||||
@ -85,7 +86,7 @@ namespace ASC.Api.Documents
|
||||
/// </summary>
|
||||
/// <visible>false</visible>
|
||||
[Update("keys")]
|
||||
public object SetKeys(string publicKey, string privateKeyEnc)
|
||||
public object SetKeys(PrivacyRoomModel model)
|
||||
{
|
||||
PermissionContext.DemandPermissions(new UserSecurityProvider(AuthContext.CurrentAccount.ID), Constants.Action_EditUser);
|
||||
|
||||
@ -102,7 +103,7 @@ namespace ASC.Api.Documents
|
||||
Log.InfoFormat("User {0} updates address", AuthContext.CurrentAccount.ID);
|
||||
}
|
||||
|
||||
EncryptionKeyPairHelper.SetKeyPair(publicKey, privateKeyEnc);
|
||||
EncryptionKeyPairHelper.SetKeyPair(model.PublicKey, model.PrivateKeyEnc);
|
||||
|
||||
return new
|
||||
{
|
||||
@ -151,11 +152,11 @@ namespace ASC.Api.Documents
|
||||
/// <returns></returns>
|
||||
/// <visible>false</visible>
|
||||
[Update("")]
|
||||
public bool SetPrivacyRoom(bool enable)
|
||||
public bool SetPrivacyRoom(PrivacyRoomModel model)
|
||||
{
|
||||
PermissionContext.DemandPermissions(SecutiryConstants.EditPortalSettings);
|
||||
|
||||
if (enable)
|
||||
if (model.Enable)
|
||||
{
|
||||
if (!PrivacyRoomSettings.IsAvailable(TenantManager))
|
||||
{
|
||||
@ -163,11 +164,11 @@ namespace ASC.Api.Documents
|
||||
}
|
||||
}
|
||||
|
||||
PrivacyRoomSettings.SetEnabled(TenantManager, SettingsManager, enable);
|
||||
PrivacyRoomSettings.SetEnabled(TenantManager, SettingsManager, model.Enable);
|
||||
|
||||
MessageService.Send(enable ? MessageAction.PrivacyRoomEnable : MessageAction.PrivacyRoomDisable);
|
||||
MessageService.Send(model.Enable ? MessageAction.PrivacyRoomEnable : MessageAction.PrivacyRoomDisable);
|
||||
|
||||
return enable;
|
||||
return model.Enable;
|
||||
}
|
||||
}
|
||||
|
||||
@ -175,7 +176,7 @@ namespace ASC.Api.Documents
|
||||
{
|
||||
public static DIHelper AddPrivacyRoomApiService(this DIHelper services)
|
||||
{
|
||||
if (services.TryAddScoped<PrivacyRoomApi>())
|
||||
if (services.TryAddScoped<PrivacyRoomController>())
|
||||
{
|
||||
services
|
||||
.AddAuthContextService()
|
||||
|
@ -340,9 +340,18 @@ namespace ASC.Files.Helpers
|
||||
return FolderWrapperHelper.Get(folder);
|
||||
}
|
||||
|
||||
public IEnumerable<FolderWrapper<T>> GetFolderPath(T folderId)
|
||||
public IEnumerable<FileEntryWrapper> GetFolderPath(T folderId)
|
||||
{
|
||||
return EntryManager.GetBreadCrumbs(folderId).Select(FolderWrapperHelper.Get);
|
||||
return EntryManager.GetBreadCrumbs(folderId).Select(r =>
|
||||
{
|
||||
if (r is Folder<string> f1)
|
||||
return FolderWrapperHelper.Get(f1);
|
||||
|
||||
if (r is Folder<int> f2)
|
||||
return FolderWrapperHelper.Get(f2);
|
||||
|
||||
return default(FileEntryWrapper);
|
||||
});
|
||||
}
|
||||
|
||||
public FileWrapper<T> GetFileInfo(T fileId, int version = -1)
|
||||
|
@ -4,10 +4,13 @@ using System.Text.Json.Serialization;
|
||||
using ASC.Api.Core;
|
||||
using ASC.Api.Documents;
|
||||
using ASC.Common;
|
||||
using ASC.Common.DependencyInjection;
|
||||
using ASC.Web.Files;
|
||||
using ASC.Web.Files.HttpHandlers;
|
||||
using ASC.Web.Studio.Core.Notify;
|
||||
|
||||
using Autofac;
|
||||
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
@ -83,6 +86,11 @@ namespace ASC.Files
|
||||
{
|
||||
appBranch.UseDocuSignHandler();
|
||||
});
|
||||
}
|
||||
|
||||
public void ConfigureContainer(ContainerBuilder builder)
|
||||
{
|
||||
builder.Register(Configuration, HostEnvironment.ContentRootPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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