aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Controllers/TimelineController.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-02-24 16:52:19 +0800
committercrupest <crupest@outlook.com>2020-02-24 16:52:19 +0800
commit8be166185139b691ec53537115c5902caf3c5eb4 (patch)
tree15a9ecbe1339813d59af04b571f350043df36abc /Timeline/Controllers/TimelineController.cs
parent5e04f3db229546e5a6de95fd36f6c41e5304b2cf (diff)
downloadtimeline-8be166185139b691ec53537115c5902caf3c5eb4.tar.gz
timeline-8be166185139b691ec53537115c5902caf3c5eb4.tar.bz2
timeline-8be166185139b691ec53537115c5902caf3c5eb4.zip
Add delete timeline.
Diffstat (limited to 'Timeline/Controllers/TimelineController.cs')
-rw-r--r--Timeline/Controllers/TimelineController.cs20
1 files changed, 20 insertions, 0 deletions
diff --git a/Timeline/Controllers/TimelineController.cs b/Timeline/Controllers/TimelineController.cs
index 9ada16e0..85ccb5c1 100644
--- a/Timeline/Controllers/TimelineController.cs
+++ b/Timeline/Controllers/TimelineController.cs
@@ -206,5 +206,25 @@ namespace Timeline.Controllers
return BadRequest(ErrorResponse.TimelineCommon.NameConflict());
}
}
+
+ [HttpDelete("timelines/{name}")]
+ [Authorize]
+ public async Task<ActionResult<TimelineInfo>> TimelineDelete([FromRoute][TimelineName] string name)
+ {
+ if (!this.IsAdministrator() && !(await _service.HasManagePermission(name, this.GetUserId())))
+ {
+ return StatusCode(StatusCodes.Status403Forbidden, ErrorResponse.Common.Forbid());
+ }
+
+ try
+ {
+ await _service.DeleteTimeline(name);
+ return Ok(CommonDeleteResponse.Delete());
+ }
+ catch (TimelineNotExistException)
+ {
+ return Ok(CommonDeleteResponse.NotExist());
+ }
+ }
}
}