diff --git a/OliverBooth/Data/Blog/BlogPost.cs b/OliverBooth/Data/Blog/BlogPost.cs
index ec8e877..e1e1c3f 100644
--- a/OliverBooth/Data/Blog/BlogPost.cs
+++ b/OliverBooth/Data/Blog/BlogPost.cs
@@ -22,6 +22,9 @@ internal sealed class BlogPost : IBlogPost
///
public bool IsRedirect { get; internal set; }
+ ///
+ public string? Password { get; internal set; }
+
///
public DateTimeOffset Published { get; internal set; }
@@ -37,6 +40,9 @@ internal sealed class BlogPost : IBlogPost
///
public DateTimeOffset? Updated { get; internal set; }
+ ///
+ public BlogPostVisibility Visibility { get; internal set; }
+
///
public int? WordPressId { get; set; }
diff --git a/OliverBooth/Data/Blog/BlogPostVisibility.cs b/OliverBooth/Data/Blog/BlogPostVisibility.cs
new file mode 100644
index 0000000..d8e982a
--- /dev/null
+++ b/OliverBooth/Data/Blog/BlogPostVisibility.cs
@@ -0,0 +1,22 @@
+namespace OliverBooth.Data.Blog;
+
+///
+/// An enumeration of the possible visibilities of a blog post.
+///
+public enum BlogPostVisibility
+{
+ ///
+ /// The post is private and only visible to the author, or those with the password.
+ ///
+ Private,
+
+ ///
+ /// The post is unlisted and only visible to those with the link.
+ ///
+ Unlisted,
+
+ ///
+ /// The post is published and visible to everyone.
+ ///
+ Published
+}
diff --git a/OliverBooth/Data/Blog/Configuration/BlogPostConfiguration.cs b/OliverBooth/Data/Blog/Configuration/BlogPostConfiguration.cs
index 1fd1b9c..a248d96 100644
--- a/OliverBooth/Data/Blog/Configuration/BlogPostConfiguration.cs
+++ b/OliverBooth/Data/Blog/Configuration/BlogPostConfiguration.cs
@@ -26,5 +26,7 @@ internal sealed class BlogPostConfiguration : IEntityTypeConfiguration
builder.Property(e => e.DisqusDomain).IsRequired(false);
builder.Property(e => e.DisqusIdentifier).IsRequired(false);
builder.Property(e => e.DisqusPath).IsRequired(false);
+ builder.Property(e => e.Visibility).HasConversion(new EnumToStringConverter()).IsRequired();
+ builder.Property(e => e.Password).HasMaxLength(255).IsRequired(false);
}
}
diff --git a/OliverBooth/Data/Blog/IBlogPost.cs b/OliverBooth/Data/Blog/IBlogPost.cs
index 9af773d..6cf646a 100644
--- a/OliverBooth/Data/Blog/IBlogPost.cs
+++ b/OliverBooth/Data/Blog/IBlogPost.cs
@@ -39,6 +39,12 @@ public interface IBlogPost
///
bool IsRedirect { get; }
+ ///
+ /// Gets the password of the post.
+ ///
+ /// The password of the post.
+ string? Password { get; }
+
///
/// Gets the date and time the post was published.
///
@@ -69,6 +75,12 @@ public interface IBlogPost
/// The update date and time, or if the post has not been updated.
DateTimeOffset? Updated { get; }
+ ///
+ /// Gets the visibility of the post.
+ ///
+ /// The visibility of the post.
+ BlogPostVisibility Visibility { get; }
+
///
/// Gets the WordPress ID of the post.
///
diff --git a/OliverBooth/Services/BlogPostService.cs b/OliverBooth/Services/BlogPostService.cs
index 8a0f67e..77da54a 100644
--- a/OliverBooth/Services/BlogPostService.cs
+++ b/OliverBooth/Services/BlogPostService.cs
@@ -43,7 +43,9 @@ internal sealed class BlogPostService : IBlogPostService
public IReadOnlyList GetAllBlogPosts(int limit = -1)
{
using BlogContext context = _dbContextFactory.CreateDbContext();
- IQueryable ordered = context.BlogPosts.OrderByDescending(post => post.Published);
+ IQueryable ordered = context.BlogPosts
+ .Where(p => p.Visibility == BlogPostVisibility.Published)
+ .OrderByDescending(post => post.Published);
if (limit > -1)
{
ordered = ordered.Take(limit);
@@ -57,6 +59,7 @@ internal sealed class BlogPostService : IBlogPostService
{
using BlogContext context = _dbContextFactory.CreateDbContext();
return context.BlogPosts
+ .Where(p => p.Visibility == BlogPostVisibility.Published)
.OrderByDescending(post => post.Published)
.Skip(page * pageSize)
.Take(pageSize)