You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

notifications.go 847B

123456789101112131415161718192021222324252627282930313233
  1. // Copyright 2020 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package notify
  5. import (
  6. "net/http"
  7. "code.gitea.io/gitea/models"
  8. "code.gitea.io/gitea/modules/context"
  9. api "code.gitea.io/gitea/modules/structs"
  10. )
  11. // NewAvailable check if unread notifications exist
  12. func NewAvailable(ctx *context.APIContext) {
  13. // swagger:operation GET /notifications/new notification notifyNewAvailable
  14. // ---
  15. // summary: Check if unread notifications exist
  16. // responses:
  17. // "200":
  18. // "$ref": "#/responses/NotificationCount"
  19. // "204":
  20. // description: No unread notification
  21. count := models.CountUnread(ctx.User)
  22. if count > 0 {
  23. ctx.JSON(http.StatusOK, api.NotificationCount{New: count})
  24. } else {
  25. ctx.Status(http.StatusNoContent)
  26. }
  27. }