types

package
v0.0.0-...-e9c30ff Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrApplicationValueNotFound = errors.New("application value not found")

ErrApplicationValueNotFound is returned when we can not find the specified application value

View Source
var ErrBlockedUserNotFound = errors.New("blocked user not found")

ErrBlockedUserNotFound is returned when we can not find the specified blocked user

View Source
var ErrInsufficientPointsBalance = errors.New("insufficient points balance")

ErrInsufficientPointsBalance is returned when there is an insufficient points balance for the requested operation

View Source
var ErrJWTClaimSeasonNotFound = errors.New("JWT claim season not found")

ErrJWTClaimSeasonNotFound is returned when a JWT claim season for a specified user is not found

View Source
var ErrMediaQueueEventNotFound = errors.New("media queue event not found")

ErrMediaQueueEventNotFound is returned when we can not find the specified media queue event

View Source
var ErrNoSubscription = errors.New("subscription not found")

ErrNoSubscription is returned when we can not find the specified subscription

View Source
var ErrPointsTxNotFound = errors.New("points transaction not found")

ErrPointsTxNotFound is returned when we can not find the specified points transaction

View Source
var ErrWithdrawalNotFound = errors.New("withdrawal not found")

ErrWithdrawalNotFound is returned when we can not find the specified withdrawal

View Source
var MaxConnectionsPerService = map[ConnectionService]int{
	ConnectionServiceCryptomonKeys: 1,
}

Functions

func AddressHasPendingWithdrawal

func AddressHasPendingWithdrawal(node sqalx.Node, address string) (bool, int, int, error)

AddressHasPendingWithdrawal returns whether an address has a pending withdrawal

func AdjustPointsBalanceOfAddress

func AdjustPointsBalanceOfAddress(node sqalx.Node, address string, amount int) error

AdjustPointsBalanceOfAddress adjusts the points balance of the specified address by the specified amount

func ClearApplicationValuesForApplication

func ClearApplicationValuesForApplication(node sqalx.Node, applicationID string) error

ClearApplicationValuesForApplication clears all the values for the specified application

func CountApplicationValuesForApplication

func CountApplicationValuesForApplication(node sqalx.Node, applicationID string) (int, error)

CountApplicationValuesForApplication returns the number of application values for the specified application

func CountMediaRaffleEntriesBetween

func CountMediaRaffleEntriesBetween(node sqalx.Node, onOrAfter time.Time, before time.Time) (int, error)

CountMediaRaffleEntriesBetween counts the played media raffle entries in the specified time period

func CountMediaRaffleEntriesRequestedByBetween

func CountMediaRaffleEntriesRequestedByBetween(node sqalx.Node, onOrAfter time.Time, before time.Time, user string) (int, error)

CountMediaRaffleEntriesRequestedByBetween counts the played media raffle entries in the specified time period that belong to the specified user

func Delete

func Delete[T any](node sqalx.Node, t ...T) error

Delete deletes values t from the database.

func DeleteCustom

func DeleteCustom[T any](node sqalx.Node, dbuilder sq.DeleteBuilder) error

DeleteCustom deletes the values which match the conditions in dbuilder

func GetASNumberReputationsWithNumbers

func GetASNumberReputationsWithNumbers(node sqalx.Node, numbers int) (map[int]*ASNumberReputation, error)

GetASNumberReputationsWithNumbers returns the reputations with the specified numbers

func GetApplicationFilesForApplication

func GetApplicationFilesForApplication[T ApplicationFileLike](node sqalx.Node, applicationID, filter string, pagParams *PaginationParams) ([]T, uint64, error)

GetApplicationFilesForApplication returns the latest version of all the non-deleted files of an application

func GetApplicationFilesForApplicationAtVersion

func GetApplicationFilesForApplicationAtVersion[T ApplicationFileLike](node sqalx.Node, applicationID string, version ApplicationVersion, filter string, pagParams *PaginationParams) ([]T, uint64, error)

GetApplicationFilesForApplication returns all the non-deleted files of an application, at the specified version

func GetApplicationFilesWithNamesForApplication

func GetApplicationFilesWithNamesForApplication(node sqalx.Node, applicationID string, names []string) (map[string]*ApplicationFile, error)

GetApplicationFilesWithNamesForApplication returns the latest version of the files with the specified names for an application

func GetApplicationFilesWithNamesForApplicationAtVersion

func GetApplicationFilesWithNamesForApplicationAtVersion(node sqalx.Node, applicationID string, version ApplicationVersion, names []string) (map[string]*ApplicationFile, error)

GetApplicationFilesWithNamesForApplicationAtVersion returns the files with the specified names for an application, at the specified version

func GetApplicationWalletAddress

func GetApplicationWalletAddress(node sqalx.Node, id string) (string, error)

GetApplicationWalletAddress resolves an application's wallet address based on their ID The application must have been launched at least once before

func GetApplicationsWithIDs

func GetApplicationsWithIDs(node sqalx.Node, ids []string) (map[string]*Application, error)

GetApplicationsWithIDs returns the latest version of the applications with the specified IDs

func GetBannedUserWithIDs

func GetBannedUserWithIDs(node sqalx.Node, ids []string) (map[string]*BannedUser, error)

GetBannedUserWithIDs returns the user bans with the specified IDs

func GetConnectionWithIDs

func GetConnectionWithIDs(node sqalx.Node, ids []string) (map[string]*Connection, error)

GetConnectionWithIDs returns the connections with the specified IDs

func GetCountersWithNames

func GetCountersWithNames(node sqalx.Node, names []string) (map[string]*Counter, error)

GetCountersWithNames returns the counters with the specified names

func GetDisallowedMediaCollectionsWithIDs

func GetDisallowedMediaCollectionsWithIDs(node sqalx.Node, ids []string) (map[string]*DisallowedMediaCollection, error)

GetDisallowedMediaCollectionsWithIDs returns the disallowed media cpllections with the specified IDs

func GetDisallowedMediaWithIDs

func GetDisallowedMediaWithIDs(node sqalx.Node, ids []string) (map[string]*DisallowedMedia, error)

GetDisallowedMediaWithIDs returns the disallowed media with the specified IDs

func GetDocumentsWithIDs

func GetDocumentsWithIDs(node sqalx.Node, ids []string) (map[string]*Document, error)

GetDocumentsWithIDs returns the latest version of the documents with the specified IDs

func GetPlayedMediaWithIDs

func GetPlayedMediaWithIDs(node sqalx.Node, ids []string) (map[string]*PlayedMedia, error)

GetPlayedMediaWithIDs returns the played media with the specified IDs

func GetTotalOfRewardBalances

func GetTotalOfRewardBalances(node sqalx.Node) (decimal.Decimal, error)

GetTotalOfRewardBalances returns the sum of all balances

func GetVerifiedUserWithIDs

func GetVerifiedUserWithIDs(node sqalx.Node, ids []string) (map[string]*VerifiedUser, error)

GetVerifiedUserWithIDs returns the user verifications with the specified IDs

func GetWithSelect

func GetWithSelect[T any](node sqalx.Node, sbuilder sq.SelectBuilder) ([]T, error)

GetWithSelect returns a slice of all values for the generic type that match the conditions in sbuilder

func GetWithSelectAndCount

func GetWithSelectAndCount[T any](node sqalx.Node, sbuilder sq.SelectBuilder) ([]T, uint64, error)

GetWithSelect returns a slice of all values for the generic type that match the conditions in sbuilder along with a count of all values ignoring LIMIT or OFFSET clauses

func Insert

func Insert[T any](node sqalx.Node, t ...T) error

Insert inserts values t in the database

func InsertCrowdfundedTransactions

func InsertCrowdfundedTransactions(node sqalx.Node, items []*CrowdfundedTransaction) error

InsertCrowdfundedTransactions inserts the passed received rewards in the database

func InsertMediaQueueEvents

func InsertMediaQueueEvents(node sqalx.Node, items []*MediaQueueEvent) error

InsertMediaQueueEvents inserts the passed received rewards in the database

func InsertPendingWithdrawals

func InsertPendingWithdrawals(node sqalx.Node, items []*PendingWithdrawal) error

InsertPendingWithdrawals inserts the passed pending withdrawals in the database

func InsertReceivedRewards

func InsertReceivedRewards(node sqalx.Node, items []*ReceivedReward) error

InsertReceivedRewards inserts the passed received rewards in the database

func IsMediaAllowed

func IsMediaAllowed(node sqalx.Node, mediaType MediaType, mediaID string) (bool, error)

IsMediaAllowed returns whether the specified media is allowed

func IsMediaCollectionAllowed

func IsMediaCollectionAllowed(node sqalx.Node, collectionType MediaCollectionType, collectionID string) (bool, error)

IsMediaCollectionAllowed returns whether the specified media is allowed

func MustDelete

func MustDelete[T any](node sqalx.Node, t ...T) error

MustDelete deletes values t from the database. MustDelete is like Delete but returns an error when no rows were deleted even though a non-zero argument count was passed

func SetLogger

func SetLogger(l *log.Logger)

SetLogger sets the logger that will be used for verbose output of the functions in this package

func SetMediaOfCrowdfundedTransactionsWithoutMedia

func SetMediaOfCrowdfundedTransactionsWithoutMedia(node sqalx.Node, mediaID string) error

SetMediaOfCrowdfundedTransactionsWithoutMedia sets the ForMedia field of all crowdfunded transactions without one to the specified value

func SumCrowdfundedTransactionsFromAddressSince

func SumCrowdfundedTransactionsFromAddressSince(node sqalx.Node, address string, since time.Time) (decimal.Decimal, error)

SumCrowdfundedTransactionsFromAddressSince returns the sum of all crowdfunded transactions from an address since the specified time

func SumRequestCostsOfAddressSince

func SumRequestCostsOfAddressSince(node sqalx.Node, address string, since time.Time) (decimal.Decimal, error)

SumRequestCostsOfAddressSince returns the sum of all request costs of an address since the specified time

func SumWithdrawalsToAddressSince

func SumWithdrawalsToAddressSince(node sqalx.Node, address string, since time.Time) (decimal.Decimal, error)

SumWithdrawalsToAddressSince returns the sum of all withdrawals to an address since the specified time

func Update

func Update[T any](node sqalx.Node, t ...T) error

Update updates or inserts values t in the database

func ZeroRewardBalanceOfAddresses

func ZeroRewardBalanceOfAddresses(node sqalx.Node, addresses []string) error

ZeroRewardBalanceOfAddresses zeroes the balance of the specified addresses

Types

type ASNumberReputation

type ASNumberReputation struct {
	ASNumber  int `dbKey:"true" dbColumn:"as_number"`
	IsProxy   bool
	CreatedAt time.Time
	UpdatedAt time.Time
}

ASNumberReputation registers the reputation of an Autonomous System by its number

func GetASNumberReputations

func GetASNumberReputations(node sqalx.Node, pagParams *PaginationParams) ([]*ASNumberReputation, uint64, error)

GetASNumberReputations returns all registered reputations

func GetProxyASNumberReputations

func GetProxyASNumberReputations(node sqalx.Node, pagParams *PaginationParams) ([]*ASNumberReputation, uint64, error)

GetProxyASNumberReputations returns all AS numbers marked as proxy

func (*ASNumberReputation) Delete

func (obj *ASNumberReputation) Delete(node sqalx.Node) error

Delete deletes the ASNumberReputation

func (*ASNumberReputation) Update

func (obj *ASNumberReputation) Update(node sqalx.Node) error

Update updates or inserts the ASNumberReputation

type Application

type Application struct {
	ID               string             `dbKey:"true"`
	UpdatedAt        ApplicationVersion `dbKey:"true"`
	UpdatedBy        string
	EditMessage      string
	AllowLaunching   bool
	AllowFileEditing bool
	Autorun          bool
	RuntimeVersion   int
}

Application represents an application

func GetApplications

func GetApplications(node sqalx.Node, filter string, pagParams *PaginationParams) ([]*Application, uint64, error)

func (*Application) Delete

func (obj *Application) Delete(node sqalx.Node) error

Delete deletes the Application

func (*Application) Update

func (obj *Application) Update(node sqalx.Node) error

Update updates or inserts the Application

type ApplicationFile

type ApplicationFile struct {
	ApplicationID string    `dbKey:"true"`
	Name          string    `dbKey:"true"`
	UpdatedAt     time.Time `dbKey:"true"`
	UpdatedBy     string
	EditMessage   string
	Deleted       bool
	Public        bool // whether the file should be served over http
	Type          string
	Content       []byte
}

ApplicationFile represents one of the files used by an application

func (*ApplicationFile) Update

func (obj *ApplicationFile) Update(node sqalx.Node) error

Update updates or inserts the ApplicationFile

type ApplicationFileLike

type ApplicationFileLike interface {
	*ApplicationFile | *ApplicationFileMetadata
}

type ApplicationFileMetadata

type ApplicationFileMetadata struct {
	ApplicationID string    `dbKey:"true"`
	Name          string    `dbKey:"true"`
	UpdatedAt     time.Time `dbKey:"true"`
	UpdatedBy     string
	EditMessage   string
	Deleted       bool
	Public        bool // whether the file should be served over http
	Type          string
}

ApplicationFileMetadata represents metadata about one of the files used by an application This is the same as the ApplicationFile, minus the content, so that listing files does not require bringing their contents from the database. Always use ApplicationFile when performing updates/deletes/insertions on a file

type ApplicationValue

type ApplicationValue struct {
	ApplicationID string `dbKey:"true"`
	Key           string `dbKey:"true"`
	Value         string
}

ApplicationValue represents one of the entries in an application's key-value store

func GetApplicationValue

func GetApplicationValue(node sqalx.Node, applicationID, key string) (*ApplicationValue, error)

GetApplicationValue returns the application value for the specified application and key

func GetApplicationValueByIndex

func GetApplicationValueByIndex(node sqalx.Node, applicationID string, index uint64) (*ApplicationValue, error)

GetApplicationValueByIndex returns the application value at the Nth index (zero-based)

func (*ApplicationValue) Delete

func (obj *ApplicationValue) Delete(node sqalx.Node) error

Update deletes the ApplicationValue

func (*ApplicationValue) Update

func (obj *ApplicationValue) Update(node sqalx.Node) error

Update updates or inserts the ApplicationValue

type ApplicationVersion

type ApplicationVersion time.Time

ApplicationVersion represents the version of an application

func GetEarliestVersionOfApplication

func GetEarliestVersionOfApplication(node sqalx.Node, id string) (ApplicationVersion, error)

GetEarliestVersionOfApplication returns the earliest version of the application with the specified ID

func (ApplicationVersion) MarshalJSON

func (d ApplicationVersion) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface

func (*ApplicationVersion) Scan

func (d *ApplicationVersion) Scan(value interface{}) error

Scan implements the sql.Scanner interface.

func (*ApplicationVersion) UnmarshalJSON

func (d *ApplicationVersion) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler interface

func (ApplicationVersion) Value

func (d ApplicationVersion) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type AuthEvent

type AuthEvent struct {
	Address         string    `dbKey:"true"`
	AuthenticatedAt time.Time `dbKey:"true"`
	Reason          AuthReason
	ReasonInfo      types.JSONText
	Method          AuthMethod
	MethodInfo      types.JSONText
}

AuthEvent is an authentication or authorization event

func (*AuthEvent) Update

func (obj *AuthEvent) Update(node sqalx.Node) error

Update updates or inserts the AuthEvent

type AuthMethod

type AuthMethod string

AuthMethod represents the method used for authentication or authorization

const AuthMethodAccountSignature AuthMethod = "account_public_key_signature"

AuthMethodAccountSignature is used with events where a unique message signed by the account's address was used as the authentication method

const AuthMethodExternal AuthMethod = "external"

AuthMethodExternal is used with events where a trusted external system authenticated the user

const AuthMethodInteractiveConsent AuthMethod = "interactive_consent"

AuthMethodInteractiveConsent is used with events where a third party application is authorized after interactive user consent

const AuthMethodRepresentativeChange AuthMethod = "account_representative_change"

AuthMethodAddressRepresentativeChange is used with events where representative changes were used as the authentication method

type AuthReason

type AuthReason string

AuthReason represents the type of motivation for authentication or authorization

const AuthReasonAuthorizeThirdParty AuthReason = "authorize_third_party"

AuthReasonAuthorizeThirdParty is used with events associated with authorizing a third party application

const AuthReasonSignIn AuthReason = "sign_in"

AuthReasonSignIn is used with events associated with signing in

const AuthReasonSpecialSignIn AuthReason = "special_sign_in"

AuthReasonSpecialSignIn is used with events where a non-standard sign-in method was used

type BannedUser

type BannedUser struct {
	BanID            string `dbKey:"true"`
	BannedAt         time.Time
	BannedUntil      sql.NullTime
	Address          string
	RemoteAddress    string
	FromChat         bool
	FromEnqueuing    bool
	FromRewards      bool
	Reason           string
	UnbanReason      string
	ModeratorAddress string
	ModeratorName    string
}

BannedUser is a user ban

func GetBannedUsers

func GetBannedUsers(node sqalx.Node, filter string, pagParams *PaginationParams) ([]*BannedUser, uint64, error)

GetBannedUsers returns all registered user bans, starting with the most recent one

func GetBannedUsersAtInstant

func GetBannedUsersAtInstant(node sqalx.Node, instant time.Time, filter string, pagParams *PaginationParams) ([]*BannedUser, uint64, error)

GetBannedUsersAtInstant returns a slice with all user bans in effect at the specified instant, starting with the most recent one

func (*BannedUser) Update

func (obj *BannedUser) Update(node sqalx.Node) error

Update updates or inserts the BannedUser

type BlockedUser

type BlockedUser struct {
	ID        string `dbKey:"true"`
	Address   string
	BlockedBy string
	CreatedAt time.Time
}

BlockedUser represents a blocked user

func GetBlockedUserByAddress

func GetBlockedUserByAddress(node sqalx.Node, address string, blockedBy string) (*BlockedUser, error)

GetBlockedUserByID returns the user block specified by the given ID

func GetBlockedUserByID

func GetBlockedUserByID(node sqalx.Node, id string) (*BlockedUser, error)

GetBlockedUserByID returns the user block specified by the given ID

func GetUsersBlockedByAddress

func GetUsersBlockedByAddress(node sqalx.Node, address string, pagParams *PaginationParams) ([]*BlockedUser, uint64, error)

GetUsersBlockedByAddress returns the users blocked by the specified address.

func (*BlockedUser) Delete

func (obj *BlockedUser) Delete(node sqalx.Node) error

Delete deletes the BlockedUser

func (*BlockedUser) Update

func (obj *BlockedUser) Update(node sqalx.Node) error

Update updates or inserts the BlockedUser

type ChatEmote

type ChatEmote struct {
	ID                      int64 `dbKey:"true"`
	Shortcode               string
	Animated                bool
	AvailableForNewMessages bool
	RequiresSubscription    bool
}

ChatEmote represents a chat emote

func GetChatEmotes

func GetChatEmotes(node sqalx.Node, pagParams *PaginationParams) ([]*ChatEmote, uint64, error)

GetChatEmotes returns all chat emotes in the database

func (*ChatEmote) Delete

func (obj *ChatEmote) Delete(node sqalx.Node) error

Delete deletes the ChatEmote

func (*ChatEmote) Update

func (obj *ChatEmote) Update(node sqalx.Node) error

Update updates or inserts the ChatEmote

type Connection

type Connection struct {
	ID                string `dbKey:"true"`
	Service           ConnectionService
	RewardsAddress    string
	Name              string
	CreatedAt         time.Time
	UpdatedAt         time.Time
	OAuthRefreshToken *string `dbColumn:"oauth_refresh_token"`
}

Connection represents a connection between a user identity and an external service

func GetConnectionsForRewardsAddress

func GetConnectionsForRewardsAddress(node sqalx.Node, address string) ([]*Connection, error)

GetConnectionsForRewardsAddress returns the connections of the specified rewards address

func GetConnectionsForServiceAndRewardsAddress

func GetConnectionsForServiceAndRewardsAddress(node sqalx.Node, service ConnectionService, address string) ([]*Connection, error)

GetConnectionsForServiceAndRewardsAddress returns the connections to the given service of the specified rewards address

func (*Connection) Delete

func (obj *Connection) Delete(node sqalx.Node) error

Delete deletes the Connection

func (*Connection) Update

func (obj *Connection) Update(node sqalx.Node) error

Update updates or inserts the Connection

type ConnectionService

type ConnectionService string
const ConnectionServiceCryptomonKeys ConnectionService = "cryptomonkeys"

type Counter

type Counter struct {
	CounterName  string `dbKey:"true"`
	CounterValue int
	UpdatedAt    time.Time
}

Counter is a multipurpose integer counter

func GetCounters

func GetCounters(node sqalx.Node, pagParams *PaginationParams) ([]*Counter, uint64, error)

GetCounters returns all registered counters

func (*Counter) Delete

func (obj *Counter) Delete(node sqalx.Node) error

Delete deletes the Counter

func (*Counter) Update

func (obj *Counter) Update(node sqalx.Node) error

Update updates or inserts the Counter

type CrowdfundedTransaction

type CrowdfundedTransaction struct {
	TxHash          string `dbKey:"true"`
	FromAddress     string
	Amount          decimal.Decimal
	ReceivedAt      time.Time
	TransactionType CrowdfundedTransactionType
	ForMedia        *string
}

CrowdfundedTransaction represents a Skip & Tip transaction received by the service

type CrowdfundedTransactionType

type CrowdfundedTransactionType string
const CrowdfundedTransactionTypeRain CrowdfundedTransactionType = "rain"
const CrowdfundedTransactionTypeSkip CrowdfundedTransactionType = "skip"

type DisallowedMedia

type DisallowedMedia struct {
	ID           string `dbKey:"true"`
	DisallowedBy string
	DisallowedAt time.Time
	MediaType    MediaType
	MediaID      string `dbColumn:"media_id"`
	MediaTitle   string
}

DisallowedMedia is media that can't be played on the service

func GetDisallowedMedia

func GetDisallowedMedia(node sqalx.Node, pagParams *PaginationParams) ([]*DisallowedMedia, uint64, error)

GetDisallowedMedia returns all disallowed media in the database

func GetDisallowedMediaWithFilter

func GetDisallowedMediaWithFilter(node sqalx.Node, filter string, pagParams *PaginationParams) ([]*DisallowedMedia, uint64, error)

GetDisallowedMediaWithFilter returns all disallowed media that matches the specified filter

func GetDisallowedMediaWithType

func GetDisallowedMediaWithType(node sqalx.Node, mediaType MediaType, pagParams *PaginationParams) ([]*DisallowedMedia, uint64, error)

GetDisallowedMediaWithType returns all disallowed media of the specified type

func GetDisallowedMediaWithTypeAndFilter

func GetDisallowedMediaWithTypeAndFilter(node sqalx.Node, mediaType MediaType, filter string, pagParams *PaginationParams) ([]*DisallowedMedia, uint64, error)

GetDisallowedMediaWithTypeAndFilter returns all disallowed media of the given type that matches the specified filter

func (*DisallowedMedia) Delete

func (obj *DisallowedMedia) Delete(node sqalx.Node) error

Delete deletes the DisallowedMedia

func (*DisallowedMedia) Update

func (obj *DisallowedMedia) Update(node sqalx.Node) error

Update updates or inserts the DisallowedMedia

type DisallowedMediaCollection

type DisallowedMediaCollection struct {
	ID              string `dbKey:"true"`
	DisallowedBy    string
	DisallowedAt    time.Time
	CollectionType  MediaCollectionType
	CollectionID    string `dbColumn:"collection_id"`
	CollectionTitle string
}

DisallowedMediaCollection is a set of media that can't be played on the service

func GetDisallowedMediaCollectionWithType

func GetDisallowedMediaCollectionWithType(node sqalx.Node, collectionType MediaCollectionType, pagParams *PaginationParams) ([]*DisallowedMediaCollection, uint64, error)

GetDisallowedMediaCollectionWithType returns all disallowed media collections of the specified type

func GetDisallowedMediaCollections

func GetDisallowedMediaCollections(node sqalx.Node, pagParams *PaginationParams) ([]*DisallowedMediaCollection, uint64, error)

GetDisallowedMediaCollections returns all disallowed media collections in the database

func GetDisallowedMediaCollectionsWithFilter

func GetDisallowedMediaCollectionsWithFilter(node sqalx.Node, filter string, pagParams *PaginationParams) ([]*DisallowedMediaCollection, uint64, error)

GetDisallowedMediaCollectionsWithFilter returns all disallowed media collections that match the specified filter

func GetDisallowedMediaCollectionsWithTypeAndFilter

func GetDisallowedMediaCollectionsWithTypeAndFilter(node sqalx.Node, collectionType MediaCollectionType, filter string, pagParams *PaginationParams) ([]*DisallowedMediaCollection, uint64, error)

GetDisallowedMediaCollectionsWithTypeAndFilter returns all disallowed media collections of the given type that match the specified filter

func (*DisallowedMediaCollection) Delete

func (obj *DisallowedMediaCollection) Delete(node sqalx.Node) error

Delete deletes the DisallowedMediaCollection

func (*DisallowedMediaCollection) Update

func (obj *DisallowedMediaCollection) Update(node sqalx.Node) error

Update updates or inserts the DisallowedMediaCollection

type Document

type Document struct {
	ID        string    `dbKey:"true"`
	UpdatedAt time.Time `dbKey:"true"`
	UpdatedBy string
	Public    bool
	Format    string
	Content   string
}

Document represents a document

func GetDocuments

func GetDocuments(node sqalx.Node, filter string, pagParams *PaginationParams) ([]*Document, uint64, error)

func (*Document) Delete

func (obj *Document) Delete(node sqalx.Node) error

Delete deletes the Document

func (*Document) Update

func (obj *Document) Update(node sqalx.Node) error

Update updates or inserts the Document

type Duration

type Duration time.Duration

Duration wraps a time.Duration with custom methods for serialization

func CountRequestsOfAddressSince

func CountRequestsOfAddressSince(node sqalx.Node, address string, since time.Time) (int, Duration, error)

CountRequestsOfAddressSince returns the count and total play time of all the requests by an address since the specified time

func (*Duration) Scan

func (d *Duration) Scan(value interface{}) error

Scan implements the sql.Scanner interface.

func (Duration) Value

func (d Duration) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type GetPlayedMediaFilters

type GetPlayedMediaFilters struct {
	ExcludeDisallowed       bool
	ExcludeCurrentlyPlaying bool
	StartedSince            time.Time
	StartedUntil            time.Time
	EnqueuedSince           time.Time
	EnqueuedUntil           time.Time
	TextFilter              string
	OrderBy                 GetPlayedMediaOrderBy
}

GetPlayedMediaFilters contains the filters to pass to GetPlayedMedia. Different conditions are ANDed together

type GetPlayedMediaOrderBy

type GetPlayedMediaOrderBy string

GetPlayedMediaOrderBy specifies how to order the results of GetPlayedMedia

var GetPlayedMediaOrderByEnqueuedAtAsc GetPlayedMediaOrderBy = "played_media.enqueued_at ASC"

GetPlayedMediaOrderByEnqueuedAtAsc sorts the results of GetPlayedMedia by EnqueuedAt in ascending order

var GetPlayedMediaOrderByEnqueuedAtDesc GetPlayedMediaOrderBy = "played_media.enqueued_at DESC"

GetPlayedMediaOrderByEnqueuedAtDesc sorts the results of GetPlayedMedia by EnqueuedAt in descending order

var GetPlayedMediaOrderByStartedAtAsc GetPlayedMediaOrderBy = "played_media.started_at ASC"

GetPlayedMediaOrderByStartedAtAsc sorts the results of GetPlayedMedia by StartedAt in ascending order

var GetPlayedMediaOrderByStartedAtDesc GetPlayedMediaOrderBy = "played_media.started_at DESC"

GetPlayedMediaOrderByStartedAtDesc sorts the results of GetPlayedMedia by StartedAt in descending order

type MediaCollectionType

type MediaCollectionType string
const MediaCollectionTypeSoundCloudUser MediaCollectionType = "sc_user"
const MediaCollectionTypeYouTubeChannel MediaCollectionType = "yt_channel"

type MediaQueueEvent

type MediaQueueEvent struct {
	CreatedAt time.Time `dbKey:"true"`
	EventType MediaQueueEventType
}

MediaQueueEvent represents a noteworthy media queue event

func GetMostRecentMediaQueueEventWithType

func GetMostRecentMediaQueueEventWithType(node sqalx.Node, eventType ...MediaQueueEventType) (*MediaQueueEvent, error)

GetMostRecentMediaQueueEventWithType returns the most recent media queue event with the given type

type MediaQueueEventType

type MediaQueueEventType string

MediaQueueEventType represents a type of media queue event

const MediaQueueEmptied MediaQueueEventType = "emptied"

MediaQueueEmptied is the media queue event type for when the queue becomes empty

const MediaQueueFilled MediaQueueEventType = "filled"

MediaQueueFilled is the media queue event type for when the queue becomes non-empty

type MediaType

type MediaType string
const MediaTypeApplicationPage MediaType = "app_page"
const MediaTypeDocument MediaType = "document"
const MediaTypeSoundCloudTrack MediaType = "sc_track"
const MediaTypeYouTubeVideo MediaType = "yt_video"

type PaginationParams

type PaginationParams struct {
	Offset uint64
	Limit  uint64
}

PaginationParams contains parameters needed for pagination

type PendingWithdrawal

type PendingWithdrawal struct {
	RewardsAddress string `dbKey:"true"`
	Amount         decimal.Decimal
	StartedAt      time.Time
}

PendingWithdrawal represents a withdrawal that has been initiated but is not yet completed

func GetPendingWithdrawals

func GetPendingWithdrawals(node sqalx.Node) ([]*PendingWithdrawal, error)

GetPendingWithdrawals returns all pending withdrawals

func (*PendingWithdrawal) Delete

func (obj *PendingWithdrawal) Delete(node sqalx.Node) error

Delete deletes the PendingWithdrawal and errors if the pending withdrawal no longer exists

type PlayedMedia

type PlayedMedia struct {
	ID          string `dbKey:"true"`
	EnqueuedAt  time.Time
	StartedAt   time.Time
	EndedAt     sql.NullTime
	MediaLength Duration
	MediaOffset Duration
	RequestedBy string
	RequestCost decimal.Decimal
	Unskippable bool
	MediaType   MediaType
	MediaID     string `dbColumn:"media_id"`
	MediaInfo   types.JSONText
}

PlayedMedia is media that has played on the service

func GetPlayedMedia

func GetPlayedMedia(node sqalx.Node, filters GetPlayedMediaFilters, pagParams *PaginationParams) ([]*PlayedMedia, uint64, error)

GetPlayedMedia returns all played media in the database according to the given filters

func GetPlayedMediaRequestedBySince

func GetPlayedMediaRequestedBySince(node sqalx.Node, requestedBy string, since time.Time) ([]*PlayedMedia, error)

GetPlayedMediaRequestedBySince returns the played media that had been requested by the given address and which is playing or has finished playing since the specified moment

func LastPlaysOfMedia

func LastPlaysOfMedia(node sqalx.Node, since time.Time, mediaType MediaType, mediaID string) ([]*PlayedMedia, error)

LastPlaysOfMedia returns the times the specified media was played since the specified time

func LastRequestsOfAddress

func LastRequestsOfAddress(node sqalx.Node, address string, count int, excludeDisallowed bool) ([]*PlayedMedia, error)

LastRequestsOfAddress returns the most recent played medias requested by the specified address

func (*PlayedMedia) Delete

func (obj *PlayedMedia) Delete(node sqalx.Node) error

Delete deletes the PlayedMedia

func (*PlayedMedia) Update

func (obj *PlayedMedia) Update(node sqalx.Node) error

Update updates or inserts the PlayedMedia

type PlayedMediaRaffleEntry

type PlayedMediaRaffleEntry struct {
	TicketNumber int `dbColumnRaw:"ROW_NUMBER() OVER (ORDER BY played_media.started_at) AS ticket_number"`
	RequestedBy  string
	MediaID      string `dbColumn:"media_id"`
}

PlayedMediaRaffleEntry is the raffle entry representation of a played media entry It corresponds to the same DB entry as PlayedMedia, it's just a different "view" over it

func GetPlayedMediaRaffleEntriesBetween

func GetPlayedMediaRaffleEntriesBetween(node sqalx.Node, onOrAfter time.Time, before time.Time) ([]*PlayedMediaRaffleEntry, error)

GetPlayedMediaRaffleEntriesBetween returns the played media raffle entries in the specified time period

type PointsBalance

type PointsBalance struct {
	RewardsAddress string `dbKey:"true"`
	Balance        int
}

PointsBalance is the points balance of an address

func GetPointsBalanceForAddress

func GetPointsBalanceForAddress(node sqalx.Node, address string) (*PointsBalance, error)

GetPointsBalanceForAddress returns the points balance of the given address

type PointsTx

type PointsTx struct {
	ID             int64 `dbKey:"true"`
	RewardsAddress string
	CreatedAt      time.Time
	UpdatedAt      time.Time
	Value          int
	Type           PointsTxType
	Extra          types.JSONText
}

PointsTx is a points transaction

func GetLatestPointsTxForAddress

func GetLatestPointsTxForAddress(node sqalx.Node, address string) (*PointsTx, error)

GetLatestPointsTxForAddress returns the most recent points transaction for the given address

func GetLatestPointsTxOfTypeForAddress

func GetLatestPointsTxOfTypeForAddress(node sqalx.Node, txType PointsTxType, address string) (*PointsTx, error)

GetLatestPointsTxForAddress returns the most recent points transaction of the given type for the given address

func GetPointsTxForAddress

func GetPointsTxForAddress(node sqalx.Node, address string, pagParams *PaginationParams) ([]*PointsTx, uint64, error)

GetPointsTxForAddress returns all the points transactions for the given address

func (*PointsTx) AdjustValue

func (obj *PointsTx) AdjustValue(node sqalx.Node, value int) error

AdjustValue adjusts the value of the PointsTx by the specified amount.

func (*PointsTx) Insert

func (obj *PointsTx) Insert(node sqalx.Node) error

Insert inserts the PointsTx

type PointsTxType

type PointsTxType int
const (
	PointsTxTypeActivityChallengeReward     PointsTxType = 1
	PointsTxTypeChatActivityReward          PointsTxType = 2
	PointsTxTypeMediaEnqueuedReward         PointsTxType = 3
	PointsTxTypeChatGifAttachment           PointsTxType = 4
	PointsTxTypeManualAdjustment            PointsTxType = 5
	PointsTxTypeMediaEnqueuedRewardReversal PointsTxType = 6
	PointsTxTypeConversionFromBanano        PointsTxType = 7
	PointsTxTypeQueueEntryReordering        PointsTxType = 8
	PointsTxTypeMonthlySubscription         PointsTxType = 9
	PointsTxTypeSkipThresholdReduction      PointsTxType = 10
	PointsTxTypeSkipThresholdIncrease       PointsTxType = 11
	PointsTxTypeConcealedEntryEnqueuing     PointsTxType = 12
	PointsTxTypeApplicationDefined          PointsTxType = 13
)

type RaffleDrawing

type RaffleDrawing struct {
	RaffleID              string `dbKey:"true"`
	DrawingNumber         int    `dbKey:"true"`
	PeriodStart           time.Time
	PeriodEnd             time.Time
	Status                RaffleDrawingStatus
	Reason                string
	Plaintext             *string
	VRFHash               *string `db:"vrf_hash"`
	VRFProof              *string `db:"vrf_proof"`
	WinningTicketNumber   *int
	WinningRewardsAddress *string
	PrizeTxHash           *string
}

RaffleDrawing is one of the drawings of a raffle

func GetRaffleDrawings

func GetRaffleDrawings(node sqalx.Node, pagParams *PaginationParams) ([]*RaffleDrawing, uint64, error)

GetRaffleDrawings returns all the raffle drawings

func GetRaffleDrawingsOfRaffle

func GetRaffleDrawingsOfRaffle(node sqalx.Node, raffleID string) ([]*RaffleDrawing, error)

GetRaffleDrawingsOfRaffle returns all the drawings for a raffle

func (*RaffleDrawing) Delete

func (obj *RaffleDrawing) Delete(node sqalx.Node) error

Delete deletes the RaffleDrawing

func (*RaffleDrawing) Update

func (obj *RaffleDrawing) Update(node sqalx.Node) error

Update updates or inserts the RaffleDrawing

type RaffleDrawingStatus

type RaffleDrawingStatus string
const RaffleDrawingStatusComplete RaffleDrawingStatus = "complete"
const RaffleDrawingStatusConfirmed RaffleDrawingStatus = "confirmed"
const RaffleDrawingStatusOngoing RaffleDrawingStatus = "ongoing"
const RaffleDrawingStatusPending RaffleDrawingStatus = "pending"
const RaffleDrawingStatusVoided RaffleDrawingStatus = "voided"

type ReceivedReward

type ReceivedReward struct {
	ID             string `dbKey:"true"`
	RewardsAddress string
	ReceivedAt     time.Time
	Amount         decimal.Decimal
	Media          string
}

ReceivedReward represents a reward received by a user for consuming media

func GetReceivedRewardsForAddress

func GetReceivedRewardsForAddress(node sqalx.Node, address string, pagParams *PaginationParams) ([]*ReceivedReward, uint64, error)

GetReceivedRewardsForAddress returns received rewards for the specified address, starting with the latest

type RewardBalance

type RewardBalance struct {
	RewardsAddress string          `db:"rewards_address" dbKey:"true"`
	Balance        decimal.Decimal `db:"balance"`
	UpdatedAt      time.Time       `db:"updated_at"`
}

RewardBalance represents the balance of not-yet-withdrawn rewards for a user

func AdjustRewardBalanceOfAddresses

func AdjustRewardBalanceOfAddresses(node sqalx.Node, addresses []string, amount decimal.Decimal) ([]*RewardBalance, error)

AdjustRewardBalanceOfAddresses adjusts the balance of the specified addresses by the specified amount

func GetRewardBalanceOfAddress

func GetRewardBalanceOfAddress(node sqalx.Node, address string) (*RewardBalance, error)

GetRewardBalanceOfAddress returns the reward balance for the specified address, if one exists

func GetRewardBalancesReadyForAutoWithdrawal

func GetRewardBalancesReadyForAutoWithdrawal(node sqalx.Node, minBalance decimal.Decimal, unchangedSince time.Time) ([]*RewardBalance, error)

GetRewardBalancesReadyForAutoWithdrawal returns rewards balances that are ready for automated withdrawal according to the passed parameters

type SpendingLeaderboardEntry

type SpendingLeaderboardEntry struct {
	RowNum        int
	Position      int
	Address       string
	Nickname      string
	ApplicationID string
	TotalSpent    decimal.Decimal
}

SpendingLeaderboardEntry represents a enqueue leaderboard entry

func CrowdfundedTransactionLeaderboardBetween

func CrowdfundedTransactionLeaderboardBetween(node sqalx.Node, start, end time.Time, txType CrowdfundedTransactionType, size int, showNeighbors int, mustIncludes ...string) ([]SpendingLeaderboardEntry, error)

CrowdfundedTransactionLeaderboardBetween returns the community skip or the community tipping leaderboard for the specified period

func EnqueueLeaderboardBetween

func EnqueueLeaderboardBetween(node sqalx.Node, start, end time.Time, size int, showNeighbors int, mustIncludes ...string) ([]SpendingLeaderboardEntry, error)

EnqueueLeaderboardBetween returns the enqueue leaderboard for the specified period

func GlobalSpendingLeaderboardBetween

func GlobalSpendingLeaderboardBetween(node sqalx.Node, start, end time.Time, size int, showNeighbors int, mustIncludes ...string) ([]SpendingLeaderboardEntry, error)

GlobalSpendingLeaderboardBetween returns the leaderboard for all forms of spending for the specified period

type Subscription

type Subscription struct {
	RewardsAddress string    `dbKey:"true"`
	StartsAt       time.Time `dbKey:"true"`
	EndsAt         time.Time
	PaymentTxs     pq.Int64Array
}

Subscription represents a user subscription

func GetCurrentSubscriptionAtTime

func GetCurrentSubscriptionAtTime(node sqalx.Node, address string, at time.Time) (*Subscription, error)

GetCurrentSubscription returns the current subscription for the given address at the given time, or ErrNoCurrentSubscription if the address is/was not subscribed at the given time

func GetSubscriptions

func GetSubscriptions(node sqalx.Node, pagParams *PaginationParams) ([]*Subscription, uint64, error)

GetSubscriptions returns all subscriptions in the database

func (*Subscription) Update

func (obj *Subscription) Update(node sqalx.Node) error

Update updates or inserts the Subscription

type UserJWTClaimSeason

type UserJWTClaimSeason struct {
	Address   string `dbKey:"true"`
	Season    int
	UpdatedAt time.Time
}

UserJWTClaimSeason is the JWT claims season of a user

func GetUserJWTClaimSeason

func GetUserJWTClaimSeason(node sqalx.Node, address string) (*UserJWTClaimSeason, error)

GetUserJWTClaimSeason returns the UserJWTClaimSeason for the specified user address

func (*UserJWTClaimSeason) Delete

func (obj *UserJWTClaimSeason) Delete(node sqalx.Node) error

Delete deletes the UserJWTClaimSeason

func (*UserJWTClaimSeason) Update

func (obj *UserJWTClaimSeason) Update(node sqalx.Node) error

Update updates or inserts the UserJWTClaimSeason

type UserProfile

type UserProfile struct {
	Address       string `dbKey:"true"`
	Biography     string
	FeaturedMedia *string
}

UserProfile represents a user profile

func GetUserProfileForAddress

func GetUserProfileForAddress(node sqalx.Node, address string) (*UserProfile, error)

GetUserProfileForAddress returns the user profile for the specified address. If a profile does not exist, an empty one is returned

func (*UserProfile) Delete

func (obj *UserProfile) Delete(node sqalx.Node) error

Delete deletes the UserProfile

func (*UserProfile) Update

func (obj *UserProfile) Update(node sqalx.Node) error

Update updates or inserts the UserProfile

type VerifiedUser

type VerifiedUser struct {
	ID                            string `dbKey:"true"`
	Address                       string
	CreatedAt                     time.Time
	SkipClientIntegrityChecks     bool
	SkipIPAddressReputationChecks bool `dbColumn:"skip_ip_address_reputation_checks"`
	ReduceHardChallengeFrequency  bool
	Reason                        string
	ModeratorAddress              string
	ModeratorName                 string
}

VerifiedUser represents a blocked user

func GetVerifiedUsers

func GetVerifiedUsers(node sqalx.Node, filter string, pagParams *PaginationParams) ([]*VerifiedUser, uint64, error)

GetVerifiedUsers returns all registered user verifications, starting with the most recent one

func (*VerifiedUser) Delete

func (obj *VerifiedUser) Delete(node sqalx.Node) error

Delete deletes the VerifiedUser

func (*VerifiedUser) Update

func (obj *VerifiedUser) Update(node sqalx.Node) error

Update updates or inserts the VerifiedUser

type Withdrawal

type Withdrawal struct {
	TxHash         string `dbKey:"true"`
	RewardsAddress string
	Amount         decimal.Decimal
	StartedAt      time.Time
	CompletedAt    time.Time
}

Withdrawal represents a completed withdrawal

func GetWithdrawal

func GetWithdrawal(node sqalx.Node, txHash string) (*Withdrawal, error)

GetWithdrawal returns the completed withdrawal with the given hash

func GetWithdrawals

func GetWithdrawals(node sqalx.Node, pagParams *PaginationParams) ([]*Withdrawal, uint64, error)

GetWithdrawals returns all completed withdrawals in the database

func GetWithdrawalsCompletedBetween

func GetWithdrawalsCompletedBetween(node sqalx.Node, after, before time.Time, pagParams *PaginationParams) ([]*Withdrawal, uint64, error)

GetWithdrawalsCompletedBefore returns the withdrawals completed in the specified interval

func GetWithdrawalsForAddress

func GetWithdrawalsForAddress(node sqalx.Node, address string, pagParams *PaginationParams) ([]*Withdrawal, uint64, error)

GetWithdrawalsForAddress returns completed withdrawals to the specified address, starting with the latest

func (*Withdrawal) Delete

func (obj *Withdrawal) Delete(node sqalx.Node) error

Delete deletes the Withdrawal

func (*Withdrawal) Insert

func (obj *Withdrawal) Insert(node sqalx.Node) error

Insert inserts the Withdrawal

Jump to

Keyboard shortcuts

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