forked from forgejo/forgejo
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>
This commit is contained in:
parent
4a4bfafa23
commit
1d8543e7db
154 changed files with 1763 additions and 1738 deletions
|
@ -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))
|
||||
|
|
|
@ -5,13 +5,12 @@
|
|||
package convert
|
||||
|
||||
import (
|
||||
"code.gitea.io/gitea/models"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
// ToRelease convert a models.Release to api.Release
|
||||
func ToRelease(r *models.Release) *api.Release {
|
||||
// ToRelease convert a repo_model.Release to api.Release
|
||||
func ToRelease(r *repo_model.Release) *api.Release {
|
||||
assets := make([]*api.Attachment, 0)
|
||||
for _, att := range r.Attachments {
|
||||
assets = append(assets, ToReleaseAttachment(att))
|
||||
|
|
|
@ -102,7 +102,7 @@ func innerToRepo(repo *repo_model.Repository, mode perm.AccessMode, isParent boo
|
|||
return nil
|
||||
}
|
||||
|
||||
numReleases, _ := models.GetReleaseCountByRepoID(repo.ID, models.FindReleasesOptions{IncludeDrafts: false, IncludeTags: false})
|
||||
numReleases, _ := repo_model.GetReleaseCountByRepoID(repo.ID, repo_model.FindReleasesOptions{IncludeDrafts: false, IncludeTags: false})
|
||||
|
||||
mirrorInterval := ""
|
||||
var mirrorUpdated time.Time
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue