2023-06-19 14:42:47 -07:00
|
|
|
// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
2017-11-19 21:10:04 -08:00
|
|
|
|
2023-08-10 19:46:45 -07:00
|
|
|
package model // import "miniflux.app/v2/internal/model"
|
2017-11-19 21:10:04 -08:00
|
|
|
|
2021-01-03 22:28:04 -08:00
|
|
|
import "fmt"
|
2017-11-19 21:10:04 -08:00
|
|
|
|
2021-01-03 22:28:04 -08:00
|
|
|
// Category represents a feed category.
|
2017-11-19 21:10:04 -08:00
|
|
|
type Category struct {
|
2021-06-03 02:39:47 +02:00
|
|
|
ID int64 `json:"id"`
|
|
|
|
Title string `json:"title"`
|
|
|
|
UserID int64 `json:"user_id"`
|
|
|
|
HideGlobally bool `json:"hide_globally"`
|
2023-06-19 09:50:08 -07:00
|
|
|
FeedCount *int `json:"feed_count,omitempty"`
|
|
|
|
TotalUnread *int `json:"total_unread,omitempty"`
|
2017-11-19 21:10:04 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Category) String() string {
|
|
|
|
return fmt.Sprintf("ID=%d, UserID=%d, Title=%s", c.ID, c.UserID, c.Title)
|
|
|
|
}
|
|
|
|
|
2025-04-21 18:45:30 -07:00
|
|
|
type CategoryCreationRequest struct {
|
2021-06-03 02:39:47 +02:00
|
|
|
Title string `json:"title"`
|
2025-04-21 18:45:30 -07:00
|
|
|
HideGlobally bool `json:"hide_globally"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type CategoryModificationRequest struct {
|
|
|
|
Title *string `json:"title"`
|
|
|
|
HideGlobally *bool `json:"hide_globally"`
|
2017-11-19 21:10:04 -08:00
|
|
|
}
|
|
|
|
|
2025-04-21 18:45:30 -07:00
|
|
|
func (c *CategoryModificationRequest) Patch(category *Category) {
|
|
|
|
if c.Title != nil {
|
|
|
|
category.Title = *c.Title
|
|
|
|
}
|
|
|
|
|
|
|
|
if c.HideGlobally != nil {
|
|
|
|
category.HideGlobally = *c.HideGlobally
|
|
|
|
}
|
2017-11-19 21:10:04 -08:00
|
|
|
}
|
|
|
|
|
2017-11-25 19:06:02 -08:00
|
|
|
// Categories represents a list of categories.
|
2017-11-19 21:10:04 -08:00
|
|
|
type Categories []*Category
|