more timeline stuff
This commit is contained in:
@ -256,7 +256,7 @@ type DB interface {
|
||||
WhoBoostedStatus(status *gtsmodel.Status) ([]*gtsmodel.Account, error)
|
||||
|
||||
// GetStatusesWhereFollowing returns a slice of statuses from accounts that are followed by the given account id.
|
||||
GetStatusesWhereFollowing(accountID string, limit int, maxID string, minID string, sinceID string) ([]*gtsmodel.Status, error)
|
||||
GetStatusesWhereFollowing(accountID string, maxID string, sinceID string, minID string, limit int, local bool) ([]*gtsmodel.Status, error)
|
||||
|
||||
// GetPublicTimelineForAccount fetches the account's PUBLIC timline -- ie., posts and replies that are public.
|
||||
// It will use the given filters and try to return as many statuses as possible up to the limit.
|
||||
|
||||
@ -1133,7 +1133,7 @@ func (ps *postgresService) WhoBoostedStatus(status *gtsmodel.Status) ([]*gtsmode
|
||||
return accounts, nil
|
||||
}
|
||||
|
||||
func (ps *postgresService) GetStatusesWhereFollowing(accountID string, limit int, offsetStatusID string, includeOffsetStatus bool, ascending bool) ([]*gtsmodel.Status, error) {
|
||||
func (ps *postgresService) GetStatusesWhereFollowing(accountID string, maxID string, sinceID string, minID string, limit int, local bool) ([]*gtsmodel.Status, error) {
|
||||
statuses := []*gtsmodel.Status{}
|
||||
|
||||
q := ps.conn.Model(&statuses)
|
||||
@ -1142,23 +1142,35 @@ func (ps *postgresService) GetStatusesWhereFollowing(accountID string, limit int
|
||||
Join("JOIN follows AS f ON f.target_account_id = status.account_id").
|
||||
Where("f.account_id = ?", accountID)
|
||||
|
||||
if ascending {
|
||||
if maxID != "" {
|
||||
s := >smodel.Status{}
|
||||
if err := ps.conn.Model(s).Where("id = ?", maxID).Select(); err == nil {
|
||||
q = q.Where("status.created_at < ?", s.CreatedAt)
|
||||
}
|
||||
}
|
||||
|
||||
if sinceID != "" {
|
||||
s := >smodel.Status{}
|
||||
if err := ps.conn.Model(s).Where("id = ?", sinceID).Select(); err == nil {
|
||||
q = q.Where("status.created_at > ?", s.CreatedAt)
|
||||
}
|
||||
}
|
||||
|
||||
if minID != "" {
|
||||
s := >smodel.Status{}
|
||||
if err := ps.conn.Model(s).Where("id = ?", minID).Select(); err == nil {
|
||||
q = q.Where("status.created_at > ?", s.CreatedAt)
|
||||
}
|
||||
}
|
||||
|
||||
if minID != "" {
|
||||
q = q.Order("status.created_at")
|
||||
} else {
|
||||
q = q.Order("status.created_at DESC")
|
||||
}
|
||||
|
||||
s := >smodel.Status{}
|
||||
if offsetStatusID != "" {
|
||||
if err := ps.conn.Model(s).Where("id = ?", offsetStatusID).Select(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if ascending {
|
||||
q = q.Where("status.created_at > ?", s.CreatedAt)
|
||||
} else {
|
||||
q = q.Where("status.created_at < ?", s.CreatedAt)
|
||||
}
|
||||
if local {
|
||||
q = q.Where("status.local = ?", local)
|
||||
}
|
||||
|
||||
if limit > 0 {
|
||||
@ -1172,14 +1184,6 @@ func (ps *postgresService) GetStatusesWhereFollowing(accountID string, limit int
|
||||
}
|
||||
}
|
||||
|
||||
if includeOffsetStatus {
|
||||
if ascending {
|
||||
statuses = append([]*gtsmodel.Status{s}, statuses...)
|
||||
} else {
|
||||
statuses = append(statuses, s)
|
||||
}
|
||||
}
|
||||
|
||||
return statuses, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user