Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrFakeEmail = errors.New("this email is a fake")
View Source
var (
ErrUserDeactivated = errors.New("user was deactivated")
)
View Source
var ErrUserExists = errors.New("user already exists")
View Source
var ErrValidationFailed = errors.New("validation failed")
Functions ¶
This section is empty.
Types ¶
type FeedManager ¶
type FeedManager interface { // AddFollower will subscribe follower to new tweets of the user AddFollower(ctx context.Context, userID, toUserID int) error // RemoveFollower will unsubscribe follower from new tweets of the user RemoveFollower(ctx context.Context, userID, fromUserID int) error GetFollowing(ctx context.Context, userID int) ([]entity.User, error) GetFollowers(ctx context.Context, userID int) ([]entity.User, error) AddTweet(ctx context.Context, userID int, text string) (id int, err error) AddComment(ctx context.Context, userID, tweetID int, text string) (id int, err error) EditTweet(ctx context.Context, tweetID int, text string) error EditComment(ctx context.Context, commentID int, text string) error GetNewsFeed(ctx context.Context, userID int) ([]entity.Tweet, error) GetRecommendedUsers(ctx context.Context, userID int) ([]entity.User, error) }
func NewFeedManager ¶
func NewFeedManager( usersRepo UserRepository, followersRepo FollowerRepository, tweetsRepo TweetRepository, ) FeedManager
NewFeedManager returns usecase for work with user news feed
type FollowerRepository ¶
type FollowerRepository interface { // Add follower user id linked to another user Add(ctx context.Context, followerID, toUserID int) error // Remove follower from some user Remove(ctx context.Context, followerID, fromUserID int) error // GetFollowing users with topN limit GetFollowing(ctx context.Context, userID, topN int) ([]int, error) // GetFollowers give subscribed users ids GetFollowers(ctx context.Context, userID, topN int) ([]int, error) }
type ScamDetectorClient ¶
type TweetRepository ¶
type TweetRepository interface { Add(ctx context.Context, userID int, tweetText string) (id int, err error) Update(ctx context.Context, tweetID int, newText string) error AddComment(ctx context.Context, userID, tweetID int, commentText string) (id int, err error) UpdateComment(ctx context.Context, commentID int, newText string) error GetLatest(ctx context.Context, userID int, limit int) ([]entity.Tweet, error) }
type UserProfiler ¶
type UserProfiler interface { Register(ctx context.Context, name, email, caption string, birthDate time.Time) (*entity.User, error) Deactivate(ctx context.Context, userID int) error UpdateCaption(ctx context.Context, userID int, newCaption string) error Login(ctx context.Context, email string) (*entity.User, error) }
func NewUserProfiler ¶
func NewUserProfiler(userRepo UserRepository, scamClient ScamDetectorClient) UserProfiler
type UserRepository ¶
type UserRepository interface { // Add will creates new user in repo and returns id assigned to it Add(ctx context.Context, name, email, caption string, birthDate time.Time) (id int, err error) Get(ctx context.Context, userID int) (*entity.User, error) GetAll(ctx context.Context, limit int) ([]entity.User, error) GetByEmail(ctx context.Context, email string) (*entity.User, error) UpdateCaption(ctx context.Context, userID int, caption string) error Delete(ctx context.Context, userID int) error }
Click to show internal directories.
Click to hide internal directories.