From 52a90f32669c0aaa82b382322d02997ee3c02d85 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sat, 19 Sep 2020 16:12:04 +0200 Subject: [PATCH] API: NotificationSubject show Issue/Pull State --- models/notification.go | 2 ++ modules/structs/notifications.go | 9 +++++---- templates/swagger/v1_json.tmpl | 3 +++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/models/notification.go b/models/notification.go index 80d837078acc5..1f51c99c4c250 100644 --- a/models/notification.go +++ b/models/notification.go @@ -354,6 +354,7 @@ func (n *Notification) APIFormat() *api.NotificationThread { if n.Issue != nil { result.Subject.Title = n.Issue.Title result.Subject.URL = n.Issue.APIURL() + result.Subject.State = n.Issue.State() comment, err := n.Issue.GetLastComment() if err == nil && comment != nil { result.Subject.LatestCommentURL = comment.APIURL() @@ -364,6 +365,7 @@ func (n *Notification) APIFormat() *api.NotificationThread { if n.Issue != nil { result.Subject.Title = n.Issue.Title result.Subject.URL = n.Issue.APIURL() + result.Subject.State = n.Issue.State() comment, err := n.Issue.GetLastComment() if err == nil && comment != nil { result.Subject.LatestCommentURL = comment.APIURL() diff --git a/modules/structs/notifications.go b/modules/structs/notifications.go index b6c9774a97ad8..8daa6de1686f5 100644 --- a/modules/structs/notifications.go +++ b/modules/structs/notifications.go @@ -21,10 +21,11 @@ type NotificationThread struct { // NotificationSubject contains the notification subject (Issue/Pull/Commit) type NotificationSubject struct { - Title string `json:"title"` - URL string `json:"url"` - LatestCommentURL string `json:"latest_comment_url"` - Type string `json:"type" binding:"In(Issue,Pull,Commit)"` + Title string `json:"title"` + URL string `json:"url"` + LatestCommentURL string `json:"latest_comment_url"` + Type string `json:"type" binding:"In(Issue,Pull,Commit)"` + State StateType `json:"state"` } // NotificationCount number of unread notifications diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 4b78b40dd29b6..a9dccaa85fe4f 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -13824,6 +13824,9 @@ "type": "string", "x-go-name": "LatestCommentURL" }, + "state": { + "$ref": "#/definitions/StateType" + }, "title": { "type": "string", "x-go-name": "Title"