diff options
author | crupest <crupest@outlook.com> | 2019-11-20 00:32:32 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2019-11-20 00:32:32 +0800 |
commit | 14f9493d41738a8b3523ed498838ad1f373b9377 (patch) | |
tree | 4a390f9c7bd4794fd399002f9b0eca7c7efa673f /Timeline/Controllers/PersonalTimelineController.cs | |
parent | ed8bae9cf7fd22300678d718cfee1913209f2cd0 (diff) | |
download | timeline-14f9493d41738a8b3523ed498838ad1f373b9377.tar.gz timeline-14f9493d41738a8b3523ed498838ad1f373b9377.tar.bz2 timeline-14f9493d41738a8b3523ed498838ad1f373b9377.zip |
Add delete nonexist post test, and fix the bug.
Diffstat (limited to 'Timeline/Controllers/PersonalTimelineController.cs')
-rw-r--r-- | Timeline/Controllers/PersonalTimelineController.cs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Timeline/Controllers/PersonalTimelineController.cs b/Timeline/Controllers/PersonalTimelineController.cs index 88f5ba00..c864ed39 100644 --- a/Timeline/Controllers/PersonalTimelineController.cs +++ b/Timeline/Controllers/PersonalTimelineController.cs @@ -107,14 +107,14 @@ namespace Timeline.Controllers [CatchTimelineNotExistException]
public async Task<ActionResult> PostOperationDelete([FromRoute][Username] string username, [FromBody] TimelinePostDeleteRequest body)
{
- var postId = body.Id!.Value;
- if (!IsAdmin() && !await _service.HasPostModifyPermission(username, postId, GetAuthUsername()!))
- {
- return StatusCode(StatusCodes.Status403Forbidden,
- new CommonResponse(ErrorCodes.Http.Timeline.PostOperationDeleteForbid, MessagePostOperationCreateForbid));
- }
try
{
+ var postId = body.Id!.Value;
+ if (!IsAdmin() && !await _service.HasPostModifyPermission(username, postId, GetAuthUsername()!))
+ {
+ return StatusCode(StatusCodes.Status403Forbidden,
+ new CommonResponse(ErrorCodes.Http.Timeline.PostOperationDeleteForbid, MessagePostOperationCreateForbid));
+ }
await _service.DeletePost(username, postId);
}
catch (TimelinePostNotExistException)
|