db

package
v0.0.0-...-b2fa3f8 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessTokenRow

type AccessTokenRow struct {
	Token        []byte    `json:"token"`
	AuthCode     []byte    `json:"auth_code"`
	RefreshToken []byte    `json:"refresh_token"`
	UserID       uuid.UUID `json:"user_id"`
	Created      time.Time `json:"created"`
	Expires      int       `json:"expires"`
}

AccessToken contains the information to provide user access within oAuth scope

type AuthCodeRow

type AuthCodeRow struct {
	Code     []byte    `json:"code"`
	ClientID string    `json:"client_id"`
	UserID   uuid.UUID `json:"user_id"`
	Scope    Scope     `json:"scope"`
	Expires  time.Time `json:"expires"`
}

AuthCode is the authorization code of oauth2.0 code is the primary key

type AuthStore

type AuthStore interface {
	// User
	InsertUser(ctx context.Context, u *UserRow) error
	GetUserByID(ctx context.Context, id uuid.UUID) (*UserRow, error)
	GetUserByEmail(ctx context.Context, email string) (*UserRow, error)
	GetUserByUsername(ctx context.Context, username string) (*UserRow, error)
	UpdateUser(ctx context.Context, u *UserRow) error
	UpdateUserPassword(ctx context.Context, id uuid.UUID, password_hash []byte) error
	DeleteUser(ctx context.Context, id uuid.UUID) error

	// Session
	InsertSession(ctx context.Context, s *SessionRow) error
	GetSession(ctx context.Context, id uuid.UUID) (*SessionRow, error)
	UpdateSession(ctx context.Context, s *SessionRow) error
	DeleteSession(ctx context.Context, id uuid.UUID) error

	// Both
	GetSessionAndUser(ctx context.Context, sessionID uuid.UUID) (*SessionRow, *UserRow, error)
}

type AuthStorePG

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

func NewAuthStorePG

func NewAuthStorePG(db *pgxpool.Pool) *AuthStorePG

func (*AuthStorePG) DeleteSession

func (a *AuthStorePG) DeleteSession(ctx context.Context, id uuid.UUID) error

func (*AuthStorePG) DeleteUser

func (a *AuthStorePG) DeleteUser(ctx context.Context, id uuid.UUID) error

func (*AuthStorePG) GetSession

func (a *AuthStorePG) GetSession(ctx context.Context, id uuid.UUID) (*SessionRow, error)

func (*AuthStorePG) GetSessionAndUser

func (a *AuthStorePG) GetSessionAndUser(ctx context.Context, sessionID uuid.UUID) (*SessionRow, *UserRow, error)

func (*AuthStorePG) GetUserByEmail

func (a *AuthStorePG) GetUserByEmail(ctx context.Context, email string) (*UserRow, error)

func (*AuthStorePG) GetUserByID

func (a *AuthStorePG) GetUserByID(ctx context.Context, id uuid.UUID) (*UserRow, error)

func (*AuthStorePG) GetUserByUsername

func (a *AuthStorePG) GetUserByUsername(ctx context.Context, username string) (*UserRow, error)

func (*AuthStorePG) InsertSession

func (a *AuthStorePG) InsertSession(ctx context.Context, s *SessionRow) error

Session

func (*AuthStorePG) InsertUser

func (a *AuthStorePG) InsertUser(ctx context.Context, u *UserRow) error

User

func (*AuthStorePG) UpdateSession

func (a *AuthStorePG) UpdateSession(ctx context.Context, s *SessionRow) error

func (*AuthStorePG) UpdateUser

func (a *AuthStorePG) UpdateUser(ctx context.Context, u *UserRow) error

func (AuthStorePG) UpdateUserPassword

func (a AuthStorePG) UpdateUserPassword(ctx context.Context, id uuid.UUID, password_hash []byte) error

type Category

type Category struct {
	ID       int
	Name     string
	ParentID int
}

type Episode

type Episode struct {
	// REQUIRED
	ID              uuid.UUID
	Title           string
	EnclosureURL    string
	EnclosureLength int64
	EnclosureType   string
	// RECOMMENDED
	PubDate     time.Time
	Description string
	Duration    int64
	LinkURL     string
	ImageURL    string
	ImageTitle  string
	Explicit    string
	// SITUATIONAL
	Episode     int
	Season      int
	EpisodeType string
	//Block       bool
	// OTHER
	Subtitle  string
	Summary   string
	Encoded   string
	PodcastID uuid.UUID
}

Episode holds information about a single episode of a podcast within the rss feed

type OAuthStore

type OAuthStore interface {
	// Auth Code
	InsertAuthCode(ctx context.Context, a *AuthCodeRow) error
	GetAuthCode(ctx context.Context, code []byte) (*AuthCodeRow, error)
	// UpdateAuthCode(ctx context.Context, a *AuthCodeRow) error
	DeleteAuthCode(ctx context.Context, code []byte) error

	// Access Token
	InsertAccessToken(ctx context.Context, a *AccessTokenRow) error
	GetAccessTokenByRefresh(ctx context.Context, refreshToken []byte) (*AccessTokenRow, error)
	DeleteAccessToken(ctx context.Context, token []byte) error

	GetAccessTokenAndUser(ctx context.Context, token []byte) (*UserRow, *AccessTokenRow, error)
}

type OAuthStorePG

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

func NewOAuthStorePG

func NewOAuthStorePG(db *pgxpool.Pool) *OAuthStorePG

func (*OAuthStorePG) DeleteAccessToken

func (o *OAuthStorePG) DeleteAccessToken(ctx context.Context, token []byte) error

func (*OAuthStorePG) DeleteAuthCode

func (o *OAuthStorePG) DeleteAuthCode(ctx context.Context, code []byte) error

func (*OAuthStorePG) GetAccessTokenAndUser

func (o *OAuthStorePG) GetAccessTokenAndUser(ctx context.Context, token []byte) (*UserRow, *AccessTokenRow, error)

func (*OAuthStorePG) GetAccessTokenByRefresh

func (o *OAuthStorePG) GetAccessTokenByRefresh(ctx context.Context, refreshToken []byte) (*AccessTokenRow, error)

func (*OAuthStorePG) GetAuthCode

func (o *OAuthStorePG) GetAuthCode(ctx context.Context, code []byte) (*AuthCodeRow, error)

func (*OAuthStorePG) InsertAccessToken

func (o *OAuthStorePG) InsertAccessToken(ctx context.Context, a *AccessTokenRow) error

func (*OAuthStorePG) InsertAuthCode

func (o *OAuthStorePG) InsertAuthCode(ctx context.Context, a *AuthCodeRow) error

type Podcast

type Podcast struct {
	// REQUIRED
	ID          uuid.UUID
	Title       string
	Description string
	ImageURL    string
	Language    string
	Category    []int
	Explicit    string
	// RECOMMENDED
	Author     string
	LinkURL    string
	OwnerName  string
	OwnerEmail string
	// SITUATIONAL
	Episodic  bool
	Copyright string
	Block     bool
	Complete  bool
	// RSS/OTHER
	PubDate  time.Time
	Keywords string
	Summary  string
	RSSURL   string
}

Podcast contains information and xml struct tags for podcast

type PodcastStore

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

func NewPodcastStore

func NewPodcastStore(db *pgxpool.Pool) *PodcastStore

func (*PodcastStore) DeleteSubscription

func (ps *PodcastStore) DeleteSubscription(ctx context.Context, uID uuid.UUID, pID uuid.UUID) error

func (*PodcastStore) FindAllCategories

func (p *PodcastStore) FindAllCategories(ctx context.Context) ([]Category, error)

func (*PodcastStore) FindEpisodeByID

func (p *PodcastStore) FindEpisodeByID(ctx context.Context, epiID uuid.UUID) (*Episode, error)

func (*PodcastStore) FindEpisodeByURL

func (p *PodcastStore) FindEpisodeByURL(ctx context.Context, podID uuid.UUID, mp3URL string) (*Episode, error)

func (*PodcastStore) FindEpisodeNumber

func (p *PodcastStore) FindEpisodeNumber(ctx context.Context, podID uuid.UUID, season, episode int) (*Episode, error)

func (*PodcastStore) FindEpisodesByRange

func (ps *PodcastStore) FindEpisodesByRange(ctx context.Context, podID uuid.UUID, start, end int64) ([]Episode, error)

func (*PodcastStore) FindLastPlayed

func (ps *PodcastStore) FindLastPlayed(ctx context.Context, userID uuid.UUID) (*UserEpisode, *Podcast, *Episode, error)

func (*PodcastStore) FindLastUserEpi

func (p *PodcastStore) FindLastUserEpi(ctx context.Context, userID uuid.UUID) (*UserEpisode, error)

func (*PodcastStore) FindLatestEpisode

func (p *PodcastStore) FindLatestEpisode(ctx context.Context, podID uuid.UUID) (*Episode, error)

func (*PodcastStore) FindPodcastByID

func (ps *PodcastStore) FindPodcastByID(ctx context.Context, id uuid.UUID) (*Podcast, error)

func (*PodcastStore) FindPodcastByRSS

func (ps *PodcastStore) FindPodcastByRSS(ctx context.Context, rssURL string) (*Podcast, error)

func (*PodcastStore) FindPodcastsByRange

func (ps *PodcastStore) FindPodcastsByRange(ctx context.Context, start int, end int) ([]Podcast, error)

func (*PodcastStore) FindSubscriptions

func (ps *PodcastStore) FindSubscriptions(ctx context.Context, userID uuid.UUID) ([]Subscription, error)

func (*PodcastStore) FindUserEpisode

func (p *PodcastStore) FindUserEpisode(ctx context.Context, userID, epiID uuid.UUID) (*UserEpisode, error)

func (*PodcastStore) InsertCategory

func (p *PodcastStore) InsertCategory(ctx context.Context, cat *Category) error

func (*PodcastStore) InsertEpisode

func (p *PodcastStore) InsertEpisode(ctx context.Context, e *Episode) error

func (*PodcastStore) InsertPodcast

func (ps *PodcastStore) InsertPodcast(ctx context.Context, p *Podcast) error

Podcast stuff

func (*PodcastStore) InsertSubscription

func (ps *PodcastStore) InsertSubscription(ctx context.Context, sub *Subscription) error

func (*PodcastStore) SearchPodcasts

func (ps *PodcastStore) SearchPodcasts(ctx context.Context, search string) ([]Podcast, error)

func (*PodcastStore) UpsertUserEpisode

func (p *PodcastStore) UpsertUserEpisode(ctx context.Context, userEpi *UserEpisode) error

type Scope

type Scope string

Scope contains identifiers to oAuth permissions

const (
	Read       Scope = "Read"
	ReadChange Scope = "ReadChange"
)

Scopes of oauth2.0

type SessionRow

type SessionRow struct {
	ID           uuid.UUID
	UserID       uuid.UUID
	LoginTime    time.Time
	LastSeenTime time.Time
	Expires      time.Time
	UserAgent    string
}

SessionRow contains all session information

type Subscription

type Subscription struct {
	UserID        uuid.UUID
	PodcastID     uuid.UUID
	CompletedIDs  []uuid.UUID
	InProgressIDs []uuid.UUID
}

type UserEpisode

type UserEpisode struct {
	UserID       uuid.UUID
	EpisodeID    uuid.UUID
	OffsetMillis int64
	LastSeen     time.Time
	Played       bool
}

type UserRow

type UserRow struct {
	ID           uuid.UUID
	Email        string
	Username     string
	Birthdate    time.Time
	PasswordHash []byte
	Created      time.Time
	LastSeen     time.Time
}

UserRow contains all user specific information

Jump to

Keyboard shortcuts

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