category.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
  2. // SPDX-License-Identifier: Apache-2.0
  3. package model // import "miniflux.app/v2/internal/model"
  4. import "fmt"
  5. // Category represents a feed category.
  6. type Category struct {
  7. ID int64 `json:"id"`
  8. Title string `json:"title"`
  9. UserID int64 `json:"user_id"`
  10. HideGlobally bool `json:"hide_globally"`
  11. FeedCount *int `json:"feed_count,omitempty"`
  12. TotalUnread *int `json:"total_unread,omitempty"`
  13. }
  14. func (c *Category) String() string {
  15. return fmt.Sprintf("ID=%d, UserID=%d, Title=%s", c.ID, c.UserID, c.Title)
  16. }
  17. type CategoryCreationRequest struct {
  18. Title string `json:"title"`
  19. HideGlobally bool `json:"hide_globally"`
  20. }
  21. type CategoryModificationRequest struct {
  22. Title *string `json:"title"`
  23. HideGlobally *bool `json:"hide_globally"`
  24. }
  25. func (c *CategoryModificationRequest) Patch(category *Category) {
  26. if c.Title != nil {
  27. category.Title = *c.Title
  28. }
  29. if c.HideGlobally != nil {
  30. category.HideGlobally = *c.HideGlobally
  31. }
  32. }
  33. // Categories represents a list of categories.
  34. type Categories []*Category