11acbf54d579900df090cb1397bb69de885f2cee
[motion2.git] / server / services / routing / server / applications / close.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x0661=['YYYY-MM-DD\x20HH:mm:ss','system','Interaction','update','interaction','then','[%s][CLOSE]\x20interaction\x20%s\x20has\x20been\x20closed!','error','stringify','stop','moment','../../../../config/logger','../../rpc/openchannelInteraction','../../rpc/smsInteraction','../../rpc/mailInteraction','../../rpc/whatsappInteraction','info','format'];(function(_0x51fe5f,_0x1d8632){var _0x4abce9=function(_0x34afb7){while(--_0x34afb7){_0x51fe5f['push'](_0x51fe5f['shift']());}};_0x4abce9(++_0x1d8632);}(_0x0661,0x14e));var _0x1066=function(_0x453378,_0x2f360c){_0x453378=_0x453378-0x0;var _0xab3d9e=_0x0661[_0x453378];return _0xab3d9e;};'use strict';var moment=require(_0x1066('0x0'));var logger=require(_0x1066('0x1'))('routing');var rpc={'chatInteraction':require('../../rpc/chatInteraction'),'openchannelInteraction':require(_0x1066('0x2')),'smsInteraction':require(_0x1066('0x3')),'mailInteraction':require(_0x1066('0x4')),'faxInteraction':require('../../rpc/faxInteraction'),'whatsappInteraction':require(_0x1066('0x5'))};exports['consequence']=function(_0x4cd031,_0x549c5e,_0x30821e,_0x3eac69){return function(_0x49fa4e){try{logger[_0x1066('0x6')]('[%s][CLOSE]\x20reason\x20%s',_0x4cd031,_0x549c5e[0x0]);var _0x58876b={'closed':0x1,'closedAt':moment()[_0x1066('0x7')](_0x1066('0x8')),'closeReason':_0x1066('0x9'),'disposition':_0x549c5e[0x0]};if(rpc[_0x3eac69['channel']+'Interaction']){rpc[_0x3eac69['channel']+_0x1066('0xa')][_0x1066('0xb')](_0x3eac69[_0x1066('0xc')]['id'],_0x58876b)[_0x1066('0xd')](function(_0x200ed6){logger[_0x1066('0x6')](_0x1066('0xe'),_0x4cd031,_0x3eac69[_0x1066('0xc')]['id']);})['catch'](function(_0x548916){logger[_0x1066('0xf')]('[%s][CLOSE]\x20%s',_0x4cd031,JSON[_0x1066('0x10')](_0x548916));})['finally'](function(){_0x49fa4e[_0x1066('0x11')]();});}}catch(_0xd9444f){logger['error']('[%s][CLOSE]\x20%s',_0x4cd031,JSON['stringify'](_0xd9444f));_0x49fa4e[_0x1066('0x11')]();}};};