mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-17 23:42:52 +00:00
Notifications API: respond with updated notifications (#17064)
* notifications api: return updated notifications in response * make generate-swagger * openapi fix Co-authored-by: zeripath <art27@cantab.net>
This commit is contained in:
parent
ba2e600d17
commit
0ffad31b92
7 changed files with 37 additions and 23 deletions
|
@ -13,6 +13,7 @@ import (
|
|||
"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 {
|
||||
|
@ -176,7 +177,7 @@ func ReadRepoNotifications(ctx *context.APIContext) {
|
|||
// required: false
|
||||
// responses:
|
||||
// "205":
|
||||
// "$ref": "#/responses/empty"
|
||||
// "$ref": "#/responses/NotificationThreadList"
|
||||
|
||||
lastRead := int64(0)
|
||||
qLastRead := ctx.FormTrim("last_read_at")
|
||||
|
@ -213,14 +214,16 @@ func ReadRepoNotifications(ctx *context.APIContext) {
|
|||
targetStatus = models.NotificationStatusRead
|
||||
}
|
||||
|
||||
changed := make([]*structs.NotificationThread, len(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 {
|
||||
ctx.InternalServerError(err)
|
||||
return
|
||||
}
|
||||
ctx.Status(http.StatusResetContent)
|
||||
_ = notif.LoadAttributes()
|
||||
changed = append(changed, convert.ToNotificationThread(notif))
|
||||
}
|
||||
|
||||
ctx.Status(http.StatusResetContent)
|
||||
ctx.JSON(http.StatusResetContent, changed)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue