mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-07-07 07:00:01 +02:00
Merge pull request #539 from andreynering/notifications-step-2
Notifications - Step 2
This commit is contained in:
commit
79d527195d
10 changed files with 233 additions and 6 deletions
|
@ -182,14 +182,20 @@ func getIssueNotification(e Engine, userID, issueID int64) (*Notification, error
|
|||
}
|
||||
|
||||
// NotificationsForUser returns notifications for a given user and status
|
||||
func NotificationsForUser(user *User, status NotificationStatus) ([]*Notification, error) {
|
||||
return notificationsForUser(x, user, status)
|
||||
func NotificationsForUser(user *User, status NotificationStatus, page, perPage int) ([]*Notification, error) {
|
||||
return notificationsForUser(x, user, status, page, perPage)
|
||||
}
|
||||
func notificationsForUser(e Engine, user *User, status NotificationStatus) (notifications []*Notification, err error) {
|
||||
err = e.
|
||||
func notificationsForUser(e Engine, user *User, status NotificationStatus, page, perPage int) (notifications []*Notification, err error) {
|
||||
sess := e.
|
||||
Where("user_id = ?", user.ID).
|
||||
And("status = ?", status).
|
||||
OrderBy("updated_unix DESC").
|
||||
OrderBy("updated_unix DESC")
|
||||
|
||||
if page > 0 && perPage > 0 {
|
||||
sess.Limit(perPage, (page-1)*perPage)
|
||||
}
|
||||
|
||||
err = sess.
|
||||
Find(¬ifications)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue