pixlUser

package
v3.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

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

View Source
const ShareUserID = "shared"

A special shared user ID so code knows if it's referring to this...

Variables

This section is empty.

Functions

func StripAuth0UserID

func StripAuth0UserID(userid string) string

Types

type APIObjectItem

type APIObjectItem struct {
	Shared              bool     `json:"shared"`
	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 Method

type Method struct {
	UI    bool `json:"ui"`
	Sms   bool `json:"sms"`
	Email bool `json:"email"`
}

Method - Notification Methods

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

Jump to

Keyboard shortcuts

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