Store post state as text so Go owns the allowed values and future states such as locked remain representable without a database enum migration.
This commit is contained in:
@@ -463,7 +463,7 @@ func (m *Memory) ListRootPosts(_ context.Context, postDate, viewerID string) ([]
|
||||
defer m.mu.Unlock()
|
||||
posts := make([]Post, 0)
|
||||
for _, post := range m.posts {
|
||||
if post.ParentID != nil || post.PostDate != postDate || post.Hidden {
|
||||
if post.ParentID != nil || post.PostDate != postDate || post.PostState == PostStateHidden {
|
||||
continue
|
||||
}
|
||||
cp := clonePostWithAuthor(post, m.users)
|
||||
@@ -496,7 +496,7 @@ func (m *Memory) VotePost(_ context.Context, userID, postID string, value int) e
|
||||
return fmt.Errorf("invalid vote")
|
||||
}
|
||||
post, ok := m.posts[postID]
|
||||
if !ok || post.ParentID != nil || post.Hidden {
|
||||
if !ok || post.ParentID != nil || post.PostState == PostStateHidden {
|
||||
return ErrPostNotVotable
|
||||
}
|
||||
if m.postVotes[postID] == nil {
|
||||
|
||||
Reference in New Issue
Block a user