diff options
author | crupest <crupest@outlook.com> | 2020-08-11 17:59:44 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-08-11 17:59:44 +0800 |
commit | 7df5e63e8b2eaa5b4f83ee72a32eeedd480cde47 (patch) | |
tree | 77e56827955f1e84aaa0ccb8d36969818cfc1640 /Timeline/Services/TimelineService.cs | |
parent | 4685d69fe965b32438c399a4ad4a3deee9fb0a55 (diff) | |
download | timeline-7df5e63e8b2eaa5b4f83ee72a32eeedd480cde47.tar.gz timeline-7df5e63e8b2eaa5b4f83ee72a32eeedd480cde47.tar.bz2 timeline-7df5e63e8b2eaa5b4f83ee72a32eeedd480cde47.zip |
Post list modified since now consider username change. And make all datetime utc.
Diffstat (limited to 'Timeline/Services/TimelineService.cs')
-rw-r--r-- | Timeline/Services/TimelineService.cs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Timeline/Services/TimelineService.cs b/Timeline/Services/TimelineService.cs index 283938fb..0070fe3e 100644 --- a/Timeline/Services/TimelineService.cs +++ b/Timeline/Services/TimelineService.cs @@ -565,11 +565,13 @@ namespace Timeline.Services public async Task<List<TimelinePost>> GetPosts(string timelineName, DateTime? modifiedSince = null, bool includeDeleted = false)
{
+ modifiedSince = modifiedSince?.MyToUtc();
+
if (timelineName == null)
throw new ArgumentNullException(nameof(timelineName));
var timelineId = await FindTimelineId(timelineName);
- var query = _database.TimelinePosts.OrderBy(p => p.Time).Where(p => p.TimelineId == timelineId);
+ IQueryable<TimelinePostEntity> query = _database.TimelinePosts.Where(p => p.TimelineId == timelineId);
if (!includeDeleted)
{
@@ -578,9 +580,11 @@ namespace Timeline.Services if (modifiedSince.HasValue)
{
- query = query.Where(p => p.LastUpdated >= modifiedSince);
+ query = query.Include(p => p.Author).Where(p => p.LastUpdated >= modifiedSince || (p.Author != null && p.Author.UsernameChangeTime >= modifiedSince));
}
+ query = query.OrderBy(p => p.Time);
+
var postEntities = await query.ToListAsync();
var posts = new List<TimelinePost>();
@@ -663,6 +667,8 @@ namespace Timeline.Services public async Task<TimelinePost> CreateTextPost(string timelineName, long authorId, string text, DateTime? time)
{
+ time = time?.MyToUtc();
+
if (timelineName == null)
throw new ArgumentNullException(nameof(timelineName));
if (text == null)
@@ -704,6 +710,8 @@ namespace Timeline.Services public async Task<TimelinePost> CreateImagePost(string timelineName, long authorId, byte[] data, DateTime? time)
{
+ time = time?.MyToUtc();
+
if (timelineName == null)
throw new ArgumentNullException(nameof(timelineName));
if (data == null)
|