1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-09-15 18:57:04 +00:00

Add API endpoint to update entry title and content

This commit is contained in:
Frédéric Guillot 2023-10-06 22:42:59 -07:00
parent 7b541af253
commit e4285c2cba
10 changed files with 182 additions and 33 deletions

View file

@ -12,7 +12,7 @@ import (
// ValidateEntriesStatusUpdateRequest validates a status update for a list of entries.
func ValidateEntriesStatusUpdateRequest(request *model.EntriesStatusUpdateRequest) error {
if len(request.EntryIDs) == 0 {
return fmt.Errorf(`The list of entries cannot be empty`)
return fmt.Errorf(`the list of entries cannot be empty`)
}
return ValidateEntryStatus(request.Status)
@ -25,7 +25,7 @@ func ValidateEntryStatus(status string) error {
return nil
}
return fmt.Errorf(`Invalid entry status, valid status values are: "%s", "%s" and "%s"`, model.EntryStatusRead, model.EntryStatusUnread, model.EntryStatusRemoved)
return fmt.Errorf(`invalid entry status, valid status values are: "%s", "%s" and "%s"`, model.EntryStatusRead, model.EntryStatusUnread, model.EntryStatusRemoved)
}
// ValidateEntryOrder makes sure the sorting order is valid.
@ -35,5 +35,18 @@ func ValidateEntryOrder(order string) error {
return nil
}
return fmt.Errorf(`Invalid entry order, valid order values are: "id", "status", "changed_at", "published_at", "created_at", "category_title", "category_id", "title", "author"`)
return fmt.Errorf(`invalid entry order, valid order values are: "id", "status", "changed_at", "published_at", "created_at", "category_title", "category_id", "title", "author"`)
}
// ValidateEntryModification makes sure the entry modification is valid.
func ValidateEntryModification(request *model.EntryUpdateRequest) error {
if request.Title != nil && *request.Title == "" {
return fmt.Errorf(`the entry title cannot be empty`)
}
if request.Content != nil && *request.Content == "" {
return fmt.Errorf(`the entry content cannot be empty`)
}
return nil
}