Documentation ¶
Index ¶
- func ActiveRoundentries(userID int) (roundentries []vbcore.Roundentry, success bool)
- func ActiveRoundentriesCtx(userID int, ctx *zap.Logger) (roundentries []vbcore.Roundentry, success bool)
- func ActiveRounds() (lobbies []vbcore.Round, success bool)
- func ActiveRoundsCtx(ctx *zap.Logger) (rounds []vbcore.Round, success bool)
- func CountGames() int
- func CountGamesCtx(ctx *zap.Logger) int
- func CountUsers() int
- func CountUsersCtx(ctx *zap.Logger) int
- func ExistsMessage(id int64) (exists bool, err error)
- func Init(config *Config, logCtx *zap.Logger) (err error)
- func InsertMessage(msg string) (id int64, err error)
- func JoinRound(userID, roundID int) (alreadyJoined, success bool)
- func JoinRoundCtx(userID, roundID int, ctx *zap.Logger) (alreadyJoined, success bool)
- func JoinedUsers(roundID int) (joined []int, success bool)
- func JoinedUsersCtx(roundID int, ctx *zap.Logger) (joined []int, success bool)
- func JwtAdd(jti string, exp time.Time, userID int, iat time.Time, ip string) (success bool)
- func JwtAddCtx(jti string, exp time.Time, userID int, iat time.Time, ip string, ...) (success bool)
- func JwtIsBlacklisted(jti string) (blacklisted bool, success bool)
- func JwtIsBlacklistedCtx(jti string, ctx *zap.Logger) (blacklisted bool, success bool)
- func OAuthExists(providerID string, provider string) (userID int, exists bool, success bool)
- func OAuthExistsCtx(providerID string, provider string, ctx *zap.Logger) (userID int, exists bool, success bool)
- func RegcodeFromUserID(userID int) (code string, finished bool, success bool)
- func RegcodeFromUserIDCtx(userID int, ctx *zap.Logger) (code string, finished bool, success bool)
- func RegisterOauthGithub(user *github.User) (userID int, code string, success bool)
- func RegisterOauthGithubCtx(u *github.User, ctx *zap.Logger) (userID int, code string, success bool)
- func RegisterOauthGoogle(user *vbcore.GoogleUser) (userID int, code string, success bool)
- func RegisterOauthGoogleCtx(u *vbcore.GoogleUser, ctx *zap.Logger) (userID int, code string, success bool)
- func RegisterUser(user vbcore.User, msg string) (userID int, regCode string, success bool)
- func RegisterUserCtx(user vbcore.User, msg string, ctx *zap.Logger) (userID int, regCode string, success bool)
- func RoundExists(roundID int) (exists, success bool)
- func RoundExistsCtx(roundID int, ctx *zap.Logger) (exists, success bool)
- func RoundentryConnectinfo(authtoken string) (connectinfo *vbcore.RoundentryConnectinfo, exists bool, success bool)
- func RoundentryConnectinfoCtx(authtoken string, ctx *zap.Logger) (connectinfo *vbcore.RoundentryConnectinfo, exists bool, success bool)
- func RoundentryFromRoundticket(roundticket string) (verification *vbcore.RoundentryVerification, exists bool, success bool)
- func RoundentryFromRoundticketCtx(roundticket string, ctx *zap.Logger) (verification *vbcore.RoundentryVerification, exists bool, success bool)
- func RoundentryFromWatchtoken(watchtoken string) (verification *vbcore.RoundentryVerification, exists bool, success bool)
- func RoundentryFromWatchtokenCtx(watchtoken string, ctx *zap.Logger) (verification *vbcore.RoundentryVerification, exists bool, success bool)
- func SelectMessage(id int64) (msg string, exists bool, err error)
- func SelectMessageExists(id int64) (msg *string, err error)
- func UpdateUser(newUser *vbcore.User, oldUser *vbcore.SafeUser, msg string) (success bool)
- func UpdateUserCtx(newUser *vbcore.User, oldUser *vbcore.SafeUser, msg string, ctx *zap.Logger) (success bool)
- func UpdateUserEmailStatus(userID int, email string, status int) (success bool)
- func UpdateUserEmailStatusCtx(userID int, email string, status int, ctx *zap.Logger) (success bool)
- func UserDeleteSocialExpectCtx(userID int, social []string, ctx *zap.Logger) (success bool)
- func UserDeleteWebExpectCtx(userID int, web []string, ctx *zap.Logger) (success bool)
- func UserEmailVerificationIsCtx(userID int, email string, verificationCode string, ctx *zap.Logger) (verified bool, success bool)
- func UserEmailVerificationLoadCtx(userID int, email string, ctx *zap.Logger) (lastSent *time.Time, valid bool, succes bool)
- func UserEmailVerificationSetCtx(userID int, email string, verificationCode string, ctx *zap.Logger) (success bool)
- func UserFromID(userID int) (user *vbcore.SafeUser, success bool)
- func UserFromIDCtx(userID int, ctx *zap.Logger) (user *vbcore.SafeUser, success bool)
- func UserFromUsername(username string, ctx *zap.Logger) (user *vbcore.SafeUser, success bool)
- func UserFromUsernameCtx(username string, ctx *zap.Logger) (user *vbcore.SafeUser, success bool)
- func UserIDFromRegcode(code string) (userID int, finished bool, success bool)
- func UserIDFromRegcodeCtx(code string, ctx *zap.Logger) (userID int, finished bool, success bool)
- func UserIDFromUsername(username string) (userID int, exists bool, success bool)
- func UserIDFromUsernameCtx(username string, ctx *zap.Logger) (userID int, exists bool, success bool)
- func UserPermission(userID int) (permission int, success bool)
- func UserPermissionCtx(userID int, ctx *zap.Logger) (permission int, success bool)
- func UserSetRegistrationDoneCtx(userID int, ctx *zap.Logger) (success bool)
- func UsernameFromID(userID int) (username string, success bool)
- func UsernameFromIDCtx(userID int, ctx *zap.Logger) (username string, success bool)
- func UsernamesFromRoundID(roundID int) (usernames map[int]string, success bool)
- func UsernamesFromRoundIDCtx(roundID int, ctx *zap.Logger) (usernames map[int]string, success bool)
- func WebsocketAddressFromWatchtokenCtx(watchtoken string, ctx *zap.Logger) (websocket string, exists, success bool)
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActiveRoundentries ¶
func ActiveRoundentries(userID int) (roundentries []vbcore.Roundentry, success bool)
ActiveRoundentries is the same as `ActiveRoundentriesCtx` but uses the `defaultCtx` as logger.
func ActiveRoundentriesCtx ¶
func ActiveRoundentriesCtx(userID int, ctx *zap.Logger) (roundentries []vbcore.Roundentry, success bool)
ActiveRoundentriesCtx returns all Roundentries from a user, for games which are currently of status `vbcore.RoundStatusOpen`, `vbcore.RoundStatusClosed` or `vbcore.RoundStatusRunning`. Doesn't returns Roundentries for already finished games (e.g. `vbcore.RoundStatusFinished`).
func ActiveRounds ¶
ActiveRounds is the same as `ActiveRoundsCtx` but uses the `defaultCtx` as logger.
func ActiveRoundsCtx ¶
ActiveRoundsCtx loads all rounds which have not status `vbcore.RoundStatusFinished`.
func CountGames ¶
func CountGames() int
CountGames is the same as `CountGamesCtx` but uses the `defaultCtx` as logger.
func CountGamesCtx ¶
CountGamesCtx adds up all existing roundentries. Example: There are three rounds in the database and all were joined by 20 players. Therefore `3 x 20 = 60` will be returned.
func CountUsers ¶
func CountUsers() int
CountUsers is the same as `CountUsersCtx` but uses the `defaultCtx` as logger.
func CountUsersCtx ¶
CountUsersCtx adds up the amount of all registered users
func ExistsMessage ¶
ExistsMessage checks wheter the id (and therefore) it's associated value exist or not.
func Init ¶
Init initializes all internally used structures of vbdb. E.g. a database connection pool is created and connections get established. If any errors occur durring initialization the error will be returned. The passed zap instance is saved and used as default throughout the package if no explicit logging-context is provided
func InsertMessage ¶
InsertMessage inserts the passed string into the msg table and returns the auto-incremented id (foreign-key in other tables).
func JoinRoundCtx ¶
JoinRoundCtx lets the user join the specified round. The first return value `alreadyJoined` indicates if the user has already joined the team and the call is redundent.
func JoinedUsers ¶
JoinedUsers is the same as `JoinedUsersCtx` but uses the `defaultCtx` as logger.
func JoinedUsersCtx ¶
JoinedUsersCtx returns the `userID`s of all users which joined the round specified through the roundID.
func JwtAddCtx ¶
func JwtAddCtx(jti string, exp time.Time, userID int, iat time.Time, ip string, ctx *zap.Logger) (success bool)
JwtAddCtx adds the passed `jti` (JWT ID), `exp` and `userID` into the `jwts` table as valid entries. Can later be modified to invalid (e.g. blacklisted)
func JwtIsBlacklisted ¶
JwtIsBlacklisted is the same as `JwtIsBlacklistedCtx` but uses the `defaultCtx` as logger.
func JwtIsBlacklistedCtx ¶
JwtIsBlacklistedCtx checks whether the passed `jti` (JWT ID) is already blacklisted or not
func OAuthExists ¶
OAuthExists is the same as `OAuthExistsCtx` but uses the `defaultCtx` as logger.
func OAuthExistsCtx ¶
func OAuthExistsCtx(providerID string, provider string, ctx *zap.Logger) (userID int, exists bool, success bool)
OAuthExistsCtx checks if the `providerID` is already registered with the specified `provider`. If so the associated `userID` (from vikebot) is returned.
func RegcodeFromUserID ¶
RegcodeFromUserID is the same as `RegcodeFromUserIDCtx` but uses the `defaultCtx` as logger.
func RegcodeFromUserIDCtx ¶
RegcodeFromUserIDCtx exchanged a `userID` to it's associated registration code and a `finished` state (indicating the state of the registration).
func RegisterOauthGithub ¶
RegisterOauthGithub is the same as `RegisterOauthGithubCtx` but uses the `defaultCtx` as logger.
func RegisterOauthGithubCtx ¶
func RegisterOauthGithubCtx(u *github.User, ctx *zap.Logger) (userID int, code string, success bool)
RegisterOauthGithubCtx maps the `*github.User` instance to a `vbcore.User` and passes it to `RegisterUserCtx`.
func RegisterOauthGoogle ¶
func RegisterOauthGoogle(user *vbcore.GoogleUser) (userID int, code string, success bool)
RegisterOauthGoogle is the same as `RegisterOauthGoogleCtx` but uses the `defaultCtx` as logger.
func RegisterOauthGoogleCtx ¶
func RegisterOauthGoogleCtx(u *vbcore.GoogleUser, ctx *zap.Logger) (userID int, code string, success bool)
RegisterOauthGoogleCtx maps the `*vbcore.GoogleUser` instance to a `vbcore.User` and passes it to `RegisterUserCtx`.
func RegisterUser ¶
RegisterUser is the same as `RegisterUserCtx` but uses the `defaultCtx` as logger.
func RegisterUserCtx ¶
func RegisterUserCtx(user vbcore.User, msg string, ctx *zap.Logger) (userID int, regCode string, success bool)
RegisterUserCtx registers a new user and returns the user's ID, the msgID used for all inserts and a registration code (which the user must use in order to register later).
func RoundExists ¶
RoundExists is the same as `RoundExistsCtx` but uses the `defaultCtx` as logger.
func RoundExistsCtx ¶
RoundExistsCtx checks whether a round specified by it's ID exists or not
func RoundentryConnectinfo ¶
func RoundentryConnectinfo(authtoken string) (connectinfo *vbcore.RoundentryConnectinfo, exists bool, success bool)
RoundentryConnectinfo is the same as `RoundentryConnectinfoCtx` but uses the `defaultCtx` as logger.
func RoundentryConnectinfoCtx ¶
func RoundentryConnectinfoCtx(authtoken string, ctx *zap.Logger) (connectinfo *vbcore.RoundentryConnectinfo, exists bool, success bool)
RoundentryConnectinfoCtx returns everything needed to connect to the `vbgs` instance hosting the game associated with the `authtoken`.
func RoundentryFromRoundticket ¶
func RoundentryFromRoundticket(roundticket string) (verification *vbcore.RoundentryVerification, exists bool, success bool)
RoundentryFromRoundticket is the same as `RoundentryFromRoundticketCtx` but uses the `defaultCtx` as logger.
func RoundentryFromRoundticketCtx ¶
func RoundentryFromRoundticketCtx(roundticket string, ctx *zap.Logger) (verification *vbcore.RoundentryVerification, exists bool, success bool)
RoundentryFromRoundticketCtx verifies that a user passed `roundticket` exists in the database. If so informations about the specific `roundentry` are returned so further verifications can be performed.
func RoundentryFromWatchtoken ¶
func RoundentryFromWatchtoken(watchtoken string) (verification *vbcore.RoundentryVerification, exists bool, success bool)
RoundentryFromWatchtoken is the same as `RoundentryFromWatchtokenCtx` but uses the `defaultCtx` as logger.
func RoundentryFromWatchtokenCtx ¶
func RoundentryFromWatchtokenCtx(watchtoken string, ctx *zap.Logger) (verification *vbcore.RoundentryVerification, exists bool, success bool)
RoundentryFromWatchtokenCtx verifies that a user passed `watchtoken` exists in the database. If so informations about the specific `roundentry` are returned so further verifications can be performed.
func SelectMessage ¶
SelectMessage receives the message associated to the passed id.
func SelectMessageExists ¶
SelectMessageExists checks whether the id (and therefore) it's associated value exists or not and if so also returns the value. If the id doesn't exists the msg pointer will be nil.
func UpdateUser ¶
UpdateUser is the same as `UpdateUserCtx` but uses the `defaultCtx` as logger.
func UpdateUserCtx ¶
func UpdateUserCtx(newUser *vbcore.User, oldUser *vbcore.SafeUser, msg string, ctx *zap.Logger) (success bool)
UpdateUserCtx compares a newUser with an oldUser and updates the differences into the database. The msg parameter is used to safe some kind of log message how this update come about. This func uses SQL-transactions, hence the complete update process only failes or succeeds - nothing in between.
func UpdateUserEmailStatus ¶
func UserDeleteWebExpectCtx ¶
func UserFromID ¶
UserFromID is the same as `UserFromIDCtx` but uses the `defaultCtx` as logger.
func UserFromIDCtx ¶
UserFromIDCtx loads the user associated with the given `userID`. Returns `nil` if the user isn't found.
func UserFromUsername ¶
UserFromUsername is the same as `UserFromUsernameCtx` but uses the `defaultCtx` as logger.
func UserFromUsernameCtx ¶
UserFromUsernameCtx loads the user associated with the given `username`. Returns `nil` if the user isn't found.
func UserIDFromRegcode ¶
UserIDFromRegcode is the same as `UserIDFromRegcodeCtx` but uses the `defaultCtx` as logger.
func UserIDFromRegcodeCtx ¶
UserIDFromRegcodeCtx exchanges a registration code for a `userID` and a `finished` state (indicating the state of the registration).
func UserIDFromUsername ¶
UserIDFromUsername is the same as `UserIDFromUsernameCtx` but uses the `defaultCtx` as logger.
func UserIDFromUsernameCtx ¶
func UserIDFromUsernameCtx(username string, ctx *zap.Logger) (userID int, exists bool, success bool)
UserIDFromUsernameCtx tries to find the user which currently uses th passed username. Comparisons are made with lower-case strings
func UserPermission ¶
UserPermission is the same as `UserPermissionCtx` but uses the `defaultCtx` as logger.
func UserPermissionCtx ¶
UserPermissionCtx loads the current permission of the specified user from the database. It is mandatory that the user corresponding to the passed ID does exists!
func UsernameFromID ¶ added in v0.1.2
UsernameFromID returns a username as string from an given ID
func UsernameFromIDCtx ¶ added in v0.1.2
UsernameFromIDCtx loads the username associated with the given `userID`. Returns "" (empty string) if the user isn't found.
func UsernamesFromRoundID ¶ added in v0.1.2
UsernamesFromRoundID returns usernames as a slice of string from an given roundID
func UsernamesFromRoundIDCtx ¶ added in v0.1.2
UsernamesFromRoundIDCtx loads the usernames associated with the given `roundID`. Returns an empty slice if the roundID isn't valid.