store

package
v0.0.0-...-9349557 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2025 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const DiscordSource = "discord"

Variables

This section is empty.

Functions

This section is empty.

Types

type Encryptor

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

func NewEncryptor

func NewEncryptor(key []byte) (*Encryptor, error)

NewEncryptor takes a 32-byte key (AES-256)

func (*Encryptor) Decrypt

func (e *Encryptor) Decrypt(ciphertextB64 string) (string, error)

func (*Encryptor) Encrypt

func (e *Encryptor) Encrypt(plaintext string) (string, error)

type Redemption

type Redemption struct {
	Code     string         `json:"code"`
	Platform string         `json:"platform"`
	Status   string         `json:"status"`
	TimeUnix int64          `json:"time_unix"`
	Game     string         `json:"game"`
	Reward   sql.NullString `json:"reward"`
}

type Sqlite

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

func (*Sqlite) AddCode

func (s *Sqlite) AddCode(code, game string, userID *string, source *string) error

func (*Sqlite) AddRedemption

func (s *Sqlite) AddRedemption(userID, code, platform string, status string) error

func (*Sqlite) AddShiftError

func (s *Sqlite) AddShiftError(userID, code, platform, error string) error

func (*Sqlite) AddUser

func (s *Sqlite) AddUser(userID string) error

func (*Sqlite) ClearShiftErrors

func (s *Sqlite) ClearShiftErrors(userID string) error

func (*Sqlite) Close

func (s *Sqlite) Close() error

func (*Sqlite) CodeExists

func (s *Sqlite) CodeExists(code string) bool

func (*Sqlite) DeleteUserCookies

func (s *Sqlite) DeleteUserCookies(userID string) error

func (*Sqlite) EncryptAndSetUserCookies

func (s *Sqlite) EncryptAndSetUserCookies(userID string, cookies []*http.Cookie) error

func (*Sqlite) GetAllDecryptedUserCookiesSorted

func (s *Sqlite) GetAllDecryptedUserCookiesSorted(limit int64) ([]UserCookies, error)

func (*Sqlite) GetDecryptedUserCookies

func (s *Sqlite) GetDecryptedUserCookies(userID string) ([]*http.Cookie, error)

func (*Sqlite) GetRecentRedemptionsForUser

func (s *Sqlite) GetRecentRedemptionsForUser(userID string, status string, quantity int) ([]Redemption, error)

func (*Sqlite) GetShiftErrors

func (s *Sqlite) GetShiftErrors(userID string) ([]string, error)

func (*Sqlite) GetStatistics

func (s *Sqlite) GetStatistics(userID string) (Statistics, error)

func (*Sqlite) GetUserPlatformAndDM

func (s *Sqlite) GetUserPlatformAndDM(userID string) (string, bool, error)

func (*Sqlite) GetValidCodesNotRedeemedForUser

func (s *Sqlite) GetValidCodesNotRedeemedForUser(userID, platform string, limit int) ([]string, error)

func (*Sqlite) RedemptionSummaryForUser

func (s *Sqlite) RedemptionSummaryForUser(userID string) (map[string]int64, error)

func (*Sqlite) SetCodeRewardAndSuccess

func (s *Sqlite) SetCodeRewardAndSuccess(code, reward string, success bool) (bool, error)

func (*Sqlite) SetUserDM

func (s *Sqlite) SetUserDM(userID string, dm bool) error

func (*Sqlite) SetUserPlatform

func (s *Sqlite) SetUserPlatform(userID, platform string) error

func (*Sqlite) UserCookiesExists

func (s *Sqlite) UserCookiesExists(userID string) bool

func (*Sqlite) UserExists

func (s *Sqlite) UserExists(userID string) bool

type Statistics

type Statistics struct {
	Users       map[string]int64 `json:"users"`
	Codes       map[string]int64 `json:"codes"`
	Redemptions map[string]int64 `json:"redemptions"`
}

type Store

type Store interface {
	UserExists(userID string) bool
	AddUser(userID string) error
	GetUserPlatformAndDM(userID string) (string, bool, error)
	SetUserPlatform(userID, platform string) error
	SetUserDM(userID string, dm bool) error

	UserCookiesExists(userID string) bool
	EncryptAndSetUserCookies(userID string, cookie []*http.Cookie) error
	GetDecryptedUserCookies(userID string) ([]*http.Cookie, error)
	DeleteUserCookies(userID string) error
	GetAllDecryptedUserCookiesSorted(limit int64) ([]UserCookies, error)

	CodeExists(code string) bool
	AddCode(code, game string, userID *string, source *string) error
	SetCodeRewardAndSuccess(code, reward string, success bool) (bool, error)
	GetValidCodesNotRedeemedForUser(userID, platform string, limit int) ([]string, error)

	GetRecentRedemptionsForUser(userID, status string, quantity int) ([]Redemption, error)
	RedemptionSummaryForUser(userID string) (map[string]int64, error)
	AddRedemption(userID, code, platform string, status string) error

	AddShiftError(userID, code, platform, error string) error
	GetShiftErrors(userID string) ([]string, error)
	ClearShiftErrors(userID string) error

	GetStatistics(userID string) (Statistics, error)

	Close() error
}

func NewSqliteStore

func NewSqliteStore(filepath string, encryptor *Encryptor) (Store, error)

type UserCookies

type UserCookies struct {
	UserID  string
	Cookies []*http.Cookie
}

Jump to

Keyboard shortcuts

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