1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-06 17:41:00 +00:00

Refactor category validation

This commit is contained in:
Frédéric Guillot 2021-01-03 22:28:04 -08:00 committed by fguillot
parent e45cc2d2aa
commit 4468ef1410
13 changed files with 122 additions and 212 deletions

View file

@ -50,7 +50,7 @@ type FeedCreationArgs struct {
func CreateFeed(store *storage.Storage, args *FeedCreationArgs) (*model.Feed, error) {
defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[CreateFeed] FeedURL=%s", args.FeedURL))
if !store.CategoryExists(args.UserID, args.CategoryID) {
if !store.CategoryIDExists(args.UserID, args.CategoryID) {
return nil, errors.NewLocalizedError(errCategoryNotFound)
}

View file

@ -65,12 +65,7 @@ func (h *Handler) Import(userID int64, data io.Reader) error {
}
if category == nil {
category = &model.Category{
UserID: userID,
Title: subscription.CategoryName,
}
err := h.store.CreateCategory(category)
category, err = h.store.CreateCategory(userID, &model.CategoryRequest{Title: subscription.CategoryName})
if err != nil {
logger.Error("[OPML:Import] %v", err)
return fmt.Errorf(`unable to create this category: %q`, subscription.CategoryName)