diff options
author | Norwin <noerw@users.noreply.github.com> | 2021-09-30 06:17:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-30 07:17:39 +0300 |
commit | 3bbdce26012d02d3b5082f8774ce432ad9c2990b (patch) | |
tree | b0a25803038e034af1c232a582dd5baed80c8696 /modules/convert/notification.go | |
parent | ac10c4ecc2364bc994cc649e27b7789da04730ba (diff) | |
download | gitea-3bbdce26012d02d3b5082f8774ce432ad9c2990b.tar.gz gitea-3bbdce26012d02d3b5082f8774ce432ad9c2990b.zip |
API: add html urls to notification subjects (#17178)
* API: add html urls to notification subjects
* add "Repository"
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'modules/convert/notification.go')
-rw-r--r-- | modules/convert/notification.go | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/modules/convert/notification.go b/modules/convert/notification.go index b0888ee09f..fae7be1257 100644 --- a/modules/convert/notification.go +++ b/modules/convert/notification.go @@ -31,10 +31,12 @@ func ToNotificationThread(n *models.Notification) *api.NotificationThread { if n.Issue != nil { result.Subject.Title = n.Issue.Title result.Subject.URL = n.Issue.APIURL() + result.Subject.HTMLURL = n.Issue.HTMLURL() result.Subject.State = n.Issue.State() comment, err := n.Issue.GetLastComment() if err == nil && comment != nil { result.Subject.LatestCommentURL = comment.APIURL() + result.Subject.LatestCommentHTMLURL = comment.HTMLURL() } } case models.NotificationSourcePullRequest: @@ -42,10 +44,12 @@ func ToNotificationThread(n *models.Notification) *api.NotificationThread { if n.Issue != nil { result.Subject.Title = n.Issue.Title result.Subject.URL = n.Issue.APIURL() + result.Subject.HTMLURL = n.Issue.HTMLURL() result.Subject.State = n.Issue.State() comment, err := n.Issue.GetLastComment() if err == nil && comment != nil { result.Subject.LatestCommentURL = comment.APIURL() + result.Subject.LatestCommentHTMLURL = comment.HTMLURL() } pr, _ := n.Issue.GetPullRequest() @@ -54,16 +58,20 @@ func ToNotificationThread(n *models.Notification) *api.NotificationThread { } } case models.NotificationSourceCommit: + url := n.Repository.HTMLURL() + "/commit/" + n.CommitID result.Subject = &api.NotificationSubject{ - Type: api.NotifySubjectCommit, - Title: n.CommitID, - URL: n.Repository.HTMLURL() + "/commit/" + n.CommitID, + Type: api.NotifySubjectCommit, + Title: n.CommitID, + URL: url, + HTMLURL: url, } case models.NotificationSourceRepository: result.Subject = &api.NotificationSubject{ Type: api.NotifySubjectRepository, Title: n.Repository.FullName(), - URL: n.Repository.Link(), + // FIXME: this is a relative URL, rather useless and inconsistent, but keeping for backwards compat + URL: n.Repository.Link(), + HTMLURL: n.Repository.HTMLURL(), } } |