Files: added additional parameters to feed
This commit is contained in:
parent
727175f571
commit
d7e17828e0
@ -55,6 +55,7 @@ public class Feed
|
|||||||
public string Keywords { get; set; }
|
public string Keywords { get; set; }
|
||||||
public string Id => $"{Item}_{ItemId}";
|
public string Id => $"{Item}_{ItemId}";
|
||||||
public string ContextId { get; set; }
|
public string ContextId { get; set; }
|
||||||
|
public bool IsAllDayEvent { get; set; }
|
||||||
|
|
||||||
// это значит, что новость может обновляться (пр. добавление комментариев);
|
// это значит, что новость может обновляться (пр. добавление комментариев);
|
||||||
// следовательно и права доступа могут устаревать
|
// следовательно и права доступа могут устаревать
|
||||||
|
@ -258,7 +258,7 @@ public class FeedAggregateDataProvider
|
|||||||
q1 = q1.Where(r => keys.Any(k => r.aggregates.Keywords.StartsWith(k)));
|
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<IEnumerable<FeedAggregate>, List<FeedResultItem>>(news);
|
return _mapper.Map<IEnumerable<FeedAggregate>, List<FeedResultItem>>(news);
|
||||||
}
|
}
|
||||||
@ -364,7 +364,8 @@ public class FeedResultItem : IMapFrom<FeedAggregate>
|
|||||||
public string Json { get; set; }
|
public string Json { get; set; }
|
||||||
public string Module { get; set; }
|
public string Module { get; set; }
|
||||||
public Guid AuthorId { 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 string GroupId { get; set; }
|
||||||
public bool IsToday { get; set; }
|
public bool IsToday { get; set; }
|
||||||
public bool IsYesterday { get; set; }
|
public bool IsYesterday { get; set; }
|
||||||
|
@ -44,9 +44,11 @@ public class FeedMappingAction : IMappingAction<FeedAggregate, FeedResultItem>
|
|||||||
destination.ModifiedDate = _tenantUtil.DateTimeFromUtc(source.ModifiedDate);
|
destination.ModifiedDate = _tenantUtil.DateTimeFromUtc(source.ModifiedDate);
|
||||||
destination.AggregatedDate = _tenantUtil.DateTimeFromUtc(source.AggregateDate);
|
destination.AggregatedDate = _tenantUtil.DateTimeFromUtc(source.AggregateDate);
|
||||||
|
|
||||||
var node = JsonNode.Parse(destination.Json)["IsAllDayEvent"];
|
var feed = System.Text.Json.JsonSerializer.Deserialize<Aggregator.Feed>(source.Json);
|
||||||
|
|
||||||
var compareDate = node != null && node.GetValue<bool>()
|
destination.TargetId = feed.Target;
|
||||||
|
|
||||||
|
var compareDate = feed.IsAllDayEvent
|
||||||
? _tenantUtil.DateTimeToUtc(source.CreatedDate).Date
|
? _tenantUtil.DateTimeToUtc(source.CreatedDate).Date
|
||||||
: destination.CreatedDate.Date;
|
: destination.CreatedDate.Date;
|
||||||
|
|
||||||
|
@ -74,4 +74,5 @@ public class SmallShareRecord
|
|||||||
public Guid Owner { get; set; }
|
public Guid Owner { get; set; }
|
||||||
public DateTime TimeStamp { get; set; }
|
public DateTime TimeStamp { get; set; }
|
||||||
public FileShare Share { get; set; }
|
public FileShare Share { get; set; }
|
||||||
|
public SubjectType SubjectType { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -137,6 +137,7 @@ public class FilesModule : FeedModule
|
|||||||
{
|
{
|
||||||
var files = _fileDao.GetFeedsAsync(filter.Tenant, filter.Time.From, filter.Time.To)
|
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.File.RootFolderType != FolderType.TRASH && f.File.RootFolderType != FolderType.BUNCH)
|
||||||
|
.Where(f => f.ShareRecord == null)
|
||||||
.ToListAsync().Result;
|
.ToListAsync().Result;
|
||||||
|
|
||||||
var folderIDs = files.Select(r => r.File.ParentId).ToList();
|
var folderIDs = files.Select(r => r.File.ParentId).ToList();
|
||||||
@ -152,7 +153,7 @@ public class FilesModule : FeedModule
|
|||||||
return _fileDao.GetTenantsWithFeedsAsync(fromTime).ToListAsync().Result;
|
return _fileDao.GetTenantsWithFeedsAsync(fromTime).ToListAsync().Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Feed.Aggregator.Feed ToFeed(FileWithShare tuple, Folder<int> rootFolder, int roomId)
|
private Feed.Aggregator.Feed ToFeed(FileWithShare tuple, Folder<int> parentFolder, int roomId)
|
||||||
{
|
{
|
||||||
var file = tuple.File;
|
var file = tuple.File;
|
||||||
var shareRecord = tuple.ShareRecord;
|
var shareRecord = tuple.ShareRecord;
|
||||||
@ -168,12 +169,11 @@ public class FilesModule : FeedModule
|
|||||||
Product = Product,
|
Product = Product,
|
||||||
Module = Name,
|
Module = Name,
|
||||||
Title = file.Title,
|
Title = file.Title,
|
||||||
ExtraLocation = rootFolder.FolderType == FolderType.DEFAULT ? rootFolder.Title : string.Empty,
|
ExtraLocation = parentFolder.Title,
|
||||||
ExtraLocationUrl = rootFolder.FolderType == FolderType.DEFAULT ? _filesLinkUtility.GetFileRedirectPreviewUrl(file.ParentId, false) : string.Empty,
|
ExtraLocationUrl = _filesLinkUtility.GetFileRedirectPreviewUrl(file.ParentId, false),
|
||||||
AdditionalInfo = file.ContentLengthString,
|
AdditionalInfo = file.ContentLengthString,
|
||||||
|
AdditionalInfo2 = file.Encrypted ? "Encrypted" : string.Empty,
|
||||||
Keywords = file.Title,
|
Keywords = file.Title,
|
||||||
HasPreview = false,
|
|
||||||
CanComment = false,
|
|
||||||
Target = shareRecord.Subject,
|
Target = shareRecord.Subject,
|
||||||
GroupId = GetGroupId(SharedFileItem, shareRecord.Owner, file.ParentId.ToString()),
|
GroupId = GetGroupId(SharedFileItem, shareRecord.Owner, file.ParentId.ToString()),
|
||||||
ContextId = contextId
|
ContextId = contextId
|
||||||
@ -193,13 +193,11 @@ public class FilesModule : FeedModule
|
|||||||
Module = Name,
|
Module = Name,
|
||||||
Action = updated ? FeedAction.Updated : FeedAction.Created,
|
Action = updated ? FeedAction.Updated : FeedAction.Created,
|
||||||
Title = file.Title,
|
Title = file.Title,
|
||||||
ExtraLocation = rootFolder.FolderType == FolderType.DEFAULT ? rootFolder.Title : string.Empty,
|
ExtraLocation = parentFolder.Title,
|
||||||
ExtraLocationUrl = rootFolder.FolderType == FolderType.DEFAULT ? _filesLinkUtility.GetFileRedirectPreviewUrl(file.ParentId, false) : string.Empty,
|
ExtraLocationUrl = _filesLinkUtility.GetFileRedirectPreviewUrl(file.ParentId, false),
|
||||||
AdditionalInfo = file.ContentLengthString,
|
AdditionalInfo = file.ContentLengthString,
|
||||||
|
AdditionalInfo2 = file.Encrypted ? "Encrypted" : string.Empty,
|
||||||
Keywords = file.Title,
|
Keywords = file.Title,
|
||||||
HasPreview = false,
|
|
||||||
CanComment = false,
|
|
||||||
Target = null,
|
|
||||||
GroupId = GetGroupId(FileItem, file.ModifiedBy, file.ParentId.ToString(), updated ? 1 : 0),
|
GroupId = GetGroupId(FileItem, file.ModifiedBy, file.ParentId.ToString(), updated ? 1 : 0),
|
||||||
ContextId = contextId
|
ContextId = contextId
|
||||||
};
|
};
|
||||||
|
@ -113,7 +113,7 @@ public class FoldersModule : FeedModule
|
|||||||
roomsIds.GetValueOrDefault(f.Folder.ParentId)), f));
|
roomsIds.GetValueOrDefault(f.Folder.ParentId)), f));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Feed.Aggregator.Feed ToFeed(FolderWithShare folderWithSecurity, Folder<int> rootFolder, int roomId)
|
private Feed.Aggregator.Feed ToFeed(FolderWithShare folderWithSecurity, Folder<int> parentFolder, int roomId)
|
||||||
{
|
{
|
||||||
var folder = folderWithSecurity.Folder;
|
var folder = folderWithSecurity.Folder;
|
||||||
var shareRecord = folderWithSecurity.ShareRecord;
|
var shareRecord = folderWithSecurity.ShareRecord;
|
||||||
@ -129,11 +129,9 @@ public class FoldersModule : FeedModule
|
|||||||
Product = Product,
|
Product = Product,
|
||||||
Module = Name,
|
Module = Name,
|
||||||
Title = folder.Title,
|
Title = folder.Title,
|
||||||
ExtraLocation = rootFolder.FolderType == FolderType.DEFAULT ? rootFolder.Title : string.Empty,
|
ExtraLocation = parentFolder.Title,
|
||||||
ExtraLocationUrl = rootFolder.FolderType == FolderType.DEFAULT ? _filesLinkUtility.GetFileRedirectPreviewUrl(folder.ParentId, false) : string.Empty,
|
ExtraLocationUrl = _filesLinkUtility.GetFileRedirectPreviewUrl(folder.ParentId, false),
|
||||||
Keywords = folder.Title,
|
Keywords = folder.Title,
|
||||||
HasPreview = false,
|
|
||||||
CanComment = false,
|
|
||||||
Target = shareRecord.Subject,
|
Target = shareRecord.Subject,
|
||||||
GroupId = GetGroupId(SharedFolderItem, shareRecord.Owner, folder.ParentId.ToString()),
|
GroupId = GetGroupId(SharedFolderItem, shareRecord.Owner, folder.ParentId.ToString()),
|
||||||
ContextId = contextId
|
ContextId = contextId
|
||||||
@ -150,12 +148,9 @@ public class FoldersModule : FeedModule
|
|||||||
Product = Product,
|
Product = Product,
|
||||||
Module = Name,
|
Module = Name,
|
||||||
Title = folder.Title,
|
Title = folder.Title,
|
||||||
ExtraLocation = rootFolder.FolderType == FolderType.DEFAULT ? rootFolder.Title : string.Empty,
|
ExtraLocation = parentFolder.Title,
|
||||||
ExtraLocationUrl = rootFolder.FolderType == FolderType.DEFAULT ? _filesLinkUtility.GetFileRedirectPreviewUrl(folder.ParentId, false) : string.Empty,
|
ExtraLocationUrl = _filesLinkUtility.GetFileRedirectPreviewUrl(folder.ParentId, false),
|
||||||
Keywords = folder.Title,
|
Keywords = folder.Title,
|
||||||
HasPreview = false,
|
|
||||||
CanComment = false,
|
|
||||||
Target = null,
|
|
||||||
GroupId = GetGroupId(FolderItem, folder.CreateBy, folder.ParentId.ToString()),
|
GroupId = GetGroupId(FolderItem, folder.CreateBy, folder.ParentId.ToString()),
|
||||||
ContextId = contextId
|
ContextId = contextId
|
||||||
};
|
};
|
||||||
|
@ -113,10 +113,10 @@ public class RoomsModule : FeedModule
|
|||||||
|
|
||||||
if (shareRecord != null)
|
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,
|
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),
|
ItemUrl = _filesLinkUtility.GetFileRedirectPreviewUrl(folder.Id, false),
|
||||||
Product = Product,
|
Product = Product,
|
||||||
Module = Name,
|
Module = Name,
|
||||||
@ -124,8 +124,10 @@ public class RoomsModule : FeedModule
|
|||||||
ExtraLocation = FilesUCResource.VirtualRooms,
|
ExtraLocation = FilesUCResource.VirtualRooms,
|
||||||
ExtraLocationUrl = _filesLinkUtility.GetFileRedirectPreviewUrl(folder.RootId, false),
|
ExtraLocationUrl = _filesLinkUtility.GetFileRedirectPreviewUrl(folder.RootId, false),
|
||||||
Keywords = folder.Title,
|
Keywords = folder.Title,
|
||||||
AdditionalInfo = Enum.GetName(folder.FolderType),
|
AdditionalInfo = ((int)folder.FolderType).ToString(),
|
||||||
AdditionalInfo2 = folder.Private ? "private" : null,
|
AdditionalInfo2 = ((int)shareRecord.Share).ToString(),
|
||||||
|
AdditionalInfo3 = ((int)shareRecord.SubjectType).ToString(),
|
||||||
|
AdditionalInfo4 = folder.Private ? "private" : null,
|
||||||
HasPreview = false,
|
HasPreview = false,
|
||||||
CanComment = false,
|
CanComment = false,
|
||||||
Target = shareRecord.Subject,
|
Target = shareRecord.Subject,
|
||||||
@ -146,8 +148,8 @@ public class RoomsModule : FeedModule
|
|||||||
ExtraLocation = FilesUCResource.VirtualRooms,
|
ExtraLocation = FilesUCResource.VirtualRooms,
|
||||||
ExtraLocationUrl = _filesLinkUtility.GetFileRedirectPreviewUrl(folder.RootId, false),
|
ExtraLocationUrl = _filesLinkUtility.GetFileRedirectPreviewUrl(folder.RootId, false),
|
||||||
Keywords = folder.Title,
|
Keywords = folder.Title,
|
||||||
AdditionalInfo = Enum.GetName(folder.FolderType),
|
AdditionalInfo = ((int)folder.FolderType).ToString(),
|
||||||
AdditionalInfo2 = folder.Private ? "private" : null,
|
AdditionalInfo4 = folder.Private ? "private" : null,
|
||||||
HasPreview = false,
|
HasPreview = false,
|
||||||
CanComment = false,
|
CanComment = false,
|
||||||
Target = null,
|
Target = null,
|
||||||
|
@ -32,6 +32,8 @@ public class FeedDto : IMapFrom<FeedResultItem>
|
|||||||
public ApiDateTime CreatedDate { get; set; }
|
public ApiDateTime CreatedDate { get; set; }
|
||||||
public ApiDateTime ModifiedDate { get; set; }
|
public ApiDateTime ModifiedDate { get; set; }
|
||||||
public ApiDateTime TimeReaded { get; set; }
|
public ApiDateTime TimeReaded { get; set; }
|
||||||
|
public EmployeeDto Initiator { get; set; }
|
||||||
|
public EmployeeDto Target { get; set; }
|
||||||
public bool IsToday { get; set; }
|
public bool IsToday { get; set; }
|
||||||
public bool IsTomorrow { get; set; }
|
public bool IsTomorrow { get; set; }
|
||||||
public bool IsYesterday { get; set; }
|
public bool IsYesterday { get; set; }
|
||||||
@ -45,6 +47,7 @@ public class FeedDto : IMapFrom<FeedResultItem>
|
|||||||
profile.CreateMap<DateTime, ApiDateTime>()
|
profile.CreateMap<DateTime, ApiDateTime>()
|
||||||
.ConvertUsing<DateTimeMappingConverter>();
|
.ConvertUsing<DateTimeMappingConverter>();
|
||||||
|
|
||||||
profile.CreateMap<FeedResultItem, FeedDto>();
|
profile.CreateMap<FeedResultItem, FeedDto>()
|
||||||
|
.AfterMap<FeedDtoMappingAction>();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -41,3 +41,20 @@ public class DateTimeMappingConverter : ITypeConverter<DateTime, ApiDateTime>
|
|||||||
return _apiDateTimeHelper.Get(source);
|
return _apiDateTimeHelper.Get(source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Scope]
|
||||||
|
public class FeedDtoMappingAction : IMappingAction<FeedResultItem, FeedDto>
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user