aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Controllers/PersonalTimelineController.cs
diff options
context:
space:
mode:
author杨宇千 <crupest@outlook.com>2020-02-03 18:38:14 +0800
committerGitHub <noreply@github.com>2020-02-03 18:38:14 +0800
commit97010e98a11ad6fd6c075cee414c30174001fe5d (patch)
tree28ef20f9dfe742008bb934f09b99d1d4719cabaa /Timeline/Controllers/PersonalTimelineController.cs
parent1c880744293c9f47ff1241109b72c035680251df (diff)
parentbe8cbe2c4ddf2076cc02bcb2feb1a70d30a4bda0 (diff)
downloadtimeline-97010e98a11ad6fd6c075cee414c30174001fe5d.tar.gz
timeline-97010e98a11ad6fd6c075cee414c30174001fe5d.tar.bz2
timeline-97010e98a11ad6fd6c075cee414c30174001fe5d.zip
Merge pull request #57 from crupest/dev
Add normal timeline feature.
Diffstat (limited to 'Timeline/Controllers/PersonalTimelineController.cs')
-rw-r--r--Timeline/Controllers/PersonalTimelineController.cs16
1 files changed, 8 insertions, 8 deletions
diff --git a/Timeline/Controllers/PersonalTimelineController.cs b/Timeline/Controllers/PersonalTimelineController.cs
index 11353bb5..b6c213d9 100644
--- a/Timeline/Controllers/PersonalTimelineController.cs
+++ b/Timeline/Controllers/PersonalTimelineController.cs
@@ -26,9 +26,9 @@ namespace Timeline.Controllers
}
[HttpGet("users/{username}/timeline")]
- public async Task<ActionResult<BaseTimelineInfo>> TimelineGet([FromRoute][Username] string username)
+ public async Task<ActionResult<TimelineInfo>> TimelineGet([FromRoute][Username] string username)
{
- return await _service.GetTimeline(username);
+ return (await _service.GetTimeline(username)).FillLinksForPersonalTimeline(Url);
}
[HttpGet("users/{username}/timeline/posts")]
@@ -77,14 +77,14 @@ namespace Timeline.Controllers
[HttpPatch("users/{username}/timeline")]
[Authorize]
- public async Task<ActionResult<BaseTimelineInfo>> TimelinePatch([FromRoute][Username] string username, [FromBody] TimelinePatchRequest body)
+ public async Task<ActionResult<TimelineInfo>> TimelinePatch([FromRoute][Username] string username, [FromBody] TimelinePatchRequest body)
{
- if (!this.IsAdministrator() && !(User.Identity.Name == username))
+ if (!this.IsAdministrator() && !(await _service.HasManagePermission(username, this.GetUserId())))
{
return StatusCode(StatusCodes.Status403Forbidden, ErrorResponse.Common.Forbid());
}
await _service.ChangeProperty(username, body);
- var timeline = await _service.GetTimeline(username);
+ var timeline = (await _service.GetTimeline(username)).FillLinksForPersonalTimeline(Url);
return Ok(timeline);
}
@@ -92,7 +92,7 @@ namespace Timeline.Controllers
[Authorize]
public async Task<ActionResult> TimelineMemberPut([FromRoute][Username] string username, [FromRoute][Username] string member)
{
- if (!this.IsAdministrator() && !(User.Identity.Name == username))
+ if (!this.IsAdministrator() && !(await _service.HasManagePermission(username, this.GetUserId())))
{
return StatusCode(StatusCodes.Status403Forbidden, ErrorResponse.Common.Forbid());
}
@@ -104,7 +104,7 @@ namespace Timeline.Controllers
}
catch (UserNotExistException)
{
- return BadRequest(ErrorResponse.TimelineController.MemberPut_NotExist());
+ return BadRequest(ErrorResponse.TimelineCommon.MemberPut_NotExist());
}
}
@@ -112,7 +112,7 @@ namespace Timeline.Controllers
[Authorize]
public async Task<ActionResult> TimelineMemberDelete([FromRoute][Username] string username, [FromRoute][Username] string member)
{
- if (!this.IsAdministrator() && !(User.Identity.Name == username))
+ if (!this.IsAdministrator() && !(await _service.HasManagePermission(username, this.GetUserId())))
{
return StatusCode(StatusCodes.Status403Forbidden, ErrorResponse.Common.Forbid());
}