#10 - user logged in middleware
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user