Fix Novel blog post order in feeds and outbox

This commit is contained in:
Matt Baer 2018-11-17 21:59:04 -05:00
parent 2ad2270973
commit b58cb1e541
6 changed files with 9 additions and 9 deletions

View File

@ -117,7 +117,7 @@ func handleFetchCollectionOutbox(app *app, w http.ResponseWriter, r *http.Reques
ocp := activitystreams.NewOrderedCollectionPage(accountRoot, "outbox", res.TotalPosts, p)
ocp.OrderedItems = []interface{}{}
posts, err := app.db.GetPosts(c, p, false)
posts, err := app.db.GetPosts(c, p, false, true)
for _, pp := range *posts {
pp.Collection = res
o := pp.ActivityObject()

View File

@ -483,7 +483,7 @@ func fetchCollectionPosts(app *app, w http.ResponseWriter, r *http.Request) erro
}
}
posts, err := app.db.GetPosts(c, page, isCollOwner)
posts, err := app.db.GetPosts(c, page, isCollOwner, false)
if err != nil {
return err
}
@ -714,7 +714,7 @@ func handleViewCollection(app *app, w http.ResponseWriter, r *http.Request) erro
return impart.HTTPError{http.StatusFound, redirURL}
}
coll.Posts, _ = app.db.GetPosts(c, page, cr.isCollOwner)
coll.Posts, _ = app.db.GetPosts(c, page, cr.isCollOwner, false)
// Serve collection
displayPage := CollectionPage{

View File

@ -86,7 +86,7 @@ type writestore interface {
ClaimPosts(userID int64, collAlias string, posts *[]ClaimPostRequest) (*[]ClaimPostResult, error)
GetPostsCount(c *CollectionObj, includeFuture bool)
GetPosts(c *Collection, page int, includeFuture bool) (*[]PublicPost, error)
GetPosts(c *Collection, page int, includeFuture, forceRecentFirst bool) (*[]PublicPost, error)
GetPostsTagged(c *Collection, tag string, page int, includeFuture bool) (*[]PublicPost, error)
GetAPFollowers(c *Collection) (*[]RemoteUser, error)
@ -986,12 +986,12 @@ func (db *datastore) GetPostsCount(c *CollectionObj, includeFuture bool) {
// GetPosts retrieves all standard (non-pinned) posts for the given Collection.
// It will return future posts if `includeFuture` is true.
// TODO: change includeFuture to isOwner, since that's how it's used
func (db *datastore) GetPosts(c *Collection, page int, includeFuture bool) (*[]PublicPost, error) {
func (db *datastore) GetPosts(c *Collection, page int, includeFuture, forceRecentFirst bool) (*[]PublicPost, error) {
collID := c.ID
cf := c.NewFormat()
order := "DESC"
if cf.Ascending() {
if cf.Ascending() && !forceRecentFirst {
order = "ASC"
}

View File

@ -101,7 +101,7 @@ func compileFullExport(app *app, u *User) *ExportUser {
var collObjs []CollectionObj
for _, c := range *colls {
co := &CollectionObj{Collection: c}
co.Posts, err = app.db.GetPosts(&c, 0, true)
co.Posts, err = app.db.GetPosts(&c, 0, true, false)
if err != nil {
log.Error("unable to get collection posts: %v", err)
}

View File

@ -46,7 +46,7 @@ func ViewFeed(app *app, w http.ResponseWriter, req *http.Request) error {
if tag != "" {
coll.Posts, _ = app.db.GetPostsTagged(c, tag, 1, false)
} else {
coll.Posts, _ = app.db.GetPosts(c, 1, false)
coll.Posts, _ = app.db.GetPosts(c, 1, false, true)
}
author := ""

View File

@ -54,7 +54,7 @@ func handleViewSitemap(app *app, w http.ResponseWriter, r *http.Request) error {
host = c.CanonicalURL()
sm := buildSitemap(host, pre)
posts, err := app.db.GetPosts(c, 0, false)
posts, err := app.db.GetPosts(c, 0, false, false)
if err != nil {
log.Error("Error getting posts: %v", err)
return err