Merge branch 'release/rc-v1.2.0' of github.com:ONLYOFFICE/DocSpace into release/rc-v1.2.0
This commit is contained in:
commit
8ba37860c8
@ -244,6 +244,11 @@ public class CachedUserService : IUserService, ICachedService
|
||||
return user;
|
||||
}
|
||||
|
||||
public IEnumerable<int> GetTenantsWithFeeds(DateTime from)
|
||||
{
|
||||
return Service.GetTenantsWithFeeds(from);
|
||||
}
|
||||
|
||||
public void RemoveUser(int tenant, Guid id)
|
||||
{
|
||||
Service.RemoveUser(tenant, id);
|
||||
|
@ -461,6 +461,11 @@ public class UserManager
|
||||
return _userService.GetDavUserEmails(_tenantManager.GetCurrentTenant().Id);
|
||||
}
|
||||
|
||||
public IEnumerable<int> GetTenantsWithFeeds(DateTime from)
|
||||
{
|
||||
return _userService.GetTenantsWithFeeds(from);
|
||||
}
|
||||
|
||||
public async Task DeleteUser(Guid id)
|
||||
{
|
||||
if (IsSystemUser(id))
|
||||
|
@ -57,6 +57,7 @@ public interface IUserService
|
||||
UserInfo GetUserByPasswordHash(int tenant, string login, string passwordHash);
|
||||
UserInfo GetUserByUserName(int tenant, string userName);
|
||||
UserInfo SaveUser(int tenant, UserInfo user);
|
||||
IEnumerable<int> GetTenantsWithFeeds(DateTime from);
|
||||
void RemoveGroup(int tenant, Guid id);
|
||||
void RemoveUser(int tenant, Guid id);
|
||||
IEnumerable<string> GetDavUserEmails(int tenant);
|
||||
|
@ -262,6 +262,15 @@ public class EFUserService : IUserService
|
||||
.ProjectTo<UserInfo>(_mapper.ConfigurationProvider);
|
||||
}
|
||||
|
||||
public IEnumerable<int> GetTenantsWithFeeds(DateTime from)
|
||||
{
|
||||
var userDbContext = _dbContextFactory.CreateDbContext();
|
||||
|
||||
var tenants = userDbContext.Users.Where(u => u.LastModified > from).Select(u => u.Tenant).Distinct().ToList();
|
||||
|
||||
return tenants;
|
||||
}
|
||||
|
||||
public void RemoveGroup(int tenant, Guid id)
|
||||
{
|
||||
RemoveGroup(tenant, id, false);
|
||||
|
@ -52,12 +52,14 @@ public static class Constants
|
||||
public const string FilesModule = "files";
|
||||
public const string FoldersModule = "folders";
|
||||
public const string RoomsModule = "rooms";
|
||||
public const string UsersModule = "users";
|
||||
|
||||
#endregion
|
||||
|
||||
#region Products
|
||||
|
||||
public const string Documents = "documents";
|
||||
public const string People = "people";
|
||||
|
||||
#endregion
|
||||
|
||||
@ -69,6 +71,7 @@ public static class Constants
|
||||
public const string SharedFileItem = "sharedFile";
|
||||
public const string FolderItem = "folder";
|
||||
public const string SharedFolderItem = "sharedFolder";
|
||||
public const string UserItem = "user";
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
@ -24,6 +24,7 @@
|
||||
// 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
|
||||
|
||||
using Constants = ASC.Feed.Constants;
|
||||
using FeedModule = ASC.Feed.Aggregator.Modules.FeedModule;
|
||||
|
||||
namespace ASC.Files.Service.Core;
|
||||
|
@ -24,6 +24,7 @@
|
||||
// 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
|
||||
|
||||
using Constants = ASC.Feed.Constants;
|
||||
using FeedModule = ASC.Feed.Aggregator.Modules.FeedModule;
|
||||
|
||||
namespace ASC.Files.Service.Core;
|
||||
|
@ -24,6 +24,7 @@
|
||||
// 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
|
||||
|
||||
using Constants = ASC.Feed.Constants;
|
||||
using FeedModule = ASC.Feed.Aggregator.Modules.FeedModule;
|
||||
|
||||
namespace ASC.Files.Service.Core;
|
||||
|
116
products/ASC.Files/Service/Core/UsersModule.cs
Normal file
116
products/ASC.Files/Service/Core/UsersModule.cs
Normal file
@ -0,0 +1,116 @@
|
||||
// (c) Copyright Ascensio System SIA 2010-2022
|
||||
//
|
||||
// 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
|
||||
|
||||
using Constants = ASC.Feed.Constants;
|
||||
using FeedModule = ASC.Feed.Aggregator.Modules.FeedModule;
|
||||
|
||||
namespace ASC.Files.Service.Core;
|
||||
|
||||
public class UsersModule : FeedModule
|
||||
{
|
||||
private readonly UserManager _userManager;
|
||||
private readonly DisplayUserSettingsHelper _displayUserSettingsHelper;
|
||||
|
||||
private const string UserItem = Constants.UserItem;
|
||||
|
||||
public UsersModule(
|
||||
TenantManager tenantManager,
|
||||
WebItemSecurity webItemSecurity,
|
||||
UserManager userManager,
|
||||
DisplayUserSettingsHelper displayUserSettingsHelper)
|
||||
: base(tenantManager, webItemSecurity)
|
||||
{
|
||||
_userManager = userManager;
|
||||
_displayUserSettingsHelper = displayUserSettingsHelper;
|
||||
}
|
||||
|
||||
public override string Name => Constants.UsersModule;
|
||||
public override string Product => Constants.People;
|
||||
public override Guid ProductID => WebItemManager.PeopleProductID;
|
||||
protected override string DbId => string.Empty;
|
||||
|
||||
public override Task<IEnumerable<Tuple<Feed.Aggregator.Feed, object>>> GetFeeds(FeedFilter filter)
|
||||
{
|
||||
var users = _userManager.GetUsers().Where(u => u.LastModified >= filter.Time.From && u.LastModified <= filter.Time.To);
|
||||
|
||||
return Task.FromResult(users.Select(u => new Tuple<Feed.Aggregator.Feed, object>(ToFeed(u), u)));
|
||||
}
|
||||
|
||||
public override Task<IEnumerable<int>> GetTenantsWithFeeds(DateTime fromTime)
|
||||
{
|
||||
return Task.FromResult(_userManager.GetTenantsWithFeeds(fromTime));
|
||||
}
|
||||
|
||||
private Feed.Aggregator.Feed ToFeed(UserInfo u)
|
||||
{
|
||||
var fullName = _displayUserSettingsHelper.GetFullUserName(u);
|
||||
|
||||
var feed = new Feed.Aggregator.Feed(u.Id, u.LastModified, true)
|
||||
{
|
||||
Item = UserItem,
|
||||
ItemId = u.Id.ToString(),
|
||||
Product = Product,
|
||||
Module = Name,
|
||||
Title = fullName,
|
||||
ExtraLocation = u.Id.ToString(),
|
||||
AdditionalInfo = u.Email,
|
||||
AdditionalInfo2 = _userManager.GetUserType(u.Id).ToString(),
|
||||
AdditionalInfo3 = u.Status.ToString(),
|
||||
AdditionalInfo4 = u.ActivationStatus.ToString(),
|
||||
Keywords = fullName,
|
||||
Action = u.LastModified > u.CreateDate ? FeedAction.Updated : FeedAction.Created,
|
||||
};
|
||||
|
||||
return feed;
|
||||
}
|
||||
|
||||
public override bool VisibleFor(Feed.Aggregator.Feed feed, object data, Guid userId)
|
||||
{
|
||||
var user = data as UserInfo;
|
||||
|
||||
return user.Id != userId && !_userManager.IsUser(userId);
|
||||
}
|
||||
|
||||
public override Task VisibleFor(List<Tuple<FeedRow, object>> feed, Guid userId)
|
||||
{
|
||||
if (_userManager.IsUser(userId))
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
foreach (var row in feed)
|
||||
{
|
||||
var user = row.Item2 as UserInfo;
|
||||
|
||||
if (user.Id != userId)
|
||||
{
|
||||
row.Item1.Users.Add(userId);
|
||||
}
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
@ -42,6 +42,7 @@ global using ASC.Core.Common.EF;
|
||||
global using ASC.Core.Common.Hosting;
|
||||
global using ASC.Core.Common.Hosting.Interfaces;
|
||||
global using ASC.Core.Notify.Socket;
|
||||
global using ASC.Core.Users;
|
||||
global using ASC.Core.Tenants;
|
||||
global using ASC.ElasticSearch;
|
||||
global using ASC.ElasticSearch.Service;
|
||||
@ -65,6 +66,7 @@ global using ASC.Files.Service.Log;
|
||||
global using ASC.Files.ThumbnailBuilder;
|
||||
global using ASC.Thumbnail.IntegrationEvents.EventHandling;
|
||||
global using ASC.Web.Core;
|
||||
global using ASC.Web.Core.Users;
|
||||
global using ASC.Web.Files.Classes;
|
||||
global using ASC.Web.Files.Core.Search;
|
||||
global using ASC.Web.Files.Services.DocumentService;
|
||||
|
@ -26,6 +26,15 @@
|
||||
}
|
||||
],
|
||||
"instanceScope": "perlifetimescope"
|
||||
},
|
||||
{
|
||||
"type": "ASC.Files.Service.Core.UsersModule, ASC.Files.Service",
|
||||
"services": [
|
||||
{
|
||||
"type": "ASC.Feed.Aggregator.Modules.IFeedModule, ASC.Feed.Aggregator"
|
||||
}
|
||||
],
|
||||
"instanceScope": "perlifetimescope"
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user