diff options
author | 6543 <6543@obermui.de> | 2021-06-16 19:04:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-16 18:04:37 +0100 |
commit | 92736010646d4a5cfd3430c6f57bbf4cbd8951da (patch) | |
tree | 03eae57ccfc12e27fd513cc1af39e965f801a708 /models | |
parent | f4d3bf7867ac48d348f2c17637ca1229466c83bd (diff) | |
download | gitea-92736010646d4a5cfd3430c6f57bbf4cbd8951da.tar.gz gitea-92736010646d4a5cfd3430c6f57bbf4cbd8951da.zip |
Add subject-type filter to list notification API endpoints (#16177)
Close #15886
Diffstat (limited to 'models')
-rw-r--r-- | models/notification.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/models/notification.go b/models/notification.go index dcb0322079..56abd0ed83 100644 --- a/models/notification.go +++ b/models/notification.go @@ -74,6 +74,7 @@ type FindNotificationOptions struct { RepoID int64 IssueID int64 Status []NotificationStatus + Source []NotificationSource UpdatedAfterUnix int64 UpdatedBeforeUnix int64 } @@ -93,6 +94,9 @@ func (opts *FindNotificationOptions) ToCond() builder.Cond { if len(opts.Status) > 0 { cond = cond.And(builder.In("notification.status", opts.Status)) } + if len(opts.Source) > 0 { + cond = cond.And(builder.In("notification.source", opts.Source)) + } if opts.UpdatedAfterUnix != 0 { cond = cond.And(builder.Gte{"notification.updated_unix": opts.UpdatedAfterUnix}) } @@ -111,13 +115,13 @@ func (opts *FindNotificationOptions) ToSession(e Engine) *xorm.Session { return sess } -func getNotifications(e Engine, options FindNotificationOptions) (nl NotificationList, err error) { +func getNotifications(e Engine, options *FindNotificationOptions) (nl NotificationList, err error) { err = options.ToSession(e).OrderBy("notification.updated_unix DESC").Find(&nl) return } // GetNotifications returns all notifications that fit to the given options. -func GetNotifications(opts FindNotificationOptions) (NotificationList, error) { +func GetNotifications(opts *FindNotificationOptions) (NotificationList, error) { return getNotifications(x, opts) } |