aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline/Controllers/TimelinePostController.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-03-06 22:51:53 +0800
committercrupest <crupest@outlook.com>2021-03-06 22:51:53 +0800
commit8f09e3172f249a9f5d229040415a0569e9d1c01b (patch)
tree59507331750831118e7caa071a10e1cb8fc1e627 /BackEnd/Timeline/Controllers/TimelinePostController.cs
parent24c272403ba360f27acd68c2702c678a86063964 (diff)
downloadtimeline-8f09e3172f249a9f5d229040415a0569e9d1c01b.tar.gz
timeline-8f09e3172f249a9f5d229040415a0569e9d1c01b.tar.bz2
timeline-8f09e3172f249a9f5d229040415a0569e9d1c01b.zip
feat: Auto translate url in markdown post.
Diffstat (limited to 'BackEnd/Timeline/Controllers/TimelinePostController.cs')
-rw-r--r--BackEnd/Timeline/Controllers/TimelinePostController.cs15
1 files changed, 13 insertions, 2 deletions
diff --git a/BackEnd/Timeline/Controllers/TimelinePostController.cs b/BackEnd/Timeline/Controllers/TimelinePostController.cs
index 4026d551..86c5c8cf 100644
--- a/BackEnd/Timeline/Controllers/TimelinePostController.cs
+++ b/BackEnd/Timeline/Controllers/TimelinePostController.cs
@@ -32,14 +32,17 @@ namespace Timeline.Controllers
private readonly TimelineMapper _timelineMapper;
+ private readonly MarkdownProcessor _markdownProcessor;
+
/// <summary>
///
/// </summary>
- public TimelinePostController(ITimelineService timelineService, ITimelinePostService timelinePostService, TimelineMapper timelineMapper)
+ public TimelinePostController(ITimelineService timelineService, ITimelinePostService timelinePostService, TimelineMapper timelineMapper, MarkdownProcessor markdownProcessor)
{
_timelineService = timelineService;
_postService = timelinePostService;
_timelineMapper = timelineMapper;
+ _markdownProcessor = markdownProcessor;
}
private bool UserHasAllTimelineManagementPermission => this.UserHasPermission(UserPermission.AllTimelineManagement);
@@ -147,7 +150,15 @@ namespace Timeline.Controllers
return await DataCacheHelper.GenerateActionResult(this,
() => _postService.GetPostDataDigest(timelineId, post, dataIndex),
- () => _postService.GetPostData(timelineId, post, dataIndex)
+ async () =>
+ {
+ var data = await _postService.GetPostData(timelineId, post, dataIndex);
+ if (data.ContentType == MimeTypes.TextMarkdown)
+ {
+ return new ByteData(_markdownProcessor.Process(data.Data, Url, timeline, post), data.ContentType);
+ }
+ return data;
+ }
);
}