Documentation ¶
Index ¶
- Constants
- func ChangeUsername(userID string, username string)
- 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 SetEnabled(userID string, enabled bool) error
- func SetExternalAPIUserAccessTokenAsUsed(token 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 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 SetEnabled ¶
SetEnabled will will set the enabled flag on a single user assigned to userID.
func SetExternalAPIUserAccessTokenAsUsed ¶
SetExternalAPIUserAccessTokenAsUsed will update the last used timestamp for a token.
func SetupUsers ¶
func SetupUsers()
SetupUsers will perform the initial initialization of the user package.
Types ¶
type ExternalAPIUser ¶
type ExternalAPIUser struct { ID string `json:"id"` AccessToken string `json:"accessToken"` DisplayName string `json:"displayName"` DisplayColor int `json:"displayColor"` CreatedAt time.Time `json:"createdAt"` Scopes []string `json:"scopes"` Type string `json:"type,omitempty"` // Should be API LastUsedAt *time.Time `json:"lastUsedAt,omitempty"` }
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 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 { ID string `json:"id"` AccessToken string `json:"-"` DisplayName string `json:"displayName"` DisplayColor int `json:"displayColor"` CreatedAt time.Time `json:"createdAt"` DisabledAt *time.Time `json:"disabledAt,omitempty"` PreviousNames []string `json:"previousNames"` NameChangedAt *time.Time `json:"nameChangedAt,omitempty"` }
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 GetUserByToken ¶
GetUserByToken will return a user by an access token.