#10 - user logged in middleware

This commit is contained in:
2025-03-11 15:00:59 +02:00
parent b7b7a7d55d
commit 5dfe911793
4 changed files with 18 additions and 18 deletions

View File

@@ -19,15 +19,11 @@ func AddFeedHandler(s *config.State, cmd config.Command, user database.User) err
}
ctx := context.Background()
user, err := s.DB.GetUser(ctx, s.Config.CurrentUserName)
if err != nil {
return err
}
name := cmd.Args[0]
url := cmd.Args[1]
_, err = rss.FetchFeed(ctx, url)
_, err := rss.FetchFeed(ctx, url)
if err != nil {
fmt.Printf("Failed to fetch feed: %v\n", err)
os.Exit(1)

View File

@@ -4,14 +4,11 @@ import (
"context"
"fmt"
"github.com/rdarius/boot-dev-blog-aggregator/internal/config"
"github.com/rdarius/boot-dev-blog-aggregator/internal/database"
)
func GetFeedFollowsByUserHandler(s *config.State, cmd config.Command) error {
func GetFeedFollowsByUserHandler(s *config.State, cmd config.Command, user database.User) error {
ctx := context.Background()
user, err := s.DB.GetUser(ctx, s.Config.CurrentUserName)
if err != nil {
return err
}
ff, err := s.DB.GetFeedFollowsByUser(ctx, user.ID)

View File

@@ -12,15 +12,11 @@ import (
"time"
)
func FollowFeedHandler(s *config.State, cmd config.Command) error {
func FollowFeedHandler(s *config.State, cmd config.Command, user database.User) error {
if len(cmd.Args) < 1 {
log.Fatal("usage: boot-dev-blog-aggregator follow URL")
}
ctx := context.Background()
user, err := s.DB.GetUser(ctx, s.Config.CurrentUserName)
if err != nil {
return err
}
url := cmd.Args[0]