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
commit890fef4f276ec44312eb936583adbbf47d7cfe9d (patch)
tree246541d65473634839d5536b1111f7b742f54dab /BackEnd/Timeline/Controllers/TimelinePostController.cs
parent5c0d0645fd2c1bfb51069d6f9079db32493f2956 (diff)
downloadtimeline-890fef4f276ec44312eb936583adbbf47d7cfe9d.tar.gz
timeline-890fef4f276ec44312eb936583adbbf47d7cfe9d.tar.bz2
timeline-890fef4f276ec44312eb936583adbbf47d7cfe9d.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;
+ }
);
}