Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notification API should always return a JSON object with the current count of notifications #10059

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
BEAKING: check return status based on struct not httpStatus
  • Loading branch information
6543 committed Apr 9, 2020
commit 533f52a39dfbd568c7f0020e76d40586192ae56b
13 changes: 2 additions & 11 deletions routers/api/v1/notify/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ func NewAvailable(ctx *context.APIContext) {
// summary: Check if unread notifications exist
// responses:
// "200":
// "$ref": "#/responses/NotificationCount"
// "204":
// description: No unread notification

count := models.CountUnread(ctx.User)

if count > 0 {
ctx.JSON(http.StatusOK, api.NotificationCount{New: count})
} else {
ctx.Status(http.StatusNoContent)
}
// "$ref": "#/responses/NotificationCount"
ctx.JSON(http.StatusOK, api.NotificationCount{New: models.CountUnread(ctx.User)})
}
3 changes: 0 additions & 3 deletions templates/swagger/v1_json.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -530,9 +530,6 @@
"responses": {
"200": {
"$ref": "#/responses/NotificationCount"
},
"204": {
"description": "No unread notification"
}
}
}
Expand Down