mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-15 16:39:14 +00:00
block some unwanted behaviours regarding session.originate
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11983 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
46ed65824d
commit
a52849b56a
@ -2853,6 +2853,14 @@ static JSBool session_originate(JSContext * cx, JSObject * obj, uintN argc, jsva
|
|||||||
jss = JS_GetPrivate(cx, obj);
|
jss = JS_GetPrivate(cx, obj);
|
||||||
jss->cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
|
jss->cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
|
||||||
|
|
||||||
|
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "This method is depricated, please use new Session(\"<dial string>\", a_leg) \n");
|
||||||
|
|
||||||
|
if (jss->session) {
|
||||||
|
eval_some_js("~throw new Error(\"cannot call this method on an initialized session\");", cx, obj, rval);
|
||||||
|
return JS_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
JSObject *session_obj;
|
JSObject *session_obj;
|
||||||
switch_core_session_t *session = NULL, *peer_session = NULL;
|
switch_core_session_t *session = NULL, *peer_session = NULL;
|
||||||
@ -2876,7 +2884,19 @@ static JSBool session_originate(JSContext * cx, JSObject * obj, uintN argc, jsva
|
|||||||
|
|
||||||
if (JS_ValueToObject(cx, argv[0], &session_obj)) {
|
if (JS_ValueToObject(cx, argv[0], &session_obj)) {
|
||||||
struct js_session *old_jss = NULL;
|
struct js_session *old_jss = NULL;
|
||||||
if (session_obj && (old_jss = JS_GetPrivate(cx, session_obj)) && old_jss->session) {
|
if (session_obj && (old_jss = JS_GetPrivate(cx, session_obj))) {
|
||||||
|
|
||||||
|
if (old_jss == jss) {
|
||||||
|
eval_some_js("~throw new Error(\"Supplied a_leg session is the same as our session\");", cx, obj, rval);
|
||||||
|
return JS_FALSE;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!old_jss->session) {
|
||||||
|
eval_some_js("~throw new Error(\"Supplied a_leg session is not initilaized!\");", cx, obj, rval);
|
||||||
|
return JS_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
session = old_jss->session;
|
session = old_jss->session;
|
||||||
orig_caller_profile = switch_channel_get_caller_profile(switch_core_session_get_channel(session));
|
orig_caller_profile = switch_channel_get_caller_profile(switch_core_session_get_channel(session));
|
||||||
dialplan = orig_caller_profile->dialplan;
|
dialplan = orig_caller_profile->dialplan;
|
||||||
@ -2888,6 +2908,7 @@ static JSBool session_originate(JSContext * cx, JSObject * obj, uintN argc, jsva
|
|||||||
context = orig_caller_profile->context;
|
context = orig_caller_profile->context;
|
||||||
username = orig_caller_profile->username;
|
username = orig_caller_profile->username;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!switch_strlen_zero(jss->dialplan))
|
if (!switch_strlen_zero(jss->dialplan))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user