🐛 Fix bugs

This commit is contained in:
2025-04-23 00:30:25 +08:00
parent c43ff6be7b
commit 31db3d5388
6 changed files with 39 additions and 11 deletions

View File

@ -18,7 +18,11 @@ public class PostService(AppDatabase db, FileService fs)
if (post.PublishedAt.Value.ToDateTimeUtc() < DateTime.UtcNow)
throw new InvalidOperationException("Cannot create the post which published in the past.");
}
else
{
post.PublishedAt = Instant.FromDateTimeUtc(DateTime.UtcNow);
}
if (attachments is not null)
{
post.Attachments = await db.Files.Where(e => attachments.Contains(e.Id)).ToListAsync();