database

package
v0.0.0-...-4c3ee00 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TeamPrefix        = "TEAM"
	UserPrefix        = "USER"
	WhoIsOutPrefix    = "WIO"
	CallbackPrefix    = "CALLBACK"
	DepartmentsPrefix = "DEPARTMENTS"
)

Variables

View Source
var Cryptokey []byte
View Source
var DB = New()

Functions

func Decrypt

func Decrypt(data string) string

func DeleteInstallCallback

func DeleteInstallCallback(triggerID string) (err error)

DeleteInstallCallback removes an installation callback meta information.

func Encrypt

func Encrypt(data string) string

func New

func New() (db *leveldb.DB)

func PutInstallCallback

func PutInstallCallback(triggerID string, data InstallCallback) error

PutInstallCallback saves an installation callback meta information to process with the further callback.

func PutOrg

func PutOrg(org *OrganizationCredentials) error

PutOrg saves an organization credentials

func PutOrgDepartments

func PutOrgDepartments(slackTeamID string, data DepartmentCache) error

PutOrgDepartments put a list of available departments to the cache

func PutSlackUserToken

func PutSlackUserToken(slackTeamID string, slackUserID string, token SlackToken) error

PutSlackUserToken saves an auth token of the Slack user for the specific workspace.

func PutWIOMessage

func PutWIOMessage(slackTeamID string, message []WhoIsOutMessage) error

PutWIOMessage refreshes the "who is out" message for the specific Slack workspace.

Types

type DepartmentCache

type DepartmentCache struct {
	Departments map[int]string `json:"departments"`
	ExpiresAt   int64          `json:"expiresAt"`
}

DepartmentCache represents the list of departments in cache

func GetOrgDepartments

func GetOrgDepartments(slackTeamID string) (*DepartmentCache, bool)

GetOrgDepartments gets a list of departments from the cache

type InstallCallback

type InstallCallback struct {
	ResponseURL    string `json:"response_url"`
	BambooHROrg    string `json:"bamboohr_org"`
	BambooHRSecret string `json:"bamboohr_secret"`
}

func GetInstallCallback

func GetInstallCallback(triggerID string) (*InstallCallback, error)

GetInstallCallback gets an installation callback meta information.

type OrganizationCredentials

type OrganizationCredentials struct {
	SlackTeamID      string     `json:"-"`
	SlackAdminUserID string     `json:"admin_user"`
	SlackToken       SlackToken `json:"-"`
	BambooHROrg      string     `json:"bamboohr_org"`
	BambooHRSecret   string     `json:"bamboohr_secret"`
}

func GetOrg

func GetOrg(slackTeamID string) (OrganizationCredentials, bool)

GetOrg gets an organization credentials for the specific Slack team

func GetOrgs

func GetOrgs() []OrganizationCredentials

GetOrgs gets a list of all installed organizations with their credentials

type SlackToken

type SlackToken slack.OAuthResponse

func GetSlackUserToken

func GetSlackUserToken(slackTeamID string, slackUserID string) (SlackToken, bool)

GetSlackUserToken gets an auth token of the Slack user for the specific workspace.

type TimeOff

type TimeOff struct {
	Type  *TimeOffType `json:"type"`
	Start string       `json:"start"`
	End   string       `json:"end"`
}

type TimeOffType

type TimeOffType struct {
	OrderNumber  int    `json:"orderNumber"`
	BambooHRType string `json:"bambooHRType"`
	Text         string `json:"text"`
	Icon         string `json:"icon"`
}

TimeOffType struct is used as the config definition

type WhoIsOutMessage

type WhoIsOutMessage struct {
	Employee WhoIsOutMessageEmployee `json:"employee"`
	TimeOff  TimeOff                 `json:"timeOff"`
}

WhoIsOutMessage is used to parse the who-is-out message

func GetWIOMessage

func GetWIOMessage(slackTeamID string) ([]WhoIsOutMessage, error)

GetWIOMessage gets the "who is out" message for the specific Slack workspace, which is cached in the database and gets refreshed by the poller.

type WhoIsOutMessageEmployee

type WhoIsOutMessageEmployee struct {
	SlackUser WhoIsOutMessageSlackUser `json:"slack"`
	Info      *bamboohr.EmployeeInfo   `json:"info,omitempty"`
}

type WhoIsOutMessageSlackUser

type WhoIsOutMessageSlackUser struct {
	ID       string `json:"id"`
	RealName string `json:"realName"`
}

Jump to

Keyboard shortcuts

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