fix call_function events sent from backend (#4316)

This commit is contained in:
Khaleel Al-Adhami 2024-11-06 15:13:00 -08:00 committed by GitHub
parent b9d73edd66
commit 93ae79aa60
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -238,7 +238,10 @@ export const applyEvent = async (event, socket) => {
return false;
}
if (event.name == "_call_function") {
if (
event.name == "_call_function" &&
typeof event.payload.function !== "string"
) {
try {
const eval_result = event.payload.function();
if (event.payload.callback) {
@ -257,9 +260,13 @@ export const applyEvent = async (event, socket) => {
return false;
}
if (event.name == "_call_script") {
if (event.name == "_call_script" || event.name == "_call_function") {
try {
const eval_result = eval(event.payload.javascript_code);
const eval_result =
event.name == "_call_script"
? eval(event.payload.javascript_code)
: eval(event.payload.function)();
if (event.payload.callback) {
if (!!eval_result && typeof eval_result.then === "function") {
eval(event.payload.callback)(await eval_result);