2022-10-27 04:04:49 +02:00
|
|
|
package handler
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"gitea.theedgeofrage.com/TheEdgeOfRage/ytrssil-api/db"
|
2022-10-31 02:39:52 +01:00
|
|
|
"gitea.theedgeofrage.com/TheEdgeOfRage/ytrssil-api/feedparser"
|
2022-10-27 04:04:49 +02:00
|
|
|
"gitea.theedgeofrage.com/TheEdgeOfRage/ytrssil-api/lib/log"
|
|
|
|
"gitea.theedgeofrage.com/TheEdgeOfRage/ytrssil-api/models"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Handler interface {
|
|
|
|
CreateUser(ctx context.Context, user models.User) error
|
2022-10-29 05:09:52 +02:00
|
|
|
SubscribeToChannel(ctx context.Context, username string, channelID string) error
|
2022-10-30 19:23:40 +01:00
|
|
|
UnsubscribeFromChannel(ctx context.Context, username string, channelID string) error
|
2022-10-29 05:09:52 +02:00
|
|
|
GetNewVideos(ctx context.Context, username string) ([]models.Video, error)
|
2022-10-30 01:08:07 +02:00
|
|
|
GetWatchedVideos(ctx context.Context, username string) ([]models.Video, error)
|
2022-10-29 05:09:52 +02:00
|
|
|
FetchVideos(ctx context.Context) error
|
2022-10-30 01:08:07 +02:00
|
|
|
MarkVideoAsWatched(ctx context.Context, username string, videoID string) error
|
|
|
|
MarkVideoAsUnwatched(ctx context.Context, username string, videoID string) error
|
2022-10-27 04:04:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type handler struct {
|
2022-10-31 02:39:52 +01:00
|
|
|
log log.Logger
|
|
|
|
db db.DB
|
|
|
|
parser feedparser.Parser
|
2022-10-27 04:04:49 +02:00
|
|
|
}
|
|
|
|
|
2022-10-31 02:39:52 +01:00
|
|
|
func New(log log.Logger, db db.DB, parser feedparser.Parser) *handler {
|
|
|
|
return &handler{
|
|
|
|
log: log,
|
|
|
|
db: db,
|
|
|
|
parser: parser,
|
|
|
|
}
|
2022-10-27 04:04:49 +02:00
|
|
|
}
|