store

package
v0.5.8 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const GroupTypePrefix = "group:"

GroupTypePrefix identifies contacts shared with one or more groups.

Variables

View Source
var UserSessions map[string]*models.UserSession

Functions

func BatchInsertPhonebookEntries added in v0.4.5

func BatchInsertPhonebookEntries(ctx context.Context, entries []*PhonebookEntry) (int, int, error)

BatchInsertPhonebookEntries inserts multiple phonebook entries in a transaction.

func CanSeeAllOperatorGroups added in v0.5.8

func CanSeeAllOperatorGroups(capabilities map[string]bool) bool

CanSeeAllOperatorGroups reports whether the user can access all operator groups.

func CreatePhonebookEntry added in v0.5.8

func CreatePhonebookEntry(ctx context.Context, entry *PhonebookEntry) error

CreatePhonebookEntry inserts a single CTI phonebook contact.

func DeletePhonebookEntryByID added in v0.5.8

func DeletePhonebookEntryByID(ctx context.Context, id int64) error

DeletePhonebookEntryByID removes a CTI phonebook contact.

func EncodeSharedGroupsType added in v0.5.8

func EncodeSharedGroupsType(groups []string) string

EncodeSharedGroupsType serializes normalized group names into the contact type field.

func GetAllowedOperatorGroupIDs added in v0.5.8

func GetAllowedOperatorGroupIDs(capabilities map[string]bool) []string

GetAllowedOperatorGroupIDs returns the enabled grp_* presence-panel permission ids.

func GetGroupPermissionID added in v0.5.8

func GetGroupPermissionID(groupName string) string

GetGroupPermissionID returns the normalized presence-panel permission id for a group name.

func GetPhonebookPermissionLevel added in v0.5.8

func GetPhonebookPermissionLevel(username string) int

GetPhonebookPermissionLevel derives the legacy permission level for a user.

func GetPhonebookPermissionLevelFromCapabilities added in v0.5.8

func GetPhonebookPermissionLevelFromCapabilities(capabilities map[string]bool) int

GetPhonebookPermissionLevelFromCapabilities derives the legacy permission level from flattened capabilities.

func GetSharedGroupsFromType added in v0.5.8

func GetSharedGroupsFromType(contactType string) []string

GetSharedGroupsFromType parses the serialized group type and returns normalized group names.

func GetUserCapabilities added in v0.4.5

func GetUserCapabilities(username string) (map[string]bool, error)

GetUserCapabilities returns all capabilities for a given username

func GetUserDisplayInfo added in v0.4.6

func GetUserDisplayInfo(username string) (string, []string, error)

GetUserDisplayInfo returns display name and phone numbers for a given user.

func HasGroupTypePrefix added in v0.5.8

func HasGroupTypePrefix(contactType string) bool

HasGroupTypePrefix reports whether the contact type uses the shared-group namespace.

func InitPersistence added in v0.4.0

func InitPersistence(dataDir string)

InitPersistence sets up the persistence file path

func InitProfiles added in v0.4.5

func InitProfiles(profilesPath, usersPath string) error

InitProfiles loads profiles and users from JSON files

func IsReservedContactType added in v0.5.8

func IsReservedContactType(contactType string) bool

IsReservedContactType reports whether the contact type is one of the built-in visibilities.

func IsValidGroupContactType added in v0.5.8

func IsValidGroupContactType(contactType string) bool

IsValidGroupContactType reports whether the serialized group type is syntactically valid.

func IsValidSharedGroupName added in v0.5.8

func IsValidSharedGroupName(groupName string) bool

IsValidSharedGroupName reports whether a group name can be serialized in the contact type.

func LoadSessions added in v0.4.0

func LoadSessions() error

LoadSessions loads user sessions from disk

func NormalizeSharedGroups added in v0.5.8

func NormalizeSharedGroups(groups []string) []string

NormalizeSharedGroups trims, deduplicates, and drops empty group names.

func RemoveAllJWTTokens added in v0.4.0

func RemoveAllJWTTokens(username string) error

func RemoveJWTToken added in v0.4.0

func RemoveJWTToken(username, tokenToRemove string) error

func RevokeLegacySession added in v0.4.0

func RevokeLegacySession(username string, userSession *models.UserSession)

RevokeLegacySession deletes the session entry and revokes legacy persistent token (subtype "user") Requires that userSession.JWTTokens is empty.

func SaveSessions added in v0.4.0

func SaveSessions() error

Saves current user sessions to disk

func SetBatchInsertPhonebookEntriesFuncForTest added in v0.5.0

func SetBatchInsertPhonebookEntriesFuncForTest(fn func(context.Context, []*PhonebookEntry) (int, int, error)) func()

SetBatchInsertPhonebookEntriesFuncForTest allows tests to override the batch insert behavior.

func UpdatePhonebookEntryFields added in v0.5.8

func UpdatePhonebookEntryFields(ctx context.Context, id int64, fields map[string]any) error

UpdatePhonebookEntryFields updates the provided columns on a CTI phonebook contact.

func UserSessionInit

func UserSessionInit() map[string]*models.UserSession

Types

type LegacyPhonebookContact added in v0.5.8

type LegacyPhonebookContact struct {
	ID             int64  `json:"id"`
	OwnerID        string `json:"owner_id"`
	Type           string `json:"type"`
	HomeEmail      string `json:"homeemail"`
	WorkEmail      string `json:"workemail"`
	HomePhone      string `json:"homephone"`
	WorkPhone      string `json:"workphone"`
	CellPhone      string `json:"cellphone"`
	Fax            string `json:"fax"`
	Title          string `json:"title"`
	Company        string `json:"company"`
	Notes          string `json:"notes"`
	Name           string `json:"name"`
	HomeStreet     string `json:"homestreet"`
	HomePOB        string `json:"homepob"`
	HomeCity       string `json:"homecity"`
	HomeProvince   string `json:"homeprovince"`
	HomePostalCode string `json:"homepostalcode"`
	HomeCountry    string `json:"homecountry"`
	WorkStreet     string `json:"workstreet"`
	WorkPOB        string `json:"workpob"`
	WorkCity       string `json:"workcity"`
	WorkProvince   string `json:"workprovince"`
	WorkPostalCode string `json:"workpostalcode"`
	WorkCountry    string `json:"workcountry"`
	URL            string `json:"url"`
	Extension      string `json:"extension"`
	SpeedDialNum   string `json:"speeddial_num"`
	Source         string `json:"source"`
	Contacts       string `json:"contacts,omitempty"`
}

LegacyPhonebookContact mirrors the legacy phonebook search payload.

type LegacyPhonebookQuery added in v0.5.8

type LegacyPhonebookQuery struct {
	Username               string
	UserGroups             []string
	View                   string
	Visibility             string
	Term                   string
	Offset                 int
	Limit                  int
	ApplyPagination        bool
	IncludePrivateContacts bool
}

LegacyPhonebookQuery describes legacy-compatible union search/list parameters.

type LegacyPhonebookResult added in v0.5.8

type LegacyPhonebookResult struct {
	Count      int                      `json:"count"`
	Rows       []LegacyPhonebookContact `json:"rows"`
	LastSyncAt *string                  `json:"last_sync_at"`
}

LegacyPhonebookResult mirrors the legacy phonebook search/list envelope.

func ListLegacyPhonebook added in v0.5.8

func ListLegacyPhonebook(ctx context.Context, query LegacyPhonebookQuery) (*LegacyPhonebookResult, error)

ListLegacyPhonebook returns the legacy alphabetical list across CTI and centralized phonebooks.

func SearchLegacyPhonebook added in v0.5.8

func SearchLegacyPhonebook(ctx context.Context, query LegacyPhonebookQuery) (*LegacyPhonebookResult, error)

SearchLegacyPhonebook returns legacy-compatible search results across CTI and centralized phonebooks.

type PersistedSession added in v0.4.0

type PersistedSession struct {
	Username     string   `json:"username"`
	JWTTokens    []string `json:"jwt_tokens"`
	NethCTIToken string   `json:"nethcti_token"`
}

PersistedSession represents minimal session data needed for persistence

type PhonebookEntry added in v0.4.5

type PhonebookEntry struct {
	ID             int64
	OwnerID        string
	Type           string
	HomeEmail      string
	WorkEmail      string
	HomePhone      string
	WorkPhone      string
	CellPhone      string
	Fax            string
	Title          string
	Company        string
	Notes          string
	Name           string
	HomeStreet     string
	HomePOB        string
	HomeCity       string
	HomeProvince   string
	HomePostalCode string
	HomeCountry    string
	WorkStreet     string
	WorkPOB        string
	WorkCity       string
	WorkProvince   string
	WorkPostalCode string
	WorkCountry    string
	URL            string
	Extension      string
	SpeedDialNum   string
}

PhonebookEntry represents a phonebook contact from cti_phonebook table.

func GetCentralizedPhonebookEntryByID added in v0.5.8

func GetCentralizedPhonebookEntryByID(ctx context.Context, id int64) (*PhonebookEntry, error)

GetCentralizedPhonebookEntryByID returns a single contact from the centralized phonebook table (the company-wide phonebook published for physical phones) by id. The nethcti-exported rows are excluded: those are CTI contacts and must be fetched from cti_phonebook instead, to avoid returning the duplicated copy.

func GetPhonebookEntryByID added in v0.5.8

func GetPhonebookEntryByID(ctx context.Context, id int64) (*PhonebookEntry, error)

GetPhonebookEntryByID returns a single CTI phonebook contact by id.

type ProfileData added in v0.4.5

type ProfileData struct {
	ID           string
	Name         string
	Capabilities map[string]bool
}

ProfileData represents a profile with capability map

func GetUserProfile added in v0.4.5

func GetUserProfile(username string) (*ProfileData, error)

GetUserProfile returns the profile data for a given username

type ReloadStats added in v0.4.6

type ReloadStats struct {
	ProfilesLoaded int
	UsersLoaded    int
}

ReloadStats reports in-memory counters after a reload attempt.

func ReloadProfiles added in v0.4.5

func ReloadProfiles() (*ReloadStats, error)

ReloadProfiles reloads profiles and users and returns resulting counters.

type UserEndpoints added in v0.4.6

type UserEndpoints struct {
	MainExtension map[string]struct{}
	Extension     map[string]*UserExtension
	Voicemail     map[string]struct{}
	Email         map[string]struct{}
	Cellphone     map[string]struct{}
}

UserEndpoints contains endpoint data loaded from users.json.

type UserExtension added in v0.4.6

type UserExtension struct {
	Type     string
	User     string
	Password string
}

UserExtension stores details for a single extension endpoint.

type UserProfile added in v0.4.5

type UserProfile struct {
	Username     string
	Name         string
	ProfileID    string
	Endpoints    UserEndpoints
	PhoneNumbers []string
}

UserProfile links a username to a profile

Jump to

Keyboard shortcuts

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