category.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. // Pointers are needed to avoid breaking /v1/categories?counts=true
  12. FeedCount *int `json:"feed_count,omitempty"`
  13. TotalUnread *int `json:"total_unread,omitempty"`
  14. }
  15. func (c *Category) String() string {
  16. return fmt.Sprintf("ID=%d, UserID=%d, Title=%s", c.ID, c.UserID, c.Title)
  17. }
  18. type CategoryCreationRequest struct {
  19. Title string `json:"title"`
  20. HideGlobally bool `json:"hide_globally"`
  21. }
  22. type CategoryModificationRequest struct {
  23. Title *string `json:"title"`
  24. HideGlobally *bool `json:"hide_globally"`
  25. }
  26. func (c *CategoryModificationRequest) Patch(category *Category) {
  27. if c.Title != nil {
  28. category.Title = *c.Title
  29. }
  30. if c.HideGlobally != nil {
  31. category.HideGlobally = *c.HideGlobally
  32. }
  33. }
  34. // Categories represents a list of categories.
  35. type Categories []Category