|
|
@ -11,6 +11,7 @@ import ( |
|
|
|
"code.gitea.io/gitea/models" |
|
|
|
"code.gitea.io/gitea/models" |
|
|
|
"code.gitea.io/gitea/modules/context" |
|
|
|
"code.gitea.io/gitea/modules/context" |
|
|
|
"code.gitea.io/gitea/modules/convert" |
|
|
|
"code.gitea.io/gitea/modules/convert" |
|
|
|
|
|
|
|
"code.gitea.io/gitea/modules/structs" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// ListNotifications list users's notification threads
|
|
|
|
// ListNotifications list users's notification threads
|
|
|
@ -125,7 +126,7 @@ func ReadNotifications(ctx *context.APIContext) { |
|
|
|
// required: false
|
|
|
|
// required: false
|
|
|
|
// responses:
|
|
|
|
// responses:
|
|
|
|
// "205":
|
|
|
|
// "205":
|
|
|
|
// "$ref": "#/responses/empty"
|
|
|
|
// "$ref": "#/responses/NotificationThreadList"
|
|
|
|
|
|
|
|
|
|
|
|
lastRead := int64(0) |
|
|
|
lastRead := int64(0) |
|
|
|
qLastRead := ctx.FormTrim("last_read_at") |
|
|
|
qLastRead := ctx.FormTrim("last_read_at") |
|
|
@ -158,14 +159,17 @@ func ReadNotifications(ctx *context.APIContext) { |
|
|
|
targetStatus = models.NotificationStatusRead |
|
|
|
targetStatus = models.NotificationStatusRead |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
changed := make([]*structs.NotificationThread, 0, len(nl)) |
|
|
|
|
|
|
|
|
|
|
|
for _, n := range nl { |
|
|
|
for _, n := range nl { |
|
|
|
err := models.SetNotificationStatus(n.ID, ctx.User, targetStatus) |
|
|
|
notif, err := models.SetNotificationStatus(n.ID, ctx.User, targetStatus) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
ctx.InternalServerError(err) |
|
|
|
ctx.InternalServerError(err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
ctx.Status(http.StatusResetContent) |
|
|
|
_ = notif.LoadAttributes() |
|
|
|
|
|
|
|
changed = append(changed, convert.ToNotificationThread(notif)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ctx.Status(http.StatusResetContent) |
|
|
|
ctx.JSON(http.StatusResetContent, changed) |
|
|
|
} |
|
|
|
} |
|
|
|