diff options
author | crupest <crupest@outlook.com> | 2020-03-10 19:37:58 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-03-10 19:37:58 +0800 |
commit | 95be9f58b7cf76f1c585791447e8393d61862e1c (patch) | |
tree | b9165a233b00c4ab5be47f0ce786b64c178a9fdf /Timeline/Controllers/TimelineController.cs | |
parent | 88232f85e69a5e4b390e73344b31372746d4adca (diff) | |
download | timeline-95be9f58b7cf76f1c585791447e8393d61862e1c.tar.gz timeline-95be9f58b7cf76f1c585791447e8393d61862e1c.tar.bz2 timeline-95be9f58b7cf76f1c585791447e8393d61862e1c.zip |
...
Diffstat (limited to 'Timeline/Controllers/TimelineController.cs')
-rw-r--r-- | Timeline/Controllers/TimelineController.cs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Timeline/Controllers/TimelineController.cs b/Timeline/Controllers/TimelineController.cs index 38fe7475..440b0d19 100644 --- a/Timeline/Controllers/TimelineController.cs +++ b/Timeline/Controllers/TimelineController.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
+using Microsoft.Net.Http.Headers;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
@@ -113,6 +114,19 @@ namespace Timeline.Controllers return result;
}
+ // TODO: Make cache available.
+ [HttpGet("timelines/{name}/posts/{id}/data")]
+ public async Task<ActionResult<List<TimelinePostInfo>>> PostDataGet([FromRoute][GeneralTimelineName] string name, [FromRoute] long id)
+ {
+ if (!this.IsAdministrator() && !await _service.HasReadPermission(name, this.GetOptionalUserId()))
+ {
+ return StatusCode(StatusCodes.Status403Forbidden, ErrorResponse.Common.Forbid());
+ }
+
+ var data = await _service.GetPostData(name, id);
+ return File(data.Data, data.Type, data.LastModified, new EntityTagHeaderValue(data.ETag));
+ }
+
[HttpPost("timelines/{name}/posts")]
[Authorize]
public async Task<ActionResult<TimelinePostInfo>> PostPost([FromRoute][GeneralTimelineName] string name, [FromBody] TimelinePostCreateRequest body)
|