diff options
author | crupest <crupest@outlook.com> | 2021-02-13 15:09:21 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-02-13 15:09:21 +0800 |
commit | 01c3c5800f9b8a7b89d98b28ea748d496497c0b2 (patch) | |
tree | b41f4a4eb95e0f1608be951d874f6911460e71e4 /BackEnd/Timeline/Controllers/TimelinePostController.cs | |
parent | c3d0a5f88de0fbdf6bc584548832017087ab1248 (diff) | |
download | timeline-01c3c5800f9b8a7b89d98b28ea748d496497c0b2.tar.gz timeline-01c3c5800f9b8a7b89d98b28ea748d496497c0b2.tar.bz2 timeline-01c3c5800f9b8a7b89d98b28ea748d496497c0b2.zip |
feat: Post info add editable field.
Diffstat (limited to 'BackEnd/Timeline/Controllers/TimelinePostController.cs')
-rw-r--r-- | BackEnd/Timeline/Controllers/TimelinePostController.cs | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/BackEnd/Timeline/Controllers/TimelinePostController.cs b/BackEnd/Timeline/Controllers/TimelinePostController.cs index 6904e28d..7e3d6900 100644 --- a/BackEnd/Timeline/Controllers/TimelinePostController.cs +++ b/BackEnd/Timeline/Controllers/TimelinePostController.cs @@ -12,6 +12,7 @@ using Timeline.Models.Http; using Timeline.Models.Mapper;
using Timeline.Models.Validation;
using Timeline.Services;
+using Timeline.Entities;
namespace Timeline.Controllers
{
@@ -43,6 +44,16 @@ namespace Timeline.Controllers private bool UserHasAllTimelineManagementPermission => this.UserHasPermission(UserPermission.AllTimelineManagement);
+ private Task<HttpTimelinePost> Map(TimelinePostEntity post, string timelineName)
+ {
+ return _timelineMapper.MapToHttp(post, timelineName, Url, this.GetOptionalUserId(), UserHasAllTimelineManagementPermission);
+ }
+
+ private Task<List<HttpTimelinePost>> Map(List<TimelinePostEntity> post, string timelineName)
+ {
+ return _timelineMapper.MapToHttp(post, timelineName, Url, this.GetOptionalUserId(), UserHasAllTimelineManagementPermission);
+ }
+
/// <summary>
/// Get posts of a timeline.
/// </summary>
@@ -65,7 +76,7 @@ namespace Timeline.Controllers var posts = await _postService.GetPosts(timelineId, modifiedSince, includeDeleted ?? false);
- var result = await _timelineMapper.MapToHttp(posts, timeline, Url);
+ var result = await Map(posts, timeline);
return result;
}
@@ -89,7 +100,7 @@ namespace Timeline.Controllers }
var post = await _postService.GetPost(timelineId, postId);
- var result = await _timelineMapper.MapToHttp(post, timeline, Url);
+ var result = await Map(post, timeline);
return result;
}
@@ -190,7 +201,7 @@ namespace Timeline.Controllers try
{
var post = await _postService.CreatePost(timelineId, userId, createRequest);
- var result = await _timelineMapper.MapToHttp(post, timeline, Url);
+ var result = await Map(post, timeline);
return result;
}
catch (TimelinePostCreateDataException e)
@@ -222,7 +233,7 @@ namespace Timeline.Controllers }
var entity = await _postService.PatchPost(timelineId, post, new TimelinePostPatchRequest { Time = body.Time, Color = body.Color });
- var result = await _timelineMapper.MapToHttp(entity, timeline, Url);
+ var result = await Map(entity, timeline);
return Ok(result);
}
|