From 2d9ca08366d91c22877cee143f43a062d4efda2d Mon Sep 17 00:00:00 2001 From: crupest Date: Sat, 13 Feb 2021 15:57:29 +0800 Subject: feat: Timeline add postable. --- BackEnd/Timeline/Models/Mapper/TimelineMapper.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'BackEnd/Timeline/Models/Mapper') diff --git a/BackEnd/Timeline/Models/Mapper/TimelineMapper.cs b/BackEnd/Timeline/Models/Mapper/TimelineMapper.cs index 8dfd7b8d..e4304311 100644 --- a/BackEnd/Timeline/Models/Mapper/TimelineMapper.cs +++ b/BackEnd/Timeline/Models/Mapper/TimelineMapper.cs @@ -51,6 +51,16 @@ namespace Timeline.Models.Mapper manageable = await _timelineService.HasManagePermission(entity.Id, userId.Value); } + bool postable; + if (userId is null) + { + postable = false; + } + else + { + postable = await _timelineService.IsMemberOf(entity.Id, userId.Value); + } + return new HttpTimeline( uniqueId: entity.UniqueId, title: string.IsNullOrEmpty(entity.Title) ? timelineName : entity.Title, @@ -66,6 +76,7 @@ namespace Timeline.Models.Mapper isHighlight: await _highlightTimelineService.IsHighlightTimeline(entity.Id), isBookmark: userId is not null && await _bookmarkTimelineService.IsBookmark(userId.Value, entity.Id, false, false), manageable: manageable, + postable: postable, links: new HttpTimelineLinks( self: urlHelper.ActionLink(nameof(TimelineController.TimelineGet), nameof(TimelineController)[0..^nameof(Controller).Length], new { timeline = timelineName }), posts: urlHelper.ActionLink(nameof(TimelinePostController.List), nameof(TimelinePostController)[0..^nameof(Controller).Length], new { timeline = timelineName }) -- cgit v1.2.3