aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline/Controllers
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-04-09 18:53:52 +0800
committercrupest <crupest@outlook.com>2022-04-09 18:53:52 +0800
commit0aa43ef4c6724f672453676a0c688cd80097dad7 (patch)
tree5bbb0d736b385b9d0c6254f7e006161e0080de8f /BackEnd/Timeline/Controllers
parent4db131899145b7aca0ea5fd36984cf1542c9619b (diff)
downloadtimeline-0aa43ef4c6724f672453676a0c688cd80097dad7.tar.gz
timeline-0aa43ef4c6724f672453676a0c688cd80097dad7.tar.bz2
timeline-0aa43ef4c6724f672453676a0c688cd80097dad7.zip
...
Diffstat (limited to 'BackEnd/Timeline/Controllers')
-rw-r--r--BackEnd/Timeline/Controllers/TimelinePostV2Controller.cs11
1 files changed, 6 insertions, 5 deletions
diff --git a/BackEnd/Timeline/Controllers/TimelinePostV2Controller.cs b/BackEnd/Timeline/Controllers/TimelinePostV2Controller.cs
index af1b3182..3a694e31 100644
--- a/BackEnd/Timeline/Controllers/TimelinePostV2Controller.cs
+++ b/BackEnd/Timeline/Controllers/TimelinePostV2Controller.cs
@@ -44,22 +44,23 @@ namespace Timeline.Controllers
[ProducesResponseType(StatusCodes.Status403Forbidden)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status422UnprocessableEntity)]
- public async Task<ActionResult<List<HttpTimelinePost>>> ListAsync([FromRoute][Username] string owner, [FromRoute][TimelineName] string timeline, [FromQuery] DateTime? modifiedSince, [FromQuery] bool? includeDeleted, [FromQuery][Range(0, int.MaxValue)] int? page, [FromQuery][Range(1, int.MaxValue)] int? numberPerPage)
+ public async Task<ActionResult<Page<HttpTimelinePost>>> ListAsync([FromRoute][Username] string owner, [FromRoute][TimelineName] string timeline, [FromQuery] DateTime? modifiedSince, [FromQuery][Range(0, int.MaxValue)] int? page, [FromQuery][Range(1, int.MaxValue)] int? numberPerPage)
{
var timelineId = await _timelineService.GetTimelineIdAsync(owner, timeline);
if (!UserHasPermission(UserPermission.AllTimelineManagement) && !await _timelineService.HasReadPermissionAsync(timelineId, GetOptionalAuthUserId()))
{
return Forbid();
}
- var posts = await _postService.GetPostsAsync(timelineId, modifiedSince, includeDeleted ?? false, page, numberPerPage);
- var result = await _mapper.MapListAsync<HttpTimelinePost>(posts, Url, User);
- return result;
+ var postPage = await _postService.GetPostsV2Async(timelineId, modifiedSince, page, numberPerPage);
+ var items = await _mapper.MapListAsync<HttpTimelinePost>(postPage.Items, Url, User);
+ return postPage.WithItems(items);
}
[HttpGet("{post}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status403Forbidden)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
+ [ProducesResponseType(StatusCodes.Status410Gone)]
[ProducesResponseType(StatusCodes.Status422UnprocessableEntity)]
public async Task<ActionResult<HttpTimelinePost>> GetAsync([FromRoute][Username] string owner, [FromRoute][TimelineName] string timeline, [FromRoute(Name = "post")] long postId)
{
@@ -68,7 +69,7 @@ namespace Timeline.Controllers
{
return Forbid();
}
- var post = await _postService.GetPostAsync(timelineId, postId);
+ var post = await _postService.GetPostV2Async(timelineId, postId);
var result = await _mapper.MapAsync<HttpTimelinePost>(post, Url, User);
return result;
}