mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-08 07:09:31 -06:00
more timeline stuff
This commit is contained in:
parent
5d65b6ca0a
commit
625e6d654c
7 changed files with 139 additions and 46 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue