comments
This commit is contained in:
parent
cbf67bf5f1
commit
ce3888f1ab
15 changed files with 162 additions and 21 deletions
|
@ -13,7 +13,9 @@ internal class Post : Entity
|
|||
public IList<PostMedia> Media { get; private set; }
|
||||
|
||||
public IList<PostReaction> Reactions { get; private set; } = [];
|
||||
public bool IsPublic { get; set; }
|
||||
|
||||
public IList<PostComment> Comments { get; private set; } = [];
|
||||
public bool IsPublic { get; private set; }
|
||||
|
||||
public DateTimeOffset PostedOn { get; private set; }
|
||||
|
||||
|
@ -27,7 +29,7 @@ internal class Post : Entity
|
|||
|
||||
private Post() { }
|
||||
|
||||
public Post(Guid authorId, string content, IList<PostMedia> media)
|
||||
public Post(Guid authorId, string content, IList<PostMedia> media, bool isPublic)
|
||||
{
|
||||
this.Id = Guid.CreateVersion7();
|
||||
this.AuthorId = authorId;
|
||||
|
@ -35,6 +37,7 @@ internal class Post : Entity
|
|||
this.Media = media;
|
||||
this.PossibleReactions = AllEmoji.GetRandomEmoji(5);
|
||||
this.PostedOn = DateTimeOffset.UtcNow;
|
||||
this.IsPublic = isPublic;
|
||||
|
||||
this.AddDomainEvent(new PostCreated(this));
|
||||
}
|
||||
|
@ -56,4 +59,14 @@ internal class Post : Entity
|
|||
.Reactions.Where(r => r.AuthorId != reactorId || r.Emoji != emoji)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public void AddComment(Guid authorId, string content)
|
||||
{
|
||||
// XXX just ignore empty comments for now. we may want to upgrade this to an error
|
||||
// but it is probably suitable to just consider it a no-op
|
||||
if (string.IsNullOrWhiteSpace(content))
|
||||
return;
|
||||
|
||||
this.Comments.Add(new PostComment(authorId, content));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue