mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-21 17:24:10 +00:00
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
|
@ -12,7 +12,7 @@ import (
|
|||
"net/url"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
activities_model "code.gitea.io/gitea/models/activities"
|
||||
"code.gitea.io/gitea/modules/base"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
|
@ -36,7 +36,7 @@ func GetNotificationCount(c *context.Context) {
|
|||
}
|
||||
|
||||
c.Data["NotificationUnreadCount"] = func() int64 {
|
||||
count, err := models.GetNotificationCount(c, c.Doer, models.NotificationStatusUnread)
|
||||
count, err := activities_model.GetNotificationCount(c, c.Doer, activities_model.NotificationStatusUnread)
|
||||
if err != nil {
|
||||
if err != goctx.Canceled {
|
||||
log.Error("Unable to GetNotificationCount for user:%-v: %v", c.Doer, err)
|
||||
|
@ -65,7 +65,7 @@ func Notifications(c *context.Context) {
|
|||
func getNotifications(c *context.Context) {
|
||||
var (
|
||||
keyword = c.FormTrim("q")
|
||||
status models.NotificationStatus
|
||||
status activities_model.NotificationStatus
|
||||
page = c.FormInt("page")
|
||||
perPage = c.FormInt("perPage")
|
||||
)
|
||||
|
@ -78,12 +78,12 @@ func getNotifications(c *context.Context) {
|
|||
|
||||
switch keyword {
|
||||
case "read":
|
||||
status = models.NotificationStatusRead
|
||||
status = activities_model.NotificationStatusRead
|
||||
default:
|
||||
status = models.NotificationStatusUnread
|
||||
status = activities_model.NotificationStatusUnread
|
||||
}
|
||||
|
||||
total, err := models.GetNotificationCount(c, c.Doer, status)
|
||||
total, err := activities_model.GetNotificationCount(c, c.Doer, status)
|
||||
if err != nil {
|
||||
c.ServerError("ErrGetNotificationCount", err)
|
||||
return
|
||||
|
@ -96,8 +96,8 @@ func getNotifications(c *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
statuses := []models.NotificationStatus{status, models.NotificationStatusPinned}
|
||||
notifications, err := models.NotificationsForUser(c, c.Doer, statuses, page, perPage)
|
||||
statuses := []activities_model.NotificationStatus{status, activities_model.NotificationStatusPinned}
|
||||
notifications, err := activities_model.NotificationsForUser(c, c.Doer, statuses, page, perPage)
|
||||
if err != nil {
|
||||
c.ServerError("ErrNotificationsForUser", err)
|
||||
return
|
||||
|
@ -151,22 +151,22 @@ func NotificationStatusPost(c *context.Context) {
|
|||
var (
|
||||
notificationID = c.FormInt64("notification_id")
|
||||
statusStr = c.FormString("status")
|
||||
status models.NotificationStatus
|
||||
status activities_model.NotificationStatus
|
||||
)
|
||||
|
||||
switch statusStr {
|
||||
case "read":
|
||||
status = models.NotificationStatusRead
|
||||
status = activities_model.NotificationStatusRead
|
||||
case "unread":
|
||||
status = models.NotificationStatusUnread
|
||||
status = activities_model.NotificationStatusUnread
|
||||
case "pinned":
|
||||
status = models.NotificationStatusPinned
|
||||
status = activities_model.NotificationStatusPinned
|
||||
default:
|
||||
c.ServerError("InvalidNotificationStatus", errors.New("Invalid notification status"))
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := models.SetNotificationStatus(notificationID, c.Doer, status); err != nil {
|
||||
if _, err := activities_model.SetNotificationStatus(notificationID, c.Doer, status); err != nil {
|
||||
c.ServerError("SetNotificationStatus", err)
|
||||
return
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ func NotificationStatusPost(c *context.Context) {
|
|||
|
||||
// NotificationPurgePost is a route for 'purging' the list of notifications - marking all unread as read
|
||||
func NotificationPurgePost(c *context.Context) {
|
||||
err := models.UpdateNotificationStatuses(c.Doer, models.NotificationStatusUnread, models.NotificationStatusRead)
|
||||
err := activities_model.UpdateNotificationStatuses(c.Doer, activities_model.NotificationStatusUnread, activities_model.NotificationStatusRead)
|
||||
if err != nil {
|
||||
c.ServerError("ErrUpdateNotificationStatuses", err)
|
||||
return
|
||||
|
@ -199,5 +199,5 @@ func NotificationPurgePost(c *context.Context) {
|
|||
|
||||
// NewAvailable returns the notification counts
|
||||
func NewAvailable(ctx *context.Context) {
|
||||
ctx.JSON(http.StatusOK, structs.NotificationCount{New: models.CountUnread(ctx, ctx.Doer.ID)})
|
||||
ctx.JSON(http.StatusOK, structs.NotificationCount{New: activities_model.CountUnread(ctx, ctx.Doer.ID)})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue