mirror of
https://github.com/balzack/databag.git
synced 2025-02-11 19:19:16 +00:00
restricitng allow unsealed if transforms not possible
This commit is contained in:
parent
4c386fac8e
commit
25e469a639
@ -3897,6 +3897,8 @@ components:
|
||||
type: boolean
|
||||
allowUnsealed:
|
||||
type: boolean
|
||||
transformSupported:
|
||||
type: boolean
|
||||
enableIce:
|
||||
type: boolean
|
||||
iceUrl:
|
||||
@ -3953,6 +3955,8 @@ components:
|
||||
type: string
|
||||
searchable:
|
||||
type: boolean
|
||||
allowUnsealed:
|
||||
type: boolean
|
||||
pushEnabled:
|
||||
type: boolean
|
||||
sealable:
|
||||
@ -4291,8 +4295,6 @@ components:
|
||||
updated:
|
||||
type: integer
|
||||
format: int64
|
||||
allowUnsealed:
|
||||
type: boolean
|
||||
enableImage:
|
||||
type: boolean
|
||||
enableAudio:
|
||||
|
@ -4,8 +4,6 @@ set -e
|
||||
sqlite3 /var/lib/databag/databag.db "VACUUM;"
|
||||
sqlite3 /var/lib/databag/databag.db "CREATE TABLE IF NOT EXISTS 'configs' ('id' integer NOT NULL UNIQUE,'config_id' text NOT NULL,'str_value' text,'num_value' integer,'bool_value' numeric,'bin_value' blob,PRIMARY KEY ('id'));"
|
||||
sqlite3 /var/lib/databag/databag.db "CREATE UNIQUE INDEX IF NOT EXISTS 'idx_configs_config_id' ON 'configs'('config_id');"
|
||||
sqlite3 /var/lib/databag/databag.db "delete from configs where config_id='script_path';"
|
||||
sqlite3 /var/lib/databag/databag.db "insert into configs (config_id, str_value) values ('script_path', '/opt/databag/transform/');"
|
||||
|
||||
if [[ -v ADMIN ]]; then
|
||||
sqlite3 /var/lib/databag/databag.db "delete from configs where config_id='configured';"
|
||||
@ -20,5 +18,5 @@ if [ "$DEV" == "1" ]; then
|
||||
done
|
||||
else
|
||||
cd /app/databag/net/server
|
||||
/usr/local/go/bin/go run databag -p 7000 -w /app/databag/net/web/build -s /var/lib/databag
|
||||
/usr/local/go/bin/go run databag -p 7000 -w /app/databag/net/web/build -s /var/lib/databag -t /opt/databag/transform
|
||||
fi
|
||||
|
@ -29,6 +29,7 @@ func GetNodeConfig(w http.ResponseWriter, r *http.Request) {
|
||||
config.IcePassword = getStrConfigValue(CNFIcePassword, "")
|
||||
config.EnableOpenAccess = getBoolConfigValue(CNFEnableOpenAccess, false);
|
||||
config.OpenAccessLimit = getNumConfigValue(CNFOpenAccessLimit, 0);
|
||||
config.TransformSupported = getStrConfigValue(CNFScriptPath, "") != "";
|
||||
|
||||
WriteResponse(w, config)
|
||||
}
|
||||
|
@ -372,6 +372,8 @@ type NodeConfig struct {
|
||||
|
||||
AccountStorage int64 `json:"accountStorage"`
|
||||
|
||||
TransformSupported bool `json:"transformSupported"`
|
||||
|
||||
AllowUnsealed bool `json:"allowUnsealed"`
|
||||
|
||||
PushSupported bool `json:"pushSupported"`
|
||||
|
@ -10,8 +10,8 @@ import (
|
||||
|
||||
var DB *gorm.DB;
|
||||
|
||||
func SetPath(path string) {
|
||||
db, err := gorm.Open(sqlite.Open(path + "/databag.db"), &gorm.Config{
|
||||
func SetPath(storePath string, transformPath string) {
|
||||
db, err := gorm.Open(sqlite.Open(storePath + "/databag.db"), &gorm.Config{
|
||||
Logger: logger.Default.LogMode(logger.Silent),
|
||||
})
|
||||
if err != nil {
|
||||
@ -20,12 +20,27 @@ func SetPath(path string) {
|
||||
}
|
||||
AutoMigrate(db)
|
||||
|
||||
// upsert key type
|
||||
// upsert asset path
|
||||
err = db.Transaction(func(tx *gorm.DB) error {
|
||||
if res := tx.Clauses(clause.OnConflict{
|
||||
Columns: []clause.Column{{Name: "config_id"}},
|
||||
DoUpdates: clause.AssignmentColumns([]string{"str_value"}),
|
||||
}).Create(&Config{ConfigID: "asset_path", StrValue: path + "/assets"}).Error; res != nil {
|
||||
}).Create(&Config{ConfigID: "asset_path", StrValue: storePath + "/assets"}).Error; res != nil {
|
||||
return res
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Println(err);
|
||||
panic("failed to set database path")
|
||||
}
|
||||
|
||||
// upsert script path
|
||||
err = db.Transaction(func(tx *gorm.DB) error {
|
||||
if res := tx.Clauses(clause.OnConflict{
|
||||
Columns: []clause.Column{{Name: "config_id"}},
|
||||
DoUpdates: clause.AssignmentColumns([]string{"str_value"}),
|
||||
}).Create(&Config{ConfigID: "script_path", StrValue: transformPath}).Error; res != nil {
|
||||
return res
|
||||
}
|
||||
return nil
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
func main() {
|
||||
var cert string
|
||||
var key string
|
||||
var transformPath string
|
||||
|
||||
port := ":443"
|
||||
storePath := "/var/lib/databag"
|
||||
@ -29,19 +30,21 @@ func main() {
|
||||
cert = args[i + 1]
|
||||
} else if args[i] == "-k" {
|
||||
key = args[i + 1]
|
||||
} else if args[i] == "-t" {
|
||||
transformPath = args[i + 1]
|
||||
}
|
||||
}
|
||||
|
||||
store.SetPath(storePath);
|
||||
store.SetPath(storePath, transformPath);
|
||||
router := app.NewRouter(webApp)
|
||||
origins := handlers.AllowedOrigins([]string{"*"})
|
||||
methods := handlers.AllowedMethods([]string{"GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS"})
|
||||
|
||||
if cert != "" && key != "" {
|
||||
log.Printf("using args:" + " -s " + storePath + " -w " + webApp + " -p " + port[1:] + " -c " + cert + " -k " + key)
|
||||
log.Printf("using args:" + " -s " + storePath + " -w " + webApp + " -p " + port[1:] + " -c " + cert + " -k " + key + " -t " + transformPath)
|
||||
log.Fatal(http.ListenAndServeTLS(port, cert, key, handlers.CORS(origins, methods)(router)))
|
||||
} else {
|
||||
log.Printf("using args:" + " -s " + storePath + " -w " + webApp + " -p " + port[1:]);
|
||||
log.Printf("using args:" + " -s " + storePath + " -w " + webApp + " -p " + port[1:] + " -t " + transformPath)
|
||||
log.Fatal(http.ListenAndServe(port, handlers.CORS(origins, methods)(router)))
|
||||
}
|
||||
}
|
||||
|
@ -139,11 +139,13 @@ export function Dashboard() {
|
||||
<Switch onChange={(e) => actions.setPushSupported(e)} size="small"
|
||||
defaultChecked={true} checked={state.pushSupported} />
|
||||
</div>
|
||||
<div className="field">
|
||||
<div>Allow Unsealed Topics: </div>
|
||||
<Switch onChange={(e) => actions.setAllowUnsealed(e)} size="small"
|
||||
defaultChecked={true} checked={state.allowUnsealed} />
|
||||
</div>
|
||||
{ state.transformSupported && (
|
||||
<div className="field">
|
||||
<div>Allow Unsealed Topics: </div>
|
||||
<Switch onChange={(e) => actions.setAllowUnsealed(e)} size="small"
|
||||
defaultChecked={true} checked={state.allowUnsealed} />
|
||||
</div>
|
||||
)}
|
||||
<div className="field label">
|
||||
<span>Topic Content:</span>
|
||||
</div>
|
||||
|
@ -15,6 +15,7 @@ export function useDashboard() {
|
||||
keyType: null,
|
||||
pushSupported: null,
|
||||
allowUnsealed: null,
|
||||
transformSupported: false,
|
||||
enableImage: null,
|
||||
enableAudio: null,
|
||||
enableVideo: null,
|
||||
@ -129,7 +130,7 @@ export function useDashboard() {
|
||||
if (!state.busy) {
|
||||
updateState({ busy: true });
|
||||
try {
|
||||
const { domain, keyType, accountStorage, pushSupported, allowUnsealed, enableImage, enableAudio, enableVideo, enableIce, iceUrl, iceUsername, icePassword, enableOpenAccess, openAccessLimit } = state;
|
||||
const { domain, keyType, accountStorage, pushSupported, transformSupported, allowUnsealed, enableImage, enableAudio, enableVideo, enableIce, iceUrl, iceUsername, icePassword, enableOpenAccess, openAccessLimit } = state;
|
||||
const storage = accountStorage * 1073741824;
|
||||
const config = { domain, accountStorage: storage, keyType, enableImage, enableAudio, enableVideo, pushSupported, allowUnsealed, enableIce, iceUrl, iceUsername, icePassword, enableOpenAccess, openAccessLimit };
|
||||
await setNodeConfig(app.state.adminToken, config);
|
||||
@ -147,9 +148,9 @@ export function useDashboard() {
|
||||
const syncConfig = async () => {
|
||||
try {
|
||||
const config = await getNodeConfig(app.state.adminToken);
|
||||
const { storage, domain, keyType, pushSupported, allowUnsealed, enableImage, enableAudio, enableVideo, enableIce, iceUrl, iceUsername, icePassword, enableOpenAccess, openAccessLimit } = config;
|
||||
const { storage, domain, keyType, pushSupported, transformSupported, allowUnsealed, enableImage, enableAudio, enableVideo, enableIce, iceUrl, iceUsername, icePassword, enableOpenAccess, openAccessLimit } = config;
|
||||
const accountStorage = Math.ceil(storage / 1073741824);
|
||||
updateState({ configError: false, domain, accountStorage, keyType, enableImage, enableAudio, enableVideo, pushSupported, allowUnsealed, enableIce, iceUrl, iceUsername, icePassword, enableOpenAccess, openAccessLimit });
|
||||
updateState({ configError: false, domain, accountStorage, keyType, enableImage, enableAudio, enableVideo, pushSupported, transformSupported, allowUnsealed, enableIce, iceUrl, iceUsername, icePassword, enableOpenAccess, openAccessLimit });
|
||||
}
|
||||
catch(err) {
|
||||
console.log(err);
|
||||
|
Loading…
Reference in New Issue
Block a user