Change GetPosts() to have includePinned parameter, change all calls to match
This commit is contained in:
parent
b6da5d9711
commit
95e84a1d0e
|
@ -127,7 +127,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, true)
|
||||
posts, err := app.db.GetPosts(c, p, false, true, false)
|
||||
for _, pp := range *posts {
|
||||
pp.Collection = res
|
||||
o := pp.ActivityObject()
|
||||
|
|
|
@ -492,7 +492,7 @@ func fetchCollectionPosts(app *app, w http.ResponseWriter, r *http.Request) erro
|
|||
}
|
||||
}
|
||||
|
||||
posts, err := app.db.GetPosts(c, page, isCollOwner, false)
|
||||
posts, err := app.db.GetPosts(c, page, isCollOwner, false, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -723,7 +723,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, false)
|
||||
coll.Posts, _ = app.db.GetPosts(c, page, cr.isCollOwner, false, false)
|
||||
|
||||
// Serve collection
|
||||
displayPage := CollectionPage{
|
||||
|
|
10
database.go
10
database.go
|
@ -104,7 +104,7 @@ type writestore interface {
|
|||
ClaimPosts(userID int64, collAlias string, posts *[]ClaimPostRequest) (*[]ClaimPostResult, error)
|
||||
|
||||
GetPostsCount(c *CollectionObj, includeFuture bool)
|
||||
GetPosts(c *Collection, page int, includeFuture, forceRecentFirst bool) (*[]PublicPost, error)
|
||||
GetPosts(c *Collection, page int, includeFuture, forceRecentFirst, includePinned bool) (*[]PublicPost, error)
|
||||
GetPostsTagged(c *Collection, tag string, page int, includeFuture bool) (*[]PublicPost, error)
|
||||
|
||||
GetAPFollowers(c *Collection) (*[]RemoteUser, error)
|
||||
|
@ -1065,7 +1065,7 @@ 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, forceRecentFirst bool) (*[]PublicPost, error) {
|
||||
func (db *datastore) GetPosts(c *Collection, page int, includeFuture, forceRecentFirst, includePinned bool) (*[]PublicPost, error) {
|
||||
collID := c.ID
|
||||
|
||||
cf := c.NewFormat()
|
||||
|
@ -1089,7 +1089,11 @@ func (db *datastore) GetPosts(c *Collection, page int, includeFuture, forceRecen
|
|||
if !includeFuture {
|
||||
timeCondition = "AND created <= " + db.now()
|
||||
}
|
||||
rows, err := db.Query("SELECT "+postCols+" FROM posts WHERE collection_id = ? AND pinned_position IS NULL "+timeCondition+" ORDER BY created "+order+limitStr, collID)
|
||||
pinnedCondition := ""
|
||||
if !includePinned {
|
||||
pinnedCondition = "AND pinned_position IS NULL"
|
||||
}
|
||||
rows, err := db.Query("SELECT "+postCols+" FROM posts WHERE collection_id = ? "+pinnedCondition+" "+timeCondition+" ORDER BY created "+order+limitStr, collID)
|
||||
if err != nil {
|
||||
log.Error("Failed selecting from posts: %v", err)
|
||||
return nil, impart.HTTPError{http.StatusInternalServerError, "Couldn't retrieve collection posts."}
|
||||
|
|
|
@ -111,7 +111,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, false)
|
||||
co.Posts, err = app.db.GetPosts(&c, 0, true, false, true)
|
||||
if err != nil {
|
||||
log.Error("unable to get collection posts: %v", err)
|
||||
}
|
||||
|
|
2
feed.go
2
feed.go
|
@ -56,7 +56,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, true)
|
||||
coll.Posts, _ = app.db.GetPosts(c, 1, false, true, false)
|
||||
}
|
||||
|
||||
author := ""
|
||||
|
|
|
@ -64,7 +64,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, false)
|
||||
posts, err := app.db.GetPosts(c, 0, false, false, false)
|
||||
if err != nil {
|
||||
log.Error("Error getting posts: %v", err)
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue