mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-14 18:17:29 -06:00
Notifications (#34)
Notifications working for: * Mentions * Faves * New follow requests * New followers
This commit is contained in:
parent
e670c32a91
commit
40add68691
42 changed files with 2096 additions and 1194 deletions
|
|
@ -1138,6 +1138,35 @@ func (ps *postgresService) GetHomeTimelineForAccount(accountID string, maxID str
|
|||
return statuses, nil
|
||||
}
|
||||
|
||||
func (ps *postgresService) GetNotificationsForAccount(accountID string, limit int, maxID string) ([]*gtsmodel.Notification, error) {
|
||||
notifications := []*gtsmodel.Notification{}
|
||||
|
||||
q := ps.conn.Model(¬ifications).Where("target_account_id = ?", accountID)
|
||||
|
||||
|
||||
if maxID != "" {
|
||||
n := >smodel.Notification{}
|
||||
if err := ps.conn.Model(n).Where("id = ?", maxID).Select(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
q = q.Where("created_at < ?", n.CreatedAt)
|
||||
}
|
||||
|
||||
if limit != 0 {
|
||||
q = q.Limit(limit)
|
||||
}
|
||||
|
||||
q = q.Order("created_at DESC")
|
||||
|
||||
if err := q.Select(); err != nil {
|
||||
if err != pg.ErrNoRows {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
}
|
||||
return notifications, nil
|
||||
}
|
||||
|
||||
/*
|
||||
CONVERSION FUNCTIONS
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue