|
|
@ -74,7 +74,7 @@ func (app *App) FetchPublicPosts() (interface{}, error) { |
|
|
|
// ageCond := `p.created >= ` + app.db.dateSub(3, "month") + ` AND `
|
|
|
|
// ageCond := `p.created >= ` + app.db.dateSub(3, "month") + ` AND `
|
|
|
|
|
|
|
|
|
|
|
|
// Finds all public posts and posts in a public collection published during the owner's active subscription period and within the last 3 months
|
|
|
|
// Finds all public posts and posts in a public collection published during the owner's active subscription period and within the last 3 months
|
|
|
|
rows, err := app.db.Query(`SELECT p.id, alias, c.title, p.slug, p.title, p.content, p.text_appearance, p.language, p.rtl, p.created, p.updated |
|
|
|
rows, err := app.db.Query(`SELECT p.id, c.id, alias, c.title, p.slug, p.title, p.content, p.text_appearance, p.language, p.rtl, p.created, p.updated |
|
|
|
FROM collections c |
|
|
|
FROM collections c |
|
|
|
LEFT JOIN posts p ON p.collection_id = c.id |
|
|
|
LEFT JOIN posts p ON p.collection_id = c.id |
|
|
|
LEFT JOIN users u ON u.id = p.owner_id |
|
|
|
LEFT JOIN users u ON u.id = p.owner_id |
|
|
@ -94,7 +94,7 @@ func (app *App) FetchPublicPosts() (interface{}, error) { |
|
|
|
p := &Post{} |
|
|
|
p := &Post{} |
|
|
|
c := &Collection{} |
|
|
|
c := &Collection{} |
|
|
|
var alias, title sql.NullString |
|
|
|
var alias, title sql.NullString |
|
|
|
err = rows.Scan(&p.ID, &alias, &title, &p.Slug, &p.Title, &p.Content, &p.Font, &p.Language, &p.RTL, &p.Created, &p.Updated) |
|
|
|
err = rows.Scan(&p.ID, &c.ID, &alias, &title, &p.Slug, &p.Title, &p.Content, &p.Font, &p.Language, &p.RTL, &p.Created, &p.Updated) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
log.Error("[READ] Unable to scan row, skipping: %v", err) |
|
|
|
log.Error("[READ] Unable to scan row, skipping: %v", err) |
|
|
|
continue |
|
|
|
continue |
|
|
@ -111,9 +111,11 @@ func (app *App) FetchPublicPosts() (interface{}, error) { |
|
|
|
|
|
|
|
|
|
|
|
c.Public = true |
|
|
|
c.Public = true |
|
|
|
c.Title = title.String |
|
|
|
c.Title = title.String |
|
|
|
|
|
|
|
c.Monetization = app.db.GetCollectionAttribute(c.ID, "monetization_pointer") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
p.extractData() |
|
|
|
p.extractData() |
|
|
|
|
|
|
|
p.handlePremiumContent(c, false, false, app.cfg) |
|
|
|
p.HTMLContent = template.HTML(applyMarkdown([]byte(p.Content), "", app.cfg)) |
|
|
|
p.HTMLContent = template.HTML(applyMarkdown([]byte(p.Content), "", app.cfg)) |
|
|
|
fp := p.processPost() |
|
|
|
fp := p.processPost() |
|
|
|
if isCollectionPost { |
|
|
|
if isCollectionPost { |
|
|
|