2022-01-12 21:12:40 +00:00
|
|
|
package databag
|
|
|
|
|
|
|
|
import (
|
2022-07-22 19:28:14 +00:00
|
|
|
"databag/internal/store"
|
|
|
|
"errors"
|
|
|
|
"gorm.io/gorm"
|
|
|
|
)
|
2022-01-12 21:12:40 +00:00
|
|
|
|
2022-11-09 22:38:45 +00:00
|
|
|
//CNFPushSupported for allowing push notifications
|
|
|
|
const CNFPushSupported = "push_notifications"
|
|
|
|
|
2022-07-23 04:39:44 +00:00
|
|
|
//CNFOpenAccess for allowing for public account creation
|
2022-07-22 18:01:29 +00:00
|
|
|
const CNFOpenAccess = "open_access"
|
2022-07-23 04:39:44 +00:00
|
|
|
|
|
|
|
//CNFAccountLimit for limiting number of accounts for public creation
|
2022-07-22 18:01:29 +00:00
|
|
|
const CNFAccountLimit = "account_limit"
|
2022-07-23 04:39:44 +00:00
|
|
|
|
|
|
|
//CNFConfigured set when admin token has been set
|
2022-07-22 18:01:29 +00:00
|
|
|
const CNFConfigured = "configured"
|
2022-07-23 04:39:44 +00:00
|
|
|
|
|
|
|
//CNFToken identifies the admin token
|
2022-07-22 18:01:29 +00:00
|
|
|
const CNFToken = "token"
|
2022-07-23 04:39:44 +00:00
|
|
|
|
|
|
|
//CNFDomain identifies the configured server hostname
|
2022-07-22 18:01:29 +00:00
|
|
|
const CNFDomain = "domain"
|
2022-07-23 04:39:44 +00:00
|
|
|
|
|
|
|
//CNFStorage specifies the storage limit per account
|
2022-07-22 18:01:29 +00:00
|
|
|
const CNFStorage = "storage"
|
2022-07-23 04:39:44 +00:00
|
|
|
|
|
|
|
//CNFAssetPath specifies the path to store assets
|
2022-07-22 18:01:29 +00:00
|
|
|
const CNFAssetPath = "asset_path"
|
2022-07-23 04:39:44 +00:00
|
|
|
|
|
|
|
//CNFScriptPath specifies the path where transform scripts are found
|
2022-07-22 18:01:29 +00:00
|
|
|
const CNFScriptPath = "script_path"
|
2022-01-17 05:55:25 +00:00
|
|
|
|
2022-09-01 07:22:43 +00:00
|
|
|
//CNFEnableImage specifies whether node can process image assets
|
|
|
|
const CNFEnableImage = "enable_image"
|
|
|
|
|
|
|
|
//CNFEnableAudio specifies whether node can process audio assets
|
|
|
|
const CNFEnableAudio = "enable_audio"
|
|
|
|
|
|
|
|
//CNFEnableVideo specifies whether node can process video assets
|
|
|
|
const CNFEnableVideo = "enable_video"
|
|
|
|
|
|
|
|
//CNFKeyType specifies the type of key to use for identity
|
|
|
|
const CNFKeyType = "key_type"
|
|
|
|
|
2023-04-13 07:39:14 +00:00
|
|
|
//CNFEnableIce specifies whether webrtc is enabled
|
|
|
|
const CNFEnableIce = "enable_ice"
|
|
|
|
|
|
|
|
//CNFIceUrl specifies the ice candidate url
|
|
|
|
const CNFIceUrl = "ice_url"
|
|
|
|
|
|
|
|
//CNFIceUrl specifies the ice candidate username
|
|
|
|
const CNFIceUsername = "ice_username"
|
|
|
|
|
|
|
|
//CNFIceUrl specifies the ice candidate url
|
|
|
|
const CNFIcePassword = "ice_password"
|
|
|
|
|
|
|
|
|
2022-07-22 17:15:44 +00:00
|
|
|
func getStrConfigValue(configID string, empty string) string {
|
2022-07-22 19:28:14 +00:00
|
|
|
var config store.Config
|
|
|
|
err := store.DB.Where("config_id = ?", configID).First(&config).Error
|
|
|
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
|
|
|
return empty
|
|
|
|
}
|
|
|
|
return config.StrValue
|
2022-01-12 21:12:40 +00:00
|
|
|
}
|
|
|
|
|
2022-07-22 17:15:44 +00:00
|
|
|
func getNumConfigValue(configID string, empty int64) int64 {
|
2022-07-22 19:28:14 +00:00
|
|
|
var config store.Config
|
|
|
|
err := store.DB.Where("config_id = ?", configID).First(&config).Error
|
|
|
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
|
|
|
return empty
|
|
|
|
}
|
|
|
|
return config.NumValue
|
2022-01-12 21:12:40 +00:00
|
|
|
}
|
|
|
|
|
2022-07-22 17:15:44 +00:00
|
|
|
func getBoolConfigValue(configID string, empty bool) bool {
|
2022-07-22 19:28:14 +00:00
|
|
|
var config store.Config
|
|
|
|
err := store.DB.Where("config_id = ?", configID).First(&config).Error
|
|
|
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
|
|
|
return empty
|
|
|
|
}
|
|
|
|
return config.BoolValue
|
2022-01-12 21:12:40 +00:00
|
|
|
}
|
|
|
|
|
2022-07-22 17:15:44 +00:00
|
|
|
func getBinConfigValue(configID string, empty []byte) []byte {
|
2022-07-22 19:28:14 +00:00
|
|
|
var config store.Config
|
|
|
|
err := store.DB.Where("config_id = ?", configID).First(&config).Error
|
|
|
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
|
|
|
return empty
|
|
|
|
}
|
|
|
|
return config.BinValue
|
2022-01-12 21:12:40 +00:00
|
|
|
}
|