aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/v1/notify
diff options
context:
space:
mode:
Diffstat (limited to 'routers/api/v1/notify')
-rw-r--r--routers/api/v1/notify/notifications.go18
-rw-r--r--routers/api/v1/notify/repo.go26
-rw-r--r--routers/api/v1/notify/threads.go10
-rw-r--r--routers/api/v1/notify/user.go14
4 files changed, 34 insertions, 34 deletions
diff --git a/routers/api/v1/notify/notifications.go b/routers/api/v1/notify/notifications.go
index 44cb4ae769..9948f90a12 100644
--- a/routers/api/v1/notify/notifications.go
+++ b/routers/api/v1/notify/notifications.go
@@ -8,7 +8,7 @@ import (
"net/http"
"strings"
- "code.gitea.io/gitea/models"
+ activities_model "code.gitea.io/gitea/models/activities"
"code.gitea.io/gitea/modules/context"
api "code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/routers/api/v1/utils"
@@ -22,16 +22,16 @@ func NewAvailable(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/NotificationCount"
- ctx.JSON(http.StatusOK, api.NotificationCount{New: models.CountUnread(ctx, ctx.Doer.ID)})
+ ctx.JSON(http.StatusOK, api.NotificationCount{New: activities_model.CountUnread(ctx, ctx.Doer.ID)})
}
-func getFindNotificationOptions(ctx *context.APIContext) *models.FindNotificationOptions {
+func getFindNotificationOptions(ctx *context.APIContext) *activities_model.FindNotificationOptions {
before, since, err := context.GetQueryBeforeSince(ctx.Context)
if err != nil {
ctx.Error(http.StatusUnprocessableEntity, "GetQueryBeforeSince", err)
return nil
}
- opts := &models.FindNotificationOptions{
+ opts := &activities_model.FindNotificationOptions{
ListOptions: utils.GetListOptions(ctx),
UserID: ctx.Doer.ID,
UpdatedBeforeUnix: before,
@@ -50,17 +50,17 @@ func getFindNotificationOptions(ctx *context.APIContext) *models.FindNotificatio
return opts
}
-func subjectToSource(value []string) (result []models.NotificationSource) {
+func subjectToSource(value []string) (result []activities_model.NotificationSource) {
for _, v := range value {
switch strings.ToLower(v) {
case "issue":
- result = append(result, models.NotificationSourceIssue)
+ result = append(result, activities_model.NotificationSourceIssue)
case "pull":
- result = append(result, models.NotificationSourcePullRequest)
+ result = append(result, activities_model.NotificationSourcePullRequest)
case "commit":
- result = append(result, models.NotificationSourceCommit)
+ result = append(result, activities_model.NotificationSourceCommit)
case "repository":
- result = append(result, models.NotificationSourceRepository)
+ result = append(result, activities_model.NotificationSourceRepository)
}
}
return result
diff --git a/routers/api/v1/notify/repo.go b/routers/api/v1/notify/repo.go
index 4e9dd806de..f8e1fb0865 100644
--- a/routers/api/v1/notify/repo.go
+++ b/routers/api/v1/notify/repo.go
@@ -9,31 +9,31 @@ import (
"strings"
"time"
- "code.gitea.io/gitea/models"
+ activities_model "code.gitea.io/gitea/models/activities"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/convert"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/structs"
)
-func statusStringToNotificationStatus(status string) models.NotificationStatus {
+func statusStringToNotificationStatus(status string) activities_model.NotificationStatus {
switch strings.ToLower(strings.TrimSpace(status)) {
case "unread":
- return models.NotificationStatusUnread
+ return activities_model.NotificationStatusUnread
case "read":
- return models.NotificationStatusRead
+ return activities_model.NotificationStatusRead
case "pinned":
- return models.NotificationStatusPinned
+ return activities_model.NotificationStatusPinned
default:
return 0
}
}
-func statusStringsToNotificationStatuses(statuses, defaultStatuses []string) []models.NotificationStatus {
+func statusStringsToNotificationStatuses(statuses, defaultStatuses []string) []activities_model.NotificationStatus {
if len(statuses) == 0 {
statuses = defaultStatuses
}
- results := make([]models.NotificationStatus, 0, len(statuses))
+ results := make([]activities_model.NotificationStatus, 0, len(statuses))
for _, status := range statuses {
notificationStatus := statusStringToNotificationStatus(status)
if notificationStatus > 0 {
@@ -109,13 +109,13 @@ func ListRepoNotifications(ctx *context.APIContext) {
}
opts.RepoID = ctx.Repo.Repository.ID
- totalCount, err := models.CountNotifications(opts)
+ totalCount, err := activities_model.CountNotifications(opts)
if err != nil {
ctx.InternalServerError(err)
return
}
- nl, err := models.GetNotifications(ctx, opts)
+ nl, err := activities_model.GetNotifications(ctx, opts)
if err != nil {
ctx.InternalServerError(err)
return
@@ -192,7 +192,7 @@ func ReadRepoNotifications(ctx *context.APIContext) {
}
}
- opts := &models.FindNotificationOptions{
+ opts := &activities_model.FindNotificationOptions{
UserID: ctx.Doer.ID,
RepoID: ctx.Repo.Repository.ID,
UpdatedBeforeUnix: lastRead,
@@ -203,7 +203,7 @@ func ReadRepoNotifications(ctx *context.APIContext) {
opts.Status = statusStringsToNotificationStatuses(statuses, []string{"unread"})
log.Error("%v", opts.Status)
}
- nl, err := models.GetNotifications(ctx, opts)
+ nl, err := activities_model.GetNotifications(ctx, opts)
if err != nil {
ctx.InternalServerError(err)
return
@@ -211,13 +211,13 @@ func ReadRepoNotifications(ctx *context.APIContext) {
targetStatus := statusStringToNotificationStatus(ctx.FormString("to-status"))
if targetStatus == 0 {
- targetStatus = models.NotificationStatusRead
+ targetStatus = activities_model.NotificationStatusRead
}
changed := make([]*structs.NotificationThread, 0, len(nl))
for _, n := range nl {
- notif, err := models.SetNotificationStatus(n.ID, ctx.Doer, targetStatus)
+ notif, err := activities_model.SetNotificationStatus(n.ID, ctx.Doer, targetStatus)
if err != nil {
ctx.InternalServerError(err)
return
diff --git a/routers/api/v1/notify/threads.go b/routers/api/v1/notify/threads.go
index 7d8d34504f..44a1d30a55 100644
--- a/routers/api/v1/notify/threads.go
+++ b/routers/api/v1/notify/threads.go
@@ -8,7 +8,7 @@ import (
"fmt"
"net/http"
- "code.gitea.io/gitea/models"
+ activities_model "code.gitea.io/gitea/models/activities"
"code.gitea.io/gitea/models/db"
issues_model "code.gitea.io/gitea/models/issues"
"code.gitea.io/gitea/modules/context"
@@ -86,10 +86,10 @@ func ReadThread(ctx *context.APIContext) {
targetStatus := statusStringToNotificationStatus(ctx.FormString("to-status"))
if targetStatus == 0 {
- targetStatus = models.NotificationStatusRead
+ targetStatus = activities_model.NotificationStatusRead
}
- notif, err := models.SetNotificationStatus(n.ID, ctx.Doer, targetStatus)
+ notif, err := activities_model.SetNotificationStatus(n.ID, ctx.Doer, targetStatus)
if err != nil {
ctx.InternalServerError(err)
return
@@ -101,8 +101,8 @@ func ReadThread(ctx *context.APIContext) {
ctx.JSON(http.StatusResetContent, convert.ToNotificationThread(notif))
}
-func getThread(ctx *context.APIContext) *models.Notification {
- n, err := models.GetNotificationByID(ctx.ParamsInt64(":id"))
+func getThread(ctx *context.APIContext) *activities_model.Notification {
+ n, err := activities_model.GetNotificationByID(ctx.ParamsInt64(":id"))
if err != nil {
if db.IsErrNotExist(err) {
ctx.Error(http.StatusNotFound, "GetNotificationByID", err)
diff --git a/routers/api/v1/notify/user.go b/routers/api/v1/notify/user.go
index b923307783..1b6706e16f 100644
--- a/routers/api/v1/notify/user.go
+++ b/routers/api/v1/notify/user.go
@@ -8,7 +8,7 @@ import (
"net/http"
"time"
- "code.gitea.io/gitea/models"
+ activities_model "code.gitea.io/gitea/models/activities"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/convert"
"code.gitea.io/gitea/modules/structs"
@@ -69,13 +69,13 @@ func ListNotifications(ctx *context.APIContext) {
return
}
- totalCount, err := models.CountNotifications(opts)
+ totalCount, err := activities_model.CountNotifications(opts)
if err != nil {
ctx.InternalServerError(err)
return
}
- nl, err := models.GetNotifications(ctx, opts)
+ nl, err := activities_model.GetNotifications(ctx, opts)
if err != nil {
ctx.InternalServerError(err)
return
@@ -140,7 +140,7 @@ func ReadNotifications(ctx *context.APIContext) {
lastRead = tmpLastRead.Unix()
}
}
- opts := &models.FindNotificationOptions{
+ opts := &activities_model.FindNotificationOptions{
UserID: ctx.Doer.ID,
UpdatedBeforeUnix: lastRead,
}
@@ -148,7 +148,7 @@ func ReadNotifications(ctx *context.APIContext) {
statuses := ctx.FormStrings("status-types")
opts.Status = statusStringsToNotificationStatuses(statuses, []string{"unread"})
}
- nl, err := models.GetNotifications(ctx, opts)
+ nl, err := activities_model.GetNotifications(ctx, opts)
if err != nil {
ctx.InternalServerError(err)
return
@@ -156,13 +156,13 @@ func ReadNotifications(ctx *context.APIContext) {
targetStatus := statusStringToNotificationStatus(ctx.FormString("to-status"))
if targetStatus == 0 {
- targetStatus = models.NotificationStatusRead
+ targetStatus = activities_model.NotificationStatusRead
}
changed := make([]*structs.NotificationThread, 0, len(nl))
for _, n := range nl {
- notif, err := models.SetNotificationStatus(n.ID, ctx.Doer, targetStatus)
+ notif, err := activities_model.SetNotificationStatus(n.ID, ctx.Doer, targetStatus)
if err != nil {
ctx.InternalServerError(err)
return