Make sure random redirect only selects published and public posts

This commit is contained in:
Jan-Lukas Else 2023-02-13 20:35:00 +01:00
parent 812cff1941
commit e9e03c2fc7
1 changed files with 8 additions and 1 deletions

View File

@ -647,7 +647,14 @@ func (d *database) countPosts(config *postsRequestConfig) (count int, err error)
func (a *goBlog) getRandomPostPath(blog string) (path string, err error) {
sections := lo.Keys(a.cfg.Blogs[blog].Sections)
query, params := buildPostsQuery(&postsRequestConfig{randomOrder: true, limit: 1, blog: blog, sections: sections}, "path")
query, params := buildPostsQuery(&postsRequestConfig{
randomOrder: true,
limit: 1,
blog: blog,
sections: sections,
visibility: []postVisibility{visibilityPublic},
status: []postStatus{statusPublished},
}, "path")
row, err := a.db.QueryRow(query, params...)
if err != nil {