diff --git a/common/ASC.Feed/Core/Feed.cs b/common/ASC.Feed/Core/Feed.cs index 0b1da43194..e66cfe2e8f 100644 --- a/common/ASC.Feed/Core/Feed.cs +++ b/common/ASC.Feed/Core/Feed.cs @@ -55,6 +55,7 @@ public class Feed public string Keywords { get; set; } public string Id => $"{Item}_{ItemId}"; public string ContextId { get; set; } + public bool IsAllDayEvent { get; set; } // это значит, что новость может обновляться (пр. добавление комментариев); // следовательно и права доступа могут устаревать diff --git a/common/ASC.Feed/Data/FeedAggregateDataProvider.cs b/common/ASC.Feed/Data/FeedAggregateDataProvider.cs index 3d030e022d..20b4c970c8 100644 --- a/common/ASC.Feed/Data/FeedAggregateDataProvider.cs +++ b/common/ASC.Feed/Data/FeedAggregateDataProvider.cs @@ -258,7 +258,7 @@ public class FeedAggregateDataProvider q1 = q1.Where(r => keys.Any(k => r.aggregates.Keywords.StartsWith(k))); } - var news = q1.Select(r => r.aggregates).AsEnumerable(); + var news = q1.Select(r => r.aggregates).Distinct().AsEnumerable(); return _mapper.Map, List>(news); } @@ -364,7 +364,8 @@ public class FeedResultItem : IMapFrom public string Json { get; set; } public string Module { get; set; } public Guid AuthorId { get; set; } - public Guid ModifiedById { get; set; } + public Guid ModifiedBy { get; set; } + public object TargetId { get; set; } public string GroupId { get; set; } public bool IsToday { get; set; } public bool IsYesterday { get; set; } diff --git a/common/ASC.Feed/Mapping/FeedTypeConverter.cs b/common/ASC.Feed/Mapping/FeedTypeConverter.cs index b74f9fb95f..ac683d9880 100644 --- a/common/ASC.Feed/Mapping/FeedTypeConverter.cs +++ b/common/ASC.Feed/Mapping/FeedTypeConverter.cs @@ -44,9 +44,11 @@ public class FeedMappingAction : IMappingAction destination.ModifiedDate = _tenantUtil.DateTimeFromUtc(source.ModifiedDate); destination.AggregatedDate = _tenantUtil.DateTimeFromUtc(source.AggregateDate); - var node = JsonNode.Parse(destination.Json)["IsAllDayEvent"]; + var feed = System.Text.Json.JsonSerializer.Deserialize(source.Json); - var compareDate = node != null && node.GetValue() + destination.TargetId = feed.Target; + + var compareDate = feed.IsAllDayEvent ? _tenantUtil.DateTimeToUtc(source.CreatedDate).Date : destination.CreatedDate.Date; diff --git a/products/ASC.Files/Core/Core/Security/FileShareRecord.cs b/products/ASC.Files/Core/Core/Security/FileShareRecord.cs index 78fefdb5b7..9362e26e1d 100644 --- a/products/ASC.Files/Core/Core/Security/FileShareRecord.cs +++ b/products/ASC.Files/Core/Core/Security/FileShareRecord.cs @@ -74,4 +74,5 @@ public class SmallShareRecord public Guid Owner { get; set; } public DateTime TimeStamp { get; set; } public FileShare Share { get; set; } + public SubjectType SubjectType { get; set; } } diff --git a/products/ASC.Files/Service/Core/FilesModule.cs b/products/ASC.Files/Service/Core/FilesModule.cs index f3894fdc60..5f1cc6fa96 100644 --- a/products/ASC.Files/Service/Core/FilesModule.cs +++ b/products/ASC.Files/Service/Core/FilesModule.cs @@ -137,6 +137,7 @@ public class FilesModule : FeedModule { var files = _fileDao.GetFeedsAsync(filter.Tenant, filter.Time.From, filter.Time.To) .Where(f => f.File.RootFolderType != FolderType.TRASH && f.File.RootFolderType != FolderType.BUNCH) + .Where(f => f.ShareRecord == null) .ToListAsync().Result; var folderIDs = files.Select(r => r.File.ParentId).ToList(); @@ -152,7 +153,7 @@ public class FilesModule : FeedModule return _fileDao.GetTenantsWithFeedsAsync(fromTime).ToListAsync().Result; } - private Feed.Aggregator.Feed ToFeed(FileWithShare tuple, Folder rootFolder, int roomId) + private Feed.Aggregator.Feed ToFeed(FileWithShare tuple, Folder parentFolder, int roomId) { var file = tuple.File; var shareRecord = tuple.ShareRecord; @@ -168,12 +169,11 @@ public class FilesModule : FeedModule Product = Product, Module = Name, Title = file.Title, - ExtraLocation = rootFolder.FolderType == FolderType.DEFAULT ? rootFolder.Title : string.Empty, - ExtraLocationUrl = rootFolder.FolderType == FolderType.DEFAULT ? _filesLinkUtility.GetFileRedirectPreviewUrl(file.ParentId, false) : string.Empty, + ExtraLocation = parentFolder.Title, + ExtraLocationUrl = _filesLinkUtility.GetFileRedirectPreviewUrl(file.ParentId, false), AdditionalInfo = file.ContentLengthString, + AdditionalInfo2 = file.Encrypted ? "Encrypted" : string.Empty, Keywords = file.Title, - HasPreview = false, - CanComment = false, Target = shareRecord.Subject, GroupId = GetGroupId(SharedFileItem, shareRecord.Owner, file.ParentId.ToString()), ContextId = contextId @@ -193,13 +193,11 @@ public class FilesModule : FeedModule Module = Name, Action = updated ? FeedAction.Updated : FeedAction.Created, Title = file.Title, - ExtraLocation = rootFolder.FolderType == FolderType.DEFAULT ? rootFolder.Title : string.Empty, - ExtraLocationUrl = rootFolder.FolderType == FolderType.DEFAULT ? _filesLinkUtility.GetFileRedirectPreviewUrl(file.ParentId, false) : string.Empty, + ExtraLocation = parentFolder.Title, + ExtraLocationUrl = _filesLinkUtility.GetFileRedirectPreviewUrl(file.ParentId, false), AdditionalInfo = file.ContentLengthString, + AdditionalInfo2 = file.Encrypted ? "Encrypted" : string.Empty, Keywords = file.Title, - HasPreview = false, - CanComment = false, - Target = null, GroupId = GetGroupId(FileItem, file.ModifiedBy, file.ParentId.ToString(), updated ? 1 : 0), ContextId = contextId }; diff --git a/products/ASC.Files/Service/Core/FoldersModule.cs b/products/ASC.Files/Service/Core/FoldersModule.cs index 82a81fc6b7..ea4f8fecd3 100644 --- a/products/ASC.Files/Service/Core/FoldersModule.cs +++ b/products/ASC.Files/Service/Core/FoldersModule.cs @@ -113,7 +113,7 @@ public class FoldersModule : FeedModule roomsIds.GetValueOrDefault(f.Folder.ParentId)), f)); } - private Feed.Aggregator.Feed ToFeed(FolderWithShare folderWithSecurity, Folder rootFolder, int roomId) + private Feed.Aggregator.Feed ToFeed(FolderWithShare folderWithSecurity, Folder parentFolder, int roomId) { var folder = folderWithSecurity.Folder; var shareRecord = folderWithSecurity.ShareRecord; @@ -129,11 +129,9 @@ public class FoldersModule : FeedModule Product = Product, Module = Name, Title = folder.Title, - ExtraLocation = rootFolder.FolderType == FolderType.DEFAULT ? rootFolder.Title : string.Empty, - ExtraLocationUrl = rootFolder.FolderType == FolderType.DEFAULT ? _filesLinkUtility.GetFileRedirectPreviewUrl(folder.ParentId, false) : string.Empty, + ExtraLocation = parentFolder.Title, + ExtraLocationUrl = _filesLinkUtility.GetFileRedirectPreviewUrl(folder.ParentId, false), Keywords = folder.Title, - HasPreview = false, - CanComment = false, Target = shareRecord.Subject, GroupId = GetGroupId(SharedFolderItem, shareRecord.Owner, folder.ParentId.ToString()), ContextId = contextId @@ -150,12 +148,9 @@ public class FoldersModule : FeedModule Product = Product, Module = Name, Title = folder.Title, - ExtraLocation = rootFolder.FolderType == FolderType.DEFAULT ? rootFolder.Title : string.Empty, - ExtraLocationUrl = rootFolder.FolderType == FolderType.DEFAULT ? _filesLinkUtility.GetFileRedirectPreviewUrl(folder.ParentId, false) : string.Empty, + ExtraLocation = parentFolder.Title, + ExtraLocationUrl = _filesLinkUtility.GetFileRedirectPreviewUrl(folder.ParentId, false), Keywords = folder.Title, - HasPreview = false, - CanComment = false, - Target = null, GroupId = GetGroupId(FolderItem, folder.CreateBy, folder.ParentId.ToString()), ContextId = contextId }; diff --git a/products/ASC.Files/Service/Core/RoomsModule.cs b/products/ASC.Files/Service/Core/RoomsModule.cs index b7b58a841d..b2fe0ce89b 100644 --- a/products/ASC.Files/Service/Core/RoomsModule.cs +++ b/products/ASC.Files/Service/Core/RoomsModule.cs @@ -113,10 +113,10 @@ public class RoomsModule : FeedModule if (shareRecord != null) { - var feed = new Feed.Aggregator.Feed(shareRecord.Owner, shareRecord.TimeStamp, true) + var feed = new Feed.Aggregator.Feed(shareRecord.Owner, shareRecord.TimeStamp) { Item = SharedRoomItem, - ItemId = string.Format("{0}_{1}", folder.Id, shareRecord.Subject), + ItemId = string.Format("{0}_{1}_{2}", folder.Id, shareRecord.Subject, shareRecord.TimeStamp.Ticks), ItemUrl = _filesLinkUtility.GetFileRedirectPreviewUrl(folder.Id, false), Product = Product, Module = Name, @@ -124,8 +124,10 @@ public class RoomsModule : FeedModule ExtraLocation = FilesUCResource.VirtualRooms, ExtraLocationUrl = _filesLinkUtility.GetFileRedirectPreviewUrl(folder.RootId, false), Keywords = folder.Title, - AdditionalInfo = Enum.GetName(folder.FolderType), - AdditionalInfo2 = folder.Private ? "private" : null, + AdditionalInfo = ((int)folder.FolderType).ToString(), + AdditionalInfo2 = ((int)shareRecord.Share).ToString(), + AdditionalInfo3 = ((int)shareRecord.SubjectType).ToString(), + AdditionalInfo4 = folder.Private ? "private" : null, HasPreview = false, CanComment = false, Target = shareRecord.Subject, @@ -146,8 +148,8 @@ public class RoomsModule : FeedModule ExtraLocation = FilesUCResource.VirtualRooms, ExtraLocationUrl = _filesLinkUtility.GetFileRedirectPreviewUrl(folder.RootId, false), Keywords = folder.Title, - AdditionalInfo = Enum.GetName(folder.FolderType), - AdditionalInfo2 = folder.Private ? "private" : null, + AdditionalInfo = ((int)folder.FolderType).ToString(), + AdditionalInfo4 = folder.Private ? "private" : null, HasPreview = false, CanComment = false, Target = null, diff --git a/web/ASC.Web.Api/ApiModels/ResponseDto/FeedDto.cs b/web/ASC.Web.Api/ApiModels/ResponseDto/FeedDto.cs index 154bc0c437..5801e2dc77 100644 --- a/web/ASC.Web.Api/ApiModels/ResponseDto/FeedDto.cs +++ b/web/ASC.Web.Api/ApiModels/ResponseDto/FeedDto.cs @@ -32,6 +32,8 @@ public class FeedDto : IMapFrom public ApiDateTime CreatedDate { get; set; } public ApiDateTime ModifiedDate { get; set; } public ApiDateTime TimeReaded { get; set; } + public EmployeeDto Initiator { get; set; } + public EmployeeDto Target { get; set; } public bool IsToday { get; set; } public bool IsTomorrow { get; set; } public bool IsYesterday { get; set; } @@ -45,6 +47,7 @@ public class FeedDto : IMapFrom profile.CreateMap() .ConvertUsing(); - profile.CreateMap(); + profile.CreateMap() + .AfterMap(); } } \ No newline at end of file diff --git a/web/ASC.Web.Api/Mapping/FeedMapperAction.cs b/web/ASC.Web.Api/Mapping/FeedMapperAction.cs index eef3adfd71..b82cc932bc 100644 --- a/web/ASC.Web.Api/Mapping/FeedMapperAction.cs +++ b/web/ASC.Web.Api/Mapping/FeedMapperAction.cs @@ -40,4 +40,21 @@ public class DateTimeMappingConverter : ITypeConverter { return _apiDateTimeHelper.Get(source); } +} + +[Scope] +public class FeedDtoMappingAction : IMappingAction +{ + private readonly EmployeeDtoHelper _employeeDtoHelper; + + public FeedDtoMappingAction(EmployeeDtoHelper employeeDtoHelper) + { + _employeeDtoHelper = employeeDtoHelper; + } + + public void Process(FeedResultItem source, FeedDto destination, ResolutionContext context) + { + destination.Initiator = _employeeDtoHelper.Get(source.ModifiedBy).Result; + destination.Target = source.TargetId is JsonElement doc && doc.TryGetGuid(out var id) ? _employeeDtoHelper.Get(id).Result : null; + } } \ No newline at end of file