mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-27 12:53:57 +01:00
Introduce NotifySubjectType (#16320)
* Introduce NotifySubjectType * update swagger docs
This commit is contained in:
parent
ce286f9d9c
commit
dfa18a8b1c
3 changed files with 29 additions and 11 deletions
|
@ -27,7 +27,7 @@ func ToNotificationThread(n *models.Notification) *api.NotificationThread {
|
||||||
//handle Subject
|
//handle Subject
|
||||||
switch n.Source {
|
switch n.Source {
|
||||||
case models.NotificationSourceIssue:
|
case models.NotificationSourceIssue:
|
||||||
result.Subject = &api.NotificationSubject{Type: "Issue"}
|
result.Subject = &api.NotificationSubject{Type: api.NotifySubjectIssue}
|
||||||
if n.Issue != nil {
|
if n.Issue != nil {
|
||||||
result.Subject.Title = n.Issue.Title
|
result.Subject.Title = n.Issue.Title
|
||||||
result.Subject.URL = n.Issue.APIURL()
|
result.Subject.URL = n.Issue.APIURL()
|
||||||
|
@ -38,7 +38,7 @@ func ToNotificationThread(n *models.Notification) *api.NotificationThread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case models.NotificationSourcePullRequest:
|
case models.NotificationSourcePullRequest:
|
||||||
result.Subject = &api.NotificationSubject{Type: "Pull"}
|
result.Subject = &api.NotificationSubject{Type: api.NotifySubjectPull}
|
||||||
if n.Issue != nil {
|
if n.Issue != nil {
|
||||||
result.Subject.Title = n.Issue.Title
|
result.Subject.Title = n.Issue.Title
|
||||||
result.Subject.URL = n.Issue.APIURL()
|
result.Subject.URL = n.Issue.APIURL()
|
||||||
|
@ -55,13 +55,13 @@ func ToNotificationThread(n *models.Notification) *api.NotificationThread {
|
||||||
}
|
}
|
||||||
case models.NotificationSourceCommit:
|
case models.NotificationSourceCommit:
|
||||||
result.Subject = &api.NotificationSubject{
|
result.Subject = &api.NotificationSubject{
|
||||||
Type: "Commit",
|
Type: api.NotifySubjectCommit,
|
||||||
Title: n.CommitID,
|
Title: n.CommitID,
|
||||||
URL: n.Repository.HTMLURL() + "/commit/" + n.CommitID,
|
URL: n.Repository.HTMLURL() + "/commit/" + n.CommitID,
|
||||||
}
|
}
|
||||||
case models.NotificationSourceRepository:
|
case models.NotificationSourceRepository:
|
||||||
result.Subject = &api.NotificationSubject{
|
result.Subject = &api.NotificationSubject{
|
||||||
Type: "Repository",
|
Type: api.NotifySubjectRepository,
|
||||||
Title: n.Repository.FullName(),
|
Title: n.Repository.FullName(),
|
||||||
URL: n.Repository.Link(),
|
URL: n.Repository.Link(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,14 +21,28 @@ type NotificationThread struct {
|
||||||
|
|
||||||
// NotificationSubject contains the notification subject (Issue/Pull/Commit)
|
// NotificationSubject contains the notification subject (Issue/Pull/Commit)
|
||||||
type NotificationSubject struct {
|
type NotificationSubject struct {
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
LatestCommentURL string `json:"latest_comment_url"`
|
LatestCommentURL string `json:"latest_comment_url"`
|
||||||
Type string `json:"type" binding:"In(Issue,Pull,Commit)"`
|
Type NotifySubjectType `json:"type" binding:"In(Issue,Pull,Commit)"`
|
||||||
State StateType `json:"state"`
|
State StateType `json:"state"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NotificationCount number of unread notifications
|
// NotificationCount number of unread notifications
|
||||||
type NotificationCount struct {
|
type NotificationCount struct {
|
||||||
New int64 `json:"new"`
|
New int64 `json:"new"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotifySubjectType represent type of notification subject
|
||||||
|
type NotifySubjectType string
|
||||||
|
|
||||||
|
const (
|
||||||
|
// NotifySubjectIssue an issue is subject of an notification
|
||||||
|
NotifySubjectIssue NotifySubjectType = "Issue"
|
||||||
|
// NotifySubjectPull an pull is subject of an notification
|
||||||
|
NotifySubjectPull NotifySubjectType = "Pull"
|
||||||
|
// NotifySubjectCommit an commit is subject of an notification
|
||||||
|
NotifySubjectCommit NotifySubjectType = "Commit"
|
||||||
|
// NotifySubjectRepository an repository is subject of an notification
|
||||||
|
NotifySubjectRepository NotifySubjectType = "Repository"
|
||||||
|
)
|
||||||
|
|
|
@ -15241,8 +15241,7 @@
|
||||||
"x-go-name": "Title"
|
"x-go-name": "Title"
|
||||||
},
|
},
|
||||||
"type": {
|
"type": {
|
||||||
"type": "string",
|
"$ref": "#/definitions/NotifySubjectType"
|
||||||
"x-go-name": "Type"
|
|
||||||
},
|
},
|
||||||
"url": {
|
"url": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
@ -15286,6 +15285,11 @@
|
||||||
},
|
},
|
||||||
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
||||||
},
|
},
|
||||||
|
"NotifySubjectType": {
|
||||||
|
"description": "NotifySubjectType represent type of notification subject",
|
||||||
|
"type": "string",
|
||||||
|
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
||||||
|
},
|
||||||
"OAuth2Application": {
|
"OAuth2Application": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"title": "OAuth2Application represents an OAuth2 application.",
|
"title": "OAuth2Application represents an OAuth2 application.",
|
||||||
|
|
Loading…
Reference in a new issue