aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Models/Http
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-07-10 22:50:01 +0800
committerGitHub <noreply@github.com>2020-07-10 22:50:01 +0800
commit712cd6b079138e116a6de5d121b875094087e8a9 (patch)
treeb9f6dfdd8aa15304514de696622cbf0c64ab22a7 /Timeline/Models/Http
parente4ca28740d3ccdb64b61361a16bd104009682f6c (diff)
parent8036808ae8b7865d7d17b232c94b6a04ad197bb1 (diff)
downloadtimeline-712cd6b079138e116a6de5d121b875094087e8a9.tar.gz
timeline-712cd6b079138e116a6de5d121b875094087e8a9.tar.bz2
timeline-712cd6b079138e116a6de5d121b875094087e8a9.zip
Merge pull request #115 from crupest/post-deleted
Add timeline post deleted field.
Diffstat (limited to 'Timeline/Models/Http')
-rw-r--r--Timeline/Models/Http/Timeline.cs12
1 files changed, 9 insertions, 3 deletions
diff --git a/Timeline/Models/Http/Timeline.cs b/Timeline/Models/Http/Timeline.cs
index 80e6e69d..5404d561 100644
--- a/Timeline/Models/Http/Timeline.cs
+++ b/Timeline/Models/Http/Timeline.cs
@@ -18,7 +18,8 @@ namespace Timeline.Models.Http
public class TimelinePostInfo
{
public long Id { get; set; }
- public TimelinePostContentInfo Content { get; set; } = default!;
+ public TimelinePostContentInfo? Content { get; set; }
+ public bool Deleted { get; set; }
public DateTime Time { get; set; }
public UserInfo Author { get; set; } = default!;
public DateTime LastUpdated { get; set; } = default!;
@@ -73,7 +74,7 @@ namespace Timeline.Models.Http
}
}
- public class TimelinePostContentResolver : IValueResolver<TimelinePost, TimelinePostInfo, TimelinePostContentInfo>
+ public class TimelinePostContentResolver : IValueResolver<TimelinePost, TimelinePostInfo, TimelinePostContentInfo?>
{
private readonly IActionContextAccessor _actionContextAccessor;
private readonly IUrlHelperFactory _urlHelperFactory;
@@ -84,13 +85,18 @@ namespace Timeline.Models.Http
_urlHelperFactory = urlHelperFactory;
}
- public TimelinePostContentInfo Resolve(TimelinePost source, TimelinePostInfo destination, TimelinePostContentInfo destMember, ResolutionContext context)
+ public TimelinePostContentInfo? Resolve(TimelinePost source, TimelinePostInfo destination, TimelinePostContentInfo? destMember, ResolutionContext context)
{
var actionContext = _actionContextAccessor.AssertActionContextForUrlFill();
var urlHelper = _urlHelperFactory.GetUrlHelper(actionContext);
var sourceContent = source.Content;
+ if (sourceContent == null)
+ {
+ return null;
+ }
+
if (sourceContent is TextTimelinePostContent textContent)
{
return new TimelinePostContentInfo