aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline/Controllers/TimelinePostController.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-02-13 16:01:20 +0800
committerGitHub <noreply@github.com>2021-02-13 16:01:20 +0800
commit42034bfb60c03b30dec6ddc93d35ced29070b0e7 (patch)
treefe1aaea4f34c227b2bcf5fdad77c7e2a85b7923b /BackEnd/Timeline/Controllers/TimelinePostController.cs
parent99d525560f6aefa5f5fb63e3ba2fff3b557d61f6 (diff)
parent2d9ca08366d91c22877cee143f43a062d4efda2d (diff)
downloadtimeline-42034bfb60c03b30dec6ddc93d35ced29070b0e7.tar.gz
timeline-42034bfb60c03b30dec6ddc93d35ced29070b0e7.tar.bz2
timeline-42034bfb60c03b30dec6ddc93d35ced29070b0e7.zip
Merge pull request #273 from crupest/backend
User permission related field in http.
Diffstat (limited to 'BackEnd/Timeline/Controllers/TimelinePostController.cs')
-rw-r--r--BackEnd/Timeline/Controllers/TimelinePostController.cs19
1 files changed, 15 insertions, 4 deletions
diff --git a/BackEnd/Timeline/Controllers/TimelinePostController.cs b/BackEnd/Timeline/Controllers/TimelinePostController.cs
index 6904e28d..4026d551 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> posts, string timelineName)
+ {
+ return _timelineMapper.MapToHttp(posts, 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);
}