aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Controllers
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2019-11-20 00:32:32 +0800
committercrupest <crupest@outlook.com>2019-11-20 00:32:32 +0800
commiteb35c608b3d73db2cd819a8280fa1cdce1f59dc2 (patch)
tree4a390f9c7bd4794fd399002f9b0eca7c7efa673f /Timeline/Controllers
parenta72960e54a89bd31dcb8be8f52e097007dfd23e5 (diff)
downloadtimeline-eb35c608b3d73db2cd819a8280fa1cdce1f59dc2.tar.gz
timeline-eb35c608b3d73db2cd819a8280fa1cdce1f59dc2.tar.bz2
timeline-eb35c608b3d73db2cd819a8280fa1cdce1f59dc2.zip
Add delete nonexist post test, and fix the bug.
Diffstat (limited to 'Timeline/Controllers')
-rw-r--r--Timeline/Controllers/PersonalTimelineController.cs12
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)