From 1d8543e7db58d7c4973758e47f005c4d8bd7d7a3 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 25 Aug 2022 10:31:57 +0800 Subject: Move some files into models' sub packages (#20262) * Move some files into models' sub packages * Move functions * merge main branch * Fix check * fix check * Fix some tests * Fix lint * Fix lint * Revert lint changes * Fix error comments * Fix lint Co-authored-by: 6543 <6543@obermui.de> --- modules/convert/notification.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'modules/convert/notification.go') diff --git a/modules/convert/notification.go b/modules/convert/notification.go index 1efba5745c..55f782f8f6 100644 --- a/modules/convert/notification.go +++ b/modules/convert/notification.go @@ -7,17 +7,17 @@ package convert import ( "net/url" - "code.gitea.io/gitea/models" + activities_model "code.gitea.io/gitea/models/activities" "code.gitea.io/gitea/models/perm" api "code.gitea.io/gitea/modules/structs" ) // ToNotificationThread convert a Notification to api.NotificationThread -func ToNotificationThread(n *models.Notification) *api.NotificationThread { +func ToNotificationThread(n *activities_model.Notification) *api.NotificationThread { result := &api.NotificationThread{ ID: n.ID, - Unread: !(n.Status == models.NotificationStatusRead || n.Status == models.NotificationStatusPinned), - Pinned: n.Status == models.NotificationStatusPinned, + Unread: !(n.Status == activities_model.NotificationStatusRead || n.Status == activities_model.NotificationStatusPinned), + Pinned: n.Status == activities_model.NotificationStatusPinned, UpdatedAt: n.UpdatedUnix.AsTime(), URL: n.APIURL(), } @@ -34,7 +34,7 @@ func ToNotificationThread(n *models.Notification) *api.NotificationThread { // handle Subject switch n.Source { - case models.NotificationSourceIssue: + case activities_model.NotificationSourceIssue: result.Subject = &api.NotificationSubject{Type: api.NotifySubjectIssue} if n.Issue != nil { result.Subject.Title = n.Issue.Title @@ -47,7 +47,7 @@ func ToNotificationThread(n *models.Notification) *api.NotificationThread { result.Subject.LatestCommentHTMLURL = comment.HTMLURL() } } - case models.NotificationSourcePullRequest: + case activities_model.NotificationSourcePullRequest: result.Subject = &api.NotificationSubject{Type: api.NotifySubjectPull} if n.Issue != nil { result.Subject.Title = n.Issue.Title @@ -65,7 +65,7 @@ func ToNotificationThread(n *models.Notification) *api.NotificationThread { result.Subject.State = "merged" } } - case models.NotificationSourceCommit: + case activities_model.NotificationSourceCommit: url := n.Repository.HTMLURL() + "/commit/" + url.PathEscape(n.CommitID) result.Subject = &api.NotificationSubject{ Type: api.NotifySubjectCommit, @@ -73,7 +73,7 @@ func ToNotificationThread(n *models.Notification) *api.NotificationThread { URL: url, HTMLURL: url, } - case models.NotificationSourceRepository: + case activities_model.NotificationSourceRepository: result.Subject = &api.NotificationSubject{ Type: api.NotifySubjectRepository, Title: n.Repository.FullName(), @@ -87,7 +87,7 @@ func ToNotificationThread(n *models.Notification) *api.NotificationThread { } // ToNotifications convert list of Notification to api.NotificationThread list -func ToNotifications(nl models.NotificationList) []*api.NotificationThread { +func ToNotifications(nl activities_model.NotificationList) []*api.NotificationThread { result := make([]*api.NotificationThread, 0, len(nl)) for _, n := range nl { result = append(result, ToNotificationThread(n)) -- cgit v1.2.3