diff --git a/activitypub.go b/activitypub.go index 1acd41f..48be9f0 100644 --- a/activitypub.go +++ b/activitypub.go @@ -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() diff --git a/collections.go b/collections.go index 0841f7a..49fc0c0 100644 --- a/collections.go +++ b/collections.go @@ -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{ diff --git a/database.go b/database.go index 7c4a593..d3e6566 100644 --- a/database.go +++ b/database.go @@ -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" } diff --git a/export.go b/export.go index 56b5676..316e192 100644 --- a/export.go +++ b/export.go @@ -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) } diff --git a/feed.go b/feed.go index 91c354a..b83c54b 100644 --- a/feed.go +++ b/feed.go @@ -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 := "" diff --git a/sitemap.go b/sitemap.go index 0712bf6..3f6b36d 100644 --- a/sitemap.go +++ b/sitemap.go @@ -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