Allow a device that is logged in already to be replaced with a new alternate device.

This commit is contained in:
markjcrane 2015-09-23 20:09:16 -06:00
parent 42924ccead
commit 5d9bb1b9d1
1 changed files with 17 additions and 2 deletions

View File

@ -121,7 +121,22 @@
result = session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/voicemail/vm-fail_auth.wav");
end
--remove the previous device and send a sync command to it
--this device already has an alternate find the correct device_uuid and then override current one
if (authorized == 'true' and action == "login" and device_uuid_alternate ~= nil) then
sql = [[SELECT * FROM v_devices ]];
sql = sql .. [[WHERE device_uuid_alternate = ']]..device_uuid..[[' ]];
sql = sql .. [[AND domain_uuid = ']]..domain_uuid..[[' ]];
if (debug["sql"]) then
freeswitch.consoleLog("NOTICE", "[provision] sql: ".. sql .. "\n");
end
dbh:query(sql, function(row)
if (row.device_uuid_alternate ~= nil) then
device_uuid = row.device_uuid;
end
end);
end
--remove the alternate device from another device so that it can be added to this device
if (authorized == 'true' and action == "login") then
sql = [[SELECT * FROM v_device_lines ]];
sql = sql .. [[WHERE device_uuid = ']]..device_uuid_alternate..[[' ]];
@ -135,7 +150,7 @@
sql = sql .. [[WHERE device_uuid_alternate = ']]..device_uuid_alternate..[[' ]];
sql = sql .. [[AND domain_uuid = ']]..domain_uuid..[[' ]];
if (debug["sql"]) then
--freeswitch.consoleLog("NOTICE", "[provision] sql: ".. sql .. "\n");
freeswitch.consoleLog("NOTICE", "[provision] sql: ".. sql .. "\n");
end
dbh:query(sql);
--send a sync command to the previous device