Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2540 : [mod_callcenter] Release reserved agents if we do not provide call #2577

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/mod/applications/mod_callcenter/mod_callcenter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,31 @@ cc_status_t cc_agent_update(const char *key, const char *value, const char *agen
switch_safe_free(sql);
}

} else if (!strcasecmp(key, "state_if_reserved")) {
if (cc_agent_str2state(value) == CC_AGENT_STATE_UNKNOWN) {
result = CC_STATUS_AGENT_INVALID_STATE;
goto done;
} else {
sql = switch_mprintf("UPDATE agents SET state = '%q' WHERE name = '%q' AND state = '%q' AND status IN ('%q', '%q')",
value, agent,
cc_agent_state2str(CC_AGENT_STATE_RESERVED),
cc_agent_status2str(CC_AGENT_STATUS_AVAILABLE),
cc_agent_status2str(CC_AGENT_STATUS_AVAILABLE_ON_DEMAND));

if (cc_execute_sql_affected_rows(sql) > 0) {
result = CC_STATUS_SUCCESS;
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CALLCENTER_EVENT) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "CC-Agent", agent);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "CC-Action", "agent-state-change");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "CC-Agent-State", value);
switch_event_fire(&event);
}
} else {
result = CC_STATUS_AGENT_NOT_FOUND;
}
switch_safe_free(sql);
}

} else {
result = CC_STATUS_INVALID_KEY;
goto done;
Expand Down Expand Up @@ -2391,6 +2416,8 @@ static int agents_callback(void *pArg, int argc, char **argv, char **columnNames

switch (atoi(res)) {
case 0: /* Ok, someone else took it, or user hanged up already */
/* However, if we had reserved this agent, we should release them */
cc_agent_update("state_if_reserved", cc_agent_state2str(CC_AGENT_STATE_WAITING), agent_name);
return 1;
/* We default to default even if more entry is returned... Should never happen anyway */
default: /* Go ahead, start thread to try to bridge these 2 caller */
Expand Down