Documentation ¶
Overview ¶
Storage/retrieval of PIXLISE user data and preferences from Mongo DB. This also exposes the standard "creator/owner" structure (APIObjectItem) stored in all user-created objects
Index ¶
- Constants
- func StripAuth0UserID(userid string) string
- type APIObjectItem
- type Method
- type NotificationConfig
- type Notifications
- type Topics
- type UINotificationItem
- type UserDetails
- type UserDetailsLookup
- func (u *UserDetailsLookup) GetCurrentCreatorDetails(userID string) (UserInfo, error)
- func (u *UserDetailsLookup) GetUser(userid string) (UserStruct, error)
- func (u *UserDetailsLookup) GetUserEnsureExists(userid string, name string, email string) (UserStruct, error)
- func (u *UserDetailsLookup) WriteUser(user UserStruct) error
- type UserInfo
- type UserStruct
Constants ¶
A special shared user ID so code knows if it's referring to this...
Variables ¶
This section is empty.
Functions ¶
func StripAuth0UserID ¶
Types ¶
type APIObjectItem ¶
type APIObjectItem struct { Creator UserInfo `json:"creator"` CreatedUnixTimeSec int64 `json:"create_unix_time_sec,omitempty"` ModifiedUnixTimeSec int64 `json:"mod_unix_time_sec,omitempty"` }
APIObjectItem API endpoints send around versions of this struct (with extra fields depending on the data type) TODO: maybe need to move this to its own API structures place? It's currently used in more places than just API handlers though.
type NotificationConfig ¶
type NotificationConfig struct {
Method `json:"method"`
}
NotificationConfig - Config specifically for notifications
type Notifications ¶
type Notifications struct { Topics []Topics `json:"topics"` Hints []string `json:"hints"` UINotifications []UINotificationItem `json:"uinotifications"` }
Notifications - Object for notification settings
type Topics ¶
type Topics struct { Name string `json:"name"` Config NotificationConfig `json:"config"` }
Topics - Notification Topics'
type UINotificationItem ¶
type UINotificationItem struct { Topic string `json:"topic"` Message string `json:"message"` Timestamp time.Time `json:"timestamp"` UserID string `json:"userid"` }
UINotificationItem - A single UI Notification
type UserDetails ¶
type UserDetails struct { Name string `json:"name"` Email string `json:"email"` Cell string `json:"cell"` DataCollection string `json:"data_collection"` }
Config - config options for user
type UserDetailsLookup ¶
type UserDetailsLookup struct {
// contains filtered or unexported fields
}
func MakeUserDetailsLookup ¶
func MakeUserDetailsLookup(mongoClient *mongo.Client, envName string) UserDetailsLookup
func (*UserDetailsLookup) GetCurrentCreatorDetails ¶
func (u *UserDetailsLookup) GetCurrentCreatorDetails(userID string) (UserInfo, error)
Getting JUST UserDetails (so it goes through our in-memory cache). This is useful for the many places in the code that only require user name+email to ensure we're sending out up-to-date "creator" aka "APIObjectItem" structures
func (*UserDetailsLookup) GetUser ¶
func (u *UserDetailsLookup) GetUser(userid string) (UserStruct, error)
func (*UserDetailsLookup) GetUserEnsureExists ¶
func (u *UserDetailsLookup) GetUserEnsureExists(userid string, name string, email string) (UserStruct, error)
func (*UserDetailsLookup) WriteUser ¶
func (u *UserDetailsLookup) WriteUser(user UserStruct) error
type UserInfo ¶
type UserInfo struct { Name string `json:"name"` UserID string `json:"user_id"` Email string `json:"email"` Permissions map[string]bool `json:"-" bson:"-"` // This is a lookup - we don't want this in JSON sent out of API though! }
UserInfo - Anything we need to identify a user
type UserStruct ¶
type UserStruct struct { Userid string `json:"userid"` Notifications Notifications `json:"notifications"` Config UserDetails `json:"userconfig"` }
UserStruct - Structure for user configuration