Documentation ¶
Index ¶
- Constants
- func ChangeUserColor(userID string, color int) error
- func ChangeUsername(userID string, username string) error
- func DeleteExternalAPIUser(token string) error
- func GetIntegrationNameForAccessToken(token string) *string
- func HasValidScopes(scopes []string) bool
- func InsertExternalAPIUser(token string, name string, color int, scopes []string) error
- func IsDisplayNameAvailable(displayName string) (bool, error)
- func SetAccessTokenToOwner(token, userID string) error
- func SetEnabled(userID string, enabled bool) error
- func SetExternalAPIUserAccessTokenAsUsed(token string) error
- func SetModerator(userID string, isModerator bool) error
- func SetUserAsAuthenticated(userID string) error
- func SetupUsers()
- type ExternalAPIUser
- type User
Constants ¶
const ( // ScopeCanSendChatMessages will allow sending chat messages as itself. ScopeCanSendChatMessages = "CAN_SEND_MESSAGES" // ScopeCanSendSystemMessages will allow sending chat messages as the system. ScopeCanSendSystemMessages = "CAN_SEND_SYSTEM_MESSAGES" // ScopeHasAdminAccess will allow performing administrative actions on the server. ScopeHasAdminAccess = "HAS_ADMIN_ACCESS" )
Variables ¶
This section is empty.
Functions ¶
func ChangeUserColor ¶ added in v0.1.0
ChangeUserColor will change the user associated to userID from one display name to another.
func ChangeUsername ¶
ChangeUsername will change the user associated to userID from one display name to another.
func DeleteExternalAPIUser ¶
DeleteExternalAPIUser will delete a token from the database.
func GetIntegrationNameForAccessToken ¶
GetIntegrationNameForAccessToken will return the integration name associated with a specific access token.
func HasValidScopes ¶
HasValidScopes will verify that all the scopes provided are valid.
func InsertExternalAPIUser ¶
InsertExternalAPIUser will add a new API user to the database.
func IsDisplayNameAvailable ¶ added in v0.0.12
IsDisplayNameAvailable will check if the proposed name is available for use.
func SetAccessTokenToOwner ¶ added in v0.0.12
SetAccessTokenToOwner will reassign an access token to be owned by a different user. Used for logging in with external auth.
func SetEnabled ¶
SetEnabled will set the enabled status of a single user by ID.
func SetExternalAPIUserAccessTokenAsUsed ¶
SetExternalAPIUserAccessTokenAsUsed will update the last used timestamp for a token.
func SetModerator ¶ added in v0.0.11
SetModerator will add or remove moderator status for a single user by ID.
func SetUserAsAuthenticated ¶ added in v0.0.12
SetUserAsAuthenticated will mark that a user has been authenticated in some way.
func SetupUsers ¶
func SetupUsers()
SetupUsers will perform the initial initialization of the user package.
Types ¶
type ExternalAPIUser ¶
type ExternalAPIUser struct { CreatedAt time.Time `json:"createdAt"` LastUsedAt *time.Time `json:"lastUsedAt,omitempty"` ID string `json:"id"` AccessToken string `json:"accessToken"` DisplayName string `json:"displayName"` Type string `json:"type,omitempty"` // Should be API Scopes []string `json:"scopes"` DisplayColor int `json:"displayColor"` IsBot bool `json:"isBot"` }
ExternalAPIUser represents a single 3rd party integration that uses an access token. This struct mostly matches the User struct so they can be used interchangeably.
func GetExternalAPIUser ¶
func GetExternalAPIUser() ([]ExternalAPIUser, error)
GetExternalAPIUser will return all API users with access tokens.
func GetExternalAPIUserForAccessTokenAndScope ¶
func GetExternalAPIUserForAccessTokenAndScope(token string, scope string) (*ExternalAPIUser, error)
GetExternalAPIUserForAccessTokenAndScope will determine if a specific token has access to perform a scoped action.
type User ¶
type User struct { CreatedAt time.Time `json:"createdAt"` DisabledAt *time.Time `json:"disabledAt,omitempty"` NameChangedAt *time.Time `json:"nameChangedAt,omitempty"` AuthenticatedAt *time.Time `json:"-"` ID string `json:"id"` DisplayName string `json:"displayName"` PreviousNames []string `json:"previousNames"` Scopes []string `json:"scopes,omitempty"` DisplayColor int `json:"displayColor"` IsBot bool `json:"isBot"` Authenticated bool `json:"authenticated"` }
User represents a single chat user.
func CreateAnonymousUser ¶
CreateAnonymousUser will create a new anonymous user with the provided display name.
func GetDisabledUsers ¶
func GetDisabledUsers() []*User
GetDisabledUsers will return back all the currently disabled users that are not API users.
func GetModeratorUsers ¶ added in v0.0.11
func GetModeratorUsers() []*User
GetModeratorUsers will return a list of users with moderator access.
func GetUserByID ¶ added in v0.0.9
GetUserByID will return a user by a user ID.
func GetUserByToken ¶
GetUserByToken will return a user by an access token.
func (*User) IsModerator ¶ added in v0.0.11
IsModerator will return if the user has moderation privileges.