Documentation ¶
Index ¶
- Constants
- type EmailSender
- type Model
- type Subscription
- type SubscriptionState
- type SubscriptionUserTweets
- type SystemUseCase
- type Tweet
- type TweetAttrs
- type TwitterUser
- type TwitterUserSearchResult
- type UseCases
- type User
- type UserDatastore
- type UserEmail
- type UserLastTweet
- type UserList
- type UserUseCase
Constants ¶
const ( //Preparing - subscription status Preparing string = "PREPARING" //Ready - subscription status Ready string = "READY" //Sending - subscription status Sending string = "SENDING" //Sent - subscription status Sent string = "SENT" //Failed - subscription status Failed string = "FAILED" //EmailStatusNew - Email status NEW EmailStatusNew string = "NEW" //EmailStatusSent - confirmation email was sent EmailStatusSent string = "SENT" //EmailStatusConfirmed - Email status Confirmed EmailStatusConfirmed string = "CONFIRMED" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EmailSender ¶
EmailSender - send emails
type Subscription ¶
type Subscription struct { ID uuid.UUID `db:"id"` UserID uuid.UUID `db:"user_id"` Title string `db:"title"` Email string `db:"email"` Day string `db:"day"` IgnoreRT bool `db:"ignore_rt"` IgnoreReplies bool `db:"ignore_replies"` UserList UserList }
Subscription represents user subscription
func (Subscription) Equal ¶
func (s Subscription) Equal(another Subscription) bool
func (Subscription) GetSubject ¶
func (s Subscription) GetSubject() string
GetSubject returns the letter subject
func (Subscription) String ¶
func (s Subscription) String() string
type SubscriptionState ¶
type SubscriptionState struct { ID uint `db:"id"` SubscriptionID uuid.UUID `db:"subscription_id"` Status string `db:"status"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` }
SubscriptionState - subscription status
func (*SubscriptionState) String ¶
func (s *SubscriptionState) String() string
type SubscriptionUserTweets ¶
type SubscriptionUserTweets struct { SubscriptionID uuid.UUID `db:"subscription_id"` Tweets map[string]UserLastTweet }
SubscriptionUserTweets contains map user twiiter id to UserLastTweet
func (SubscriptionUserTweets) String ¶
func (s SubscriptionUserTweets) String() string
type SystemUseCase ¶
type SystemUseCase interface { InitSubscriptions(ids ...uuid.UUID) error PrepareSubscriptions(ids ...uuid.UUID) error SendSubscriptions(ids ...uuid.UUID) error SendConfirmationEmail() error GetToken(email, userID string) (string, error) RemoveOldTweets() error }
SystemUseCase - represents system tasks
type Tweet ¶
type Tweet struct { ID uint `db:"id"` TweetID string `db:"tweet_id"` Tweet TweetAttrs `db:"tweet"` }
Tweet - user tweet
type TweetAttrs ¶
type TweetAttrs struct { IdStr string `json:"id_str"` Text string `json:"text"` FullText string `json:"full_text"` InReplyToStatusIdStr string `json:"in_reply_to_status_id_str"` InReplyToUserIdStr string `json:"in_reply_to_user_id_str"` UserId string `json:"user_id"` UserName string `json:"user_name"` UserScreenName string `json:"user_screen_name"` UserProfileImageUrl string `json:"user_profile_image_url"` }
TweetAttrs - tweet data
func (*TweetAttrs) Scan ¶
func (a *TweetAttrs) Scan(value interface{}) error
type TwitterUser ¶
type TwitterUser struct { UserID uuid.UUID `db:"user_id"` TwitterID string `db:"social_account_id"` AccessToken string `db:"access_token"` TokenSecret string `db:"token_secret"` ProfileIMGURL string `db:"profile_image_url"` ScreenName string }
TwitterUser - represents twitter account
func (TwitterUser) String ¶
func (t TwitterUser) String() string
type TwitterUserSearchResult ¶
type TwitterUserSearchResult struct { Name string `db:"name"` TwitterID string `db:"twitter_id"` ProfileIMGURL string `db:"profile_image_url"` ScreenName string `db:"screen_name"` }
TwitterUserSearchResult - twitter user info
func (TwitterUserSearchResult) Equal ¶
func (t TwitterUserSearchResult) Equal(another TwitterUserSearchResult) bool
Equal checks if users ids are equal
func (TwitterUserSearchResult) String ¶
func (t TwitterUserSearchResult) String() string
type UseCases ¶
type UseCases struct { UserUseCase SystemUseCase }
UseCases - represents all use cases
func NewUseCases ¶
func NewUseCases(user UserUseCase, system SystemUseCase) *UseCases
NewUseCases - returns new UseCases struct
type UserDatastore ¶
type UserDatastore interface { InsertUser(ctx context.Context, user User) (User, error) UpdateUser(ctx context.Context, user User) (User, error) GetUser(ctx context.Context, userID uuid.UUID) (User, error) RemoveUser(ctx context.Context, userID uuid.UUID) error InsertTwitterUser(ctx context.Context, twitterUser TwitterUser) (TwitterUser, error) UpdateTwitterUser(ctx context.Context, twitterUser TwitterUser) (TwitterUser, error) GetTwitterUserByID(ctx context.Context, twitterUserID string) (TwitterUser, error) GetTwitterUser(ctx context.Context, userID uuid.UUID) (TwitterUser, error) InsertSubscription(ctx context.Context, subscription Subscription) (Subscription, error) GetSubscriptions(ctx context.Context, userID uuid.UUID) ([]Subscription, error) UpdateSubscription(ctx context.Context, subscription Subscription) (Subscription, error) GetSubscription(ctx context.Context, subscriptionID uuid.UUID) (Subscription, error) DeleteSubscription(ctx context.Context, subscription Subscription) error GetNewSubscriptionsUsers(ctx context.Context, subscriptionIDs ...uuid.UUID) (map[uuid.UUID][]string, error) InsertSubscriptionUserState(ctx context.Context, subscriptionID uuid.UUID, userTwitterID, lastTweetID string) error UpdateSubscriptionUserState(ctx context.Context, subscriptionID uuid.UUID, userTwitterID, lastTweetID string) error GetTodaySubscriptionsIDs(ctx context.Context) ([]uuid.UUID, error) InsertSubscriptionState(ctx context.Context, state SubscriptionState) (SubscriptionState, error) UpdateSubscriptionState(ctx context.Context, state SubscriptionState) (SubscriptionState, error) GetReadySubscriptionsStates(ctx context.Context, subscriptionIDs ...uuid.UUID) ([]SubscriptionState, error) UpdateSubscriptionUserStateTweets(ctx context.Context) error GetSubscriptionUserTweets(ctx context.Context, subscriptionID uuid.UUID) (SubscriptionUserTweets, error) GetSubscriptionTweets(ctx context.Context, subscriptionStateID uint) ([]Tweet, error) InsertTweet(ctx context.Context, tweet Tweet, subscriptionStateID uint) (Tweet, error) AcquireLock(ctx context.Context, key uint) (bool, error) ReleaseLock(ctx context.Context, key uint) (bool, error) InsertUserEmail(ctx context.Context, userEmail UserEmail) (UserEmail, error) GetUserEmail(ctx context.Context, userEmail UserEmail) (UserEmail, error) UpdateUserEmail(ctx context.Context, userEmail UserEmail) (UserEmail, error) GetUserEmails(ctx context.Context, status string) ([]UserEmail, error) RemoveOldTweets(ctx context.Context, tweetTTL int) error }
UserDatastore - represents all user related database methods
type UserEmail ¶
type UserEmail struct { UserID uuid.UUID `db:"user_id"` Email string `db:"email"` Status string `db:"status"` }
UserEmail - confirmed user email address
type UserLastTweet ¶
UserLastTweet - last read tweet of a user
func (UserLastTweet) String ¶
func (u UserLastTweet) String() string
type UserList ¶
type UserList []TwitterUserSearchResult
UserList is list of TwitterUserSearchResult structs
type UserUseCase ¶
type UserUseCase interface { SignInWithTwitter(ctx context.Context, twitterID, name, email, screenName, accessToken, tokenSecret string) (User, error) GetUserByID(ctx context.Context, userID uuid.UUID) (User, error) SearchTwitterUsers(ctx context.Context, userID uuid.UUID, query string) ([]TwitterUserSearchResult, error) AddSubscription(ctx context.Context, subscription Subscription) (Subscription, error) GetSubscriptions(ctx context.Context, userID uuid.UUID) ([]Subscription, error) UpdateSubscription(ctx context.Context, userID uuid.UUID, subscription Subscription) (Subscription, error) DeleteSubscription(ctx context.Context, userID uuid.UUID, subscriptionID uuid.UUID) error DeleteAccount(ctx context.Context, userID uuid.UUID) error ConfirmEmail(ctx context.Context, token string) error }
UserUseCase - represents user use cases