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.go4
-rw-r--r--routers/api/v1/notify/repo.go12
-rw-r--r--routers/api/v1/notify/threads.go14
-rw-r--r--routers/api/v1/notify/user.go12
4 files changed, 21 insertions, 21 deletions
diff --git a/routers/api/v1/notify/notifications.go b/routers/api/v1/notify/notifications.go
index 46b3c7f5e7..4e4c7dc6dd 100644
--- a/routers/api/v1/notify/notifications.go
+++ b/routers/api/v1/notify/notifications.go
@@ -28,7 +28,7 @@ func NewAvailable(ctx *context.APIContext) {
Status: []activities_model.NotificationStatus{activities_model.NotificationStatusUnread},
})
if err != nil {
- ctx.Error(http.StatusUnprocessableEntity, "db.Count[activities_model.Notification]", err)
+ ctx.APIError(http.StatusUnprocessableEntity, err)
return
}
@@ -38,7 +38,7 @@ func NewAvailable(ctx *context.APIContext) {
func getFindNotificationOptions(ctx *context.APIContext) *activities_model.FindNotificationOptions {
before, since, err := context.GetQueryBeforeSince(ctx.Base)
if err != nil {
- ctx.Error(http.StatusUnprocessableEntity, "GetQueryBeforeSince", err)
+ ctx.APIError(http.StatusUnprocessableEntity, err)
return nil
}
opts := &activities_model.FindNotificationOptions{
diff --git a/routers/api/v1/notify/repo.go b/routers/api/v1/notify/repo.go
index 1744426ee8..e87054e26c 100644
--- a/routers/api/v1/notify/repo.go
+++ b/routers/api/v1/notify/repo.go
@@ -110,18 +110,18 @@ func ListRepoNotifications(ctx *context.APIContext) {
totalCount, err := db.Count[activities_model.Notification](ctx, opts)
if err != nil {
- ctx.InternalServerError(err)
+ ctx.APIErrorInternal(err)
return
}
nl, err := db.Find[activities_model.Notification](ctx, opts)
if err != nil {
- ctx.InternalServerError(err)
+ ctx.APIErrorInternal(err)
return
}
err = activities_model.NotificationList(nl).LoadAttributes(ctx)
if err != nil {
- ctx.InternalServerError(err)
+ ctx.APIErrorInternal(err)
return
}
@@ -183,7 +183,7 @@ func ReadRepoNotifications(ctx *context.APIContext) {
if len(qLastRead) > 0 {
tmpLastRead, err := time.Parse(time.RFC3339, qLastRead)
if err != nil {
- ctx.Error(http.StatusBadRequest, "Parse", err)
+ ctx.APIError(http.StatusBadRequest, err)
return
}
if !tmpLastRead.IsZero() {
@@ -203,7 +203,7 @@ func ReadRepoNotifications(ctx *context.APIContext) {
}
nl, err := db.Find[activities_model.Notification](ctx, opts)
if err != nil {
- ctx.InternalServerError(err)
+ ctx.APIErrorInternal(err)
return
}
@@ -217,7 +217,7 @@ func ReadRepoNotifications(ctx *context.APIContext) {
for _, n := range nl {
notif, err := activities_model.SetNotificationStatus(ctx, n.ID, ctx.Doer, targetStatus)
if err != nil {
- ctx.InternalServerError(err)
+ ctx.APIErrorInternal(err)
return
}
_ = notif.LoadAttributes(ctx)
diff --git a/routers/api/v1/notify/threads.go b/routers/api/v1/notify/threads.go
index 0761e684a3..dd77e4aae4 100644
--- a/routers/api/v1/notify/threads.go
+++ b/routers/api/v1/notify/threads.go
@@ -42,7 +42,7 @@ func GetThread(ctx *context.APIContext) {
return
}
if err := n.LoadAttributes(ctx); err != nil && !issues_model.IsErrCommentNotExist(err) {
- ctx.InternalServerError(err)
+ ctx.APIErrorInternal(err)
return
}
@@ -90,28 +90,28 @@ func ReadThread(ctx *context.APIContext) {
notif, err := activities_model.SetNotificationStatus(ctx, n.ID, ctx.Doer, targetStatus)
if err != nil {
- ctx.InternalServerError(err)
+ ctx.APIErrorInternal(err)
return
}
if err = notif.LoadAttributes(ctx); err != nil && !issues_model.IsErrCommentNotExist(err) {
- ctx.InternalServerError(err)
+ ctx.APIErrorInternal(err)
return
}
ctx.JSON(http.StatusResetContent, convert.ToNotificationThread(ctx, notif))
}
func getThread(ctx *context.APIContext) *activities_model.Notification {
- n, err := activities_model.GetNotificationByID(ctx, ctx.PathParamInt64(":id"))
+ n, err := activities_model.GetNotificationByID(ctx, ctx.PathParamInt64("id"))
if err != nil {
if db.IsErrNotExist(err) {
- ctx.Error(http.StatusNotFound, "GetNotificationByID", err)
+ ctx.APIError(http.StatusNotFound, err)
} else {
- ctx.InternalServerError(err)
+ ctx.APIErrorInternal(err)
}
return nil
}
if n.UserID != ctx.Doer.ID && !ctx.Doer.IsAdmin {
- ctx.Error(http.StatusForbidden, "GetNotificationByID", fmt.Errorf("only user itself and admin are allowed to read/change this thread %d", n.ID))
+ ctx.APIError(http.StatusForbidden, fmt.Errorf("only user itself and admin are allowed to read/change this thread %d", n.ID))
return nil
}
return n
diff --git a/routers/api/v1/notify/user.go b/routers/api/v1/notify/user.go
index 879f484cce..3ebb678835 100644
--- a/routers/api/v1/notify/user.go
+++ b/routers/api/v1/notify/user.go
@@ -71,18 +71,18 @@ func ListNotifications(ctx *context.APIContext) {
totalCount, err := db.Count[activities_model.Notification](ctx, opts)
if err != nil {
- ctx.InternalServerError(err)
+ ctx.APIErrorInternal(err)
return
}
nl, err := db.Find[activities_model.Notification](ctx, opts)
if err != nil {
- ctx.InternalServerError(err)
+ ctx.APIErrorInternal(err)
return
}
err = activities_model.NotificationList(nl).LoadAttributes(ctx)
if err != nil {
- ctx.InternalServerError(err)
+ ctx.APIErrorInternal(err)
return
}
@@ -133,7 +133,7 @@ func ReadNotifications(ctx *context.APIContext) {
if len(qLastRead) > 0 {
tmpLastRead, err := time.Parse(time.RFC3339, qLastRead)
if err != nil {
- ctx.Error(http.StatusBadRequest, "Parse", err)
+ ctx.APIError(http.StatusBadRequest, err)
return
}
if !tmpLastRead.IsZero() {
@@ -150,7 +150,7 @@ func ReadNotifications(ctx *context.APIContext) {
}
nl, err := db.Find[activities_model.Notification](ctx, opts)
if err != nil {
- ctx.InternalServerError(err)
+ ctx.APIErrorInternal(err)
return
}
@@ -164,7 +164,7 @@ func ReadNotifications(ctx *context.APIContext) {
for _, n := range nl {
notif, err := activities_model.SetNotificationStatus(ctx, n.ID, ctx.Doer, targetStatus)
if err != nil {
- ctx.InternalServerError(err)
+ ctx.APIErrorInternal(err)
return
}
_ = notif.LoadAttributes(ctx)