forked from Mirrors/freeswitch
Make max argument optional on the limit app, set the limit_usage variable with the current count after inserting the call in the db
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11955 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
a24c4dc1f7
commit
d279dd8e5c
@ -701,7 +701,7 @@ SWITCH_STANDARD_APP(group_function)
|
||||
}
|
||||
}
|
||||
|
||||
#define LIMIT_USAGE "<realm> <id> <max> [number [dialplan [context]]]"
|
||||
#define LIMIT_USAGE "<realm> <id> [<max> [number [dialplan [context]]]]"
|
||||
#define LIMIT_DESC "limit access to a resource and transfer to an extension if the limit is exceeded"
|
||||
static char *limit_def_xfer_exten = "limit_exceeded";
|
||||
|
||||
@ -727,14 +727,23 @@ SWITCH_STANDARD_APP(limit_function)
|
||||
|
||||
if (argc < 3) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "USAGE: limit %s\n", LIMIT_USAGE);
|
||||
return;
|
||||
goto done;
|
||||
}
|
||||
|
||||
switch_mutex_lock(globals.mutex);
|
||||
|
||||
realm = argv[0];
|
||||
id = argv[1];
|
||||
max = atoi(argv[2]);
|
||||
|
||||
if (argc > 2) {
|
||||
max = atoi(argv[2]);
|
||||
if (max < 0) {
|
||||
max = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
max = -1;
|
||||
}
|
||||
|
||||
if (argc >= 4) {
|
||||
xfer_exten = argv[3];
|
||||
@ -742,9 +751,6 @@ SWITCH_STANDARD_APP(limit_function)
|
||||
xfer_exten = limit_def_xfer_exten;
|
||||
}
|
||||
|
||||
if (max < 0) {
|
||||
max = 0;
|
||||
}
|
||||
|
||||
new_channel = !switch_channel_get_variable(channel, "limit_realm");
|
||||
switch_channel_set_variable(channel, "limit_realm", realm);
|
||||
@ -758,7 +764,7 @@ SWITCH_STANDARD_APP(limit_function)
|
||||
switch_safe_free(sql);
|
||||
got = atoi(buf);
|
||||
|
||||
if (got + 1 > max) {
|
||||
if (max > 0 && got + 1 > max) {
|
||||
switch_ivr_session_transfer(session, xfer_exten, argv[4], argv[5]);
|
||||
goto done;
|
||||
}
|
||||
@ -771,8 +777,11 @@ SWITCH_STANDARD_APP(limit_function)
|
||||
switch_core_session_get_uuid(session));
|
||||
limit_execute_sql(sql, NULL);
|
||||
switch_safe_free(sql);
|
||||
|
||||
switch_channel_set_variable(channel, "limit_usage", switch_core_session_sprintf(session, "%d", ++got));
|
||||
|
||||
done:
|
||||
switch_safe_free(mydata);
|
||||
switch_mutex_unlock(globals.mutex);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user