data

package
v0.0.0-...-ec2a438 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FollowerStateNew              = "NEW"
	FollowerStateLost             = "LOST"
	FollowerStateReasonFollowed   = "FOLLOWED"
	FollowerStateReasonUnfollowed = "UNFOLLOWED"
	FollowerStateReasonDeleted    = "DELETED"
	FollowerStateReasonSuspended  = "SUSPENDED"
)

Variables

View Source
var (
	ErrUserNotFound         = errors.New("user not found")
	ErrFollowerListNotFound = errors.New("follower list not found")
)

Functions

This section is empty.

Types

type FollowerEvent

type FollowerEvent struct {
	ID                  string        `json:"id" dynamo:"EventID"`
	UserID              string        `json:"userId" tstype:"-"` // FIXME: required by notify-user
	TotalFollowers      int           `json:"totalFollowers"`
	Follower            *twitter.User `json:"follower" tstype:",required"`
	FollowerState       string        `json:"followerState" tstype:"'NEW' | 'LOST'"`
	FollowerStateReason string        `json:"followerStateReason" tstype:"'FOLLOWED' | 'UNFOLLOWED' | 'DELETED' | 'SUSPENDED'"`
	CreatedAt           time.Time     `json:"createdAt"`
	ExpiresAt           time.Time     `json:"-"`
}

func (*FollowerEvent) Validate

func (e *FollowerEvent) Validate() error

type FollowerList

type FollowerList struct {
	UserID         string
	S3Bucket       string
	S3Key          string
	TotalFollowers int
	CreatedAt      time.Time
	ExpiresAt      time.Time
}

func (*FollowerList) Validate

func (l *FollowerList) Validate() error

type SlackConfig

type SlackConfig struct {
	Enabled    bool   `json:"enabled"`
	WebhookURL string `json:"webhookUrl,omitempty" dynamo:",omitempty"`
	Channel    string `json:"channel,omitempty" dynamo:",omitempty"`
}

func (SlackConfig) Validate

func (c SlackConfig) Validate() error

type Table

type Table struct {
	// contains filtered or unexported fields
}

Table implements the Table Module pattern: https://www.martinfowler.com/eaaCatalog/tableModule.html

func NewConsistentTable

func NewConsistentTable(p client.ConfigProvider, name string) *Table

func NewTable

func NewTable(p client.ConfigProvider, name string) *Table

func (*Table) CreateFollowerEvent

func (t *Table) CreateFollowerEvent(ctx context.Context, e *FollowerEvent) error

func (*Table) CreateFollowerList

func (t *Table) CreateFollowerList(ctx context.Context, l *FollowerList) error

func (*Table) CreateUser

func (t *Table) CreateUser(ctx context.Context, u *User) error

func (*Table) DeleteUser

func (t *Table) DeleteUser(ctx context.Context, userID string) error

func (*Table) GetLatestFollowerEvents

func (t *Table) GetLatestFollowerEvents(ctx context.Context, userID string, limit int64) ([]*FollowerEvent, error)

func (*Table) GetLatestFollowerLists

func (t *Table) GetLatestFollowerLists(ctx context.Context, userID string, limit int64) ([]*FollowerList, error)

func (*Table) GetUser

func (t *Table) GetUser(ctx context.Context, userID string) (*User, error)

func (*Table) GetUserAndLatestFollowerLists

func (t *Table) GetUserAndLatestFollowerLists(ctx context.Context, userID string, limit int64) (*User, []*FollowerList, error)

func (*Table) NewUserIter

func (t *Table) NewUserIter() UserIter

func (*Table) RegisterUser

func (t *Table) RegisterUser(ctx context.Context, u *User) error

RegisterUser creates or updates a user, e.g. after login via Auth0.

func (*Table) UpdateUser

func (t *Table) UpdateUser(ctx context.Context, u *User) error

type TableAPI

type TableAPI interface {
	CreateUser(ctx context.Context, u *User) error
	UpdateUser(ctx context.Context, u *User) error
	RegisterUser(ctx context.Context, u *User) error
	GetUser(ctx context.Context, userID string) (*User, error)
	DeleteUser(ctx context.Context, userID string) error
	NewUserIter() UserIter

	CreateFollowerList(ctx context.Context, l *FollowerList) error
	GetUserAndLatestFollowerLists(ctx context.Context, userID string, limit int64) (*User, []*FollowerList, error)
	GetLatestFollowerLists(ctx context.Context, userID string, limit int64) ([]*FollowerList, error)

	CreateFollowerEvent(ctx context.Context, e *FollowerEvent) error
	GetLatestFollowerEvents(ctx context.Context, userID string, limit int64) ([]*FollowerEvent, error)
}

type User

type User struct {
	ID              string      `json:"id" dynamo:"UserID"`
	Handle          string      `json:"handle"`
	Name            string      `json:"name"`
	Location        string      `json:"location,omitempty"`
	Bio             string      `json:"bio,omitempty"`
	ProfileImageURL string      `json:"profileImageUrl"`
	AccessToken     string      `json:"-"`
	AccessSecret    string      `json:"-"`
	Slack           SlackConfig `json:"slack"`
	IgnoreFollowers []string    `json:"ignoreFollowers,omitempty" dynamo:",set,omitempty"`
	CreatedAt       time.Time   `json:"createdAt"`
	UpdatedAt       time.Time   `json:"updatedAt"`
	LastLogin       time.Time   `json:"lastLogin"`
	LastIP          string      `json:"-"`
	LoginsCount     int64       `json:"-"`
	IDP             string      `json:"-" dynamo:"IdP"`
}

func NewUser

func NewUser(id string) *User

func (*User) IgnoresFollower

func (u *User) IgnoresFollower(id, handle string) bool

func (*User) Validate

func (u *User) Validate() error

type UserIter

type UserIter interface {
	Next(ctx context.Context) *User
	Err() error
}

type UserSignupEvent

type UserSignupEvent struct {
	UserID string `tstype:"-"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL