mirror of
https://github.com/jambonz/jambonz-webapp.git
synced 2026-01-25 02:08:19 +00:00
fixed PUT of env_vars in Applications should not stringify (#513)
This commit is contained in:
@@ -338,7 +338,7 @@ export interface Application {
|
|||||||
fallback_speech_recognizer_vendor: null | string;
|
fallback_speech_recognizer_vendor: null | string;
|
||||||
fallback_speech_recognizer_language: null | string;
|
fallback_speech_recognizer_language: null | string;
|
||||||
fallback_speech_recognizer_label: null | string;
|
fallback_speech_recognizer_label: null | string;
|
||||||
env_vars: null | string;
|
env_vars: null | Record<string, string | number | boolean>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PhoneNumber {
|
export interface PhoneNumber {
|
||||||
|
|||||||
@@ -207,13 +207,23 @@ export const ApplicationForm = ({ application }: ApplicationFormProps) => {
|
|||||||
record_all_calls: recordAllCalls ? 1 : 0,
|
record_all_calls: recordAllCalls ? 1 : 0,
|
||||||
use_for_fallback_speech: useForFallbackSpeech ? 1 : 0,
|
use_for_fallback_speech: useForFallbackSpeech ? 1 : 0,
|
||||||
env_vars: envVars
|
env_vars: envVars
|
||||||
? JSON.stringify(
|
? Object.keys(envVars).reduce((acc, key) => {
|
||||||
Object.keys(envVars).reduce(
|
const value = envVars[key];
|
||||||
(acc, key) =>
|
// Keep only values that:
|
||||||
appEnv && appEnv[key] ? { ...acc, [key]: envVars[key] } : acc,
|
// 1. Are defined in appEnv schema
|
||||||
{},
|
// 2. Are not empty strings, undefined, or null
|
||||||
),
|
// 3. For booleans and numbers, keep them even if they're false or 0
|
||||||
)
|
if (
|
||||||
|
appEnv &&
|
||||||
|
appEnv[key] &&
|
||||||
|
(value === false ||
|
||||||
|
value === 0 ||
|
||||||
|
(value !== "" && value != null))
|
||||||
|
) {
|
||||||
|
return { ...acc, [key]: value };
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, {})
|
||||||
: null,
|
: null,
|
||||||
fallback_speech_synthesis_vendor: useForFallbackSpeech
|
fallback_speech_synthesis_vendor: useForFallbackSpeech
|
||||||
? fallbackSpeechSynthsisVendor || null
|
? fallbackSpeechSynthsisVendor || null
|
||||||
@@ -532,7 +542,7 @@ export const ApplicationForm = ({ application }: ApplicationFormProps) => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (application.data.env_vars) {
|
if (application.data.env_vars) {
|
||||||
setEnvVars(JSON.parse(application.data.env_vars));
|
setEnvVars(application.data.env_vars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [application]);
|
}, [application]);
|
||||||
|
|||||||
Reference in New Issue
Block a user