mirror of
https://github.com/miniflux/v2.git
synced 2025-08-26 18:21:01 +00:00
fix(api): hide_globally
categories field should be a boolean
This commit is contained in:
parent
764212f37c
commit
d33e305af9
16 changed files with 262 additions and 70 deletions
|
@ -19,16 +19,24 @@ func (c *Category) String() string {
|
|||
return fmt.Sprintf("ID=%d, UserID=%d, Title=%s", c.ID, c.UserID, c.Title)
|
||||
}
|
||||
|
||||
// CategoryRequest represents the request to create or update a category.
|
||||
type CategoryRequest struct {
|
||||
type CategoryCreationRequest struct {
|
||||
Title string `json:"title"`
|
||||
HideGlobally string `json:"hide_globally"`
|
||||
HideGlobally bool `json:"hide_globally"`
|
||||
}
|
||||
|
||||
// Patch updates category fields.
|
||||
func (cr *CategoryRequest) Patch(category *Category) {
|
||||
category.Title = cr.Title
|
||||
category.HideGlobally = cr.HideGlobally != ""
|
||||
type CategoryModificationRequest struct {
|
||||
Title *string `json:"title"`
|
||||
HideGlobally *bool `json:"hide_globally"`
|
||||
}
|
||||
|
||||
func (c *CategoryModificationRequest) Patch(category *Category) {
|
||||
if c.Title != nil {
|
||||
category.Title = *c.Title
|
||||
}
|
||||
|
||||
if c.HideGlobally != nil {
|
||||
category.HideGlobally = *c.HideGlobally
|
||||
}
|
||||
}
|
||||
|
||||
// Categories represents a list of categories.
|
||||
|
|
|
@ -20,3 +20,7 @@ func OptionalString(value string) *string {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func SetOptionalField[T any](value T) *T {
|
||||
return &value
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue