f1f4c7ddfa407e04c7da241b27565664c5319c27
[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 _0xf417=['routing','../../rpc/chatInteraction','../../rpc/smsInteraction','../../rpc/whatsappInteraction','info','[%s][CLOSE]\x20reason\x20%s','format','system','Interaction','channel','interaction','[%s][CLOSE]\x20interaction\x20%s\x20has\x20been\x20closed!','catch','error','[%s][CLOSE]\x20%s','stop','stringify','../../../../config/logger'];(function(_0x112036,_0x2a3aa3){var _0x4afc55=function(_0x483a7f){while(--_0x483a7f){_0x112036['push'](_0x112036['shift']());}};_0x4afc55(++_0x2a3aa3);}(_0xf417,0x8f));var _0x7f41=function(_0x5ce34a,_0x57887e){_0x5ce34a=_0x5ce34a-0x0;var _0x309350=_0xf417[_0x5ce34a];return _0x309350;};'use strict';var moment=require('moment');var logger=require(_0x7f41('0x0'))(_0x7f41('0x1'));var rpc={'chatInteraction':require(_0x7f41('0x2')),'openchannelInteraction':require('../../rpc/openchannelInteraction'),'smsInteraction':require(_0x7f41('0x3')),'mailInteraction':require('../../rpc/mailInteraction'),'faxInteraction':require('../../rpc/faxInteraction'),'whatsappInteraction':require(_0x7f41('0x4'))};exports['consequence']=function(_0x51b0cb,_0x5ad014,_0x5ecdb2,_0x1775d8){return function(_0x4e37b5){try{logger[_0x7f41('0x5')](_0x7f41('0x6'),_0x51b0cb,_0x5ad014[0x0]);var _0x507ac0={'closed':0x1,'closedAt':moment()[_0x7f41('0x7')]('YYYY-MM-DD\x20HH:mm:ss'),'closeReason':_0x7f41('0x8'),'disposition':_0x5ad014[0x0]};if(rpc[_0x1775d8['channel']+_0x7f41('0x9')]){rpc[_0x1775d8[_0x7f41('0xa')]+'Interaction']['update'](_0x1775d8[_0x7f41('0xb')]['id'],_0x507ac0)['then'](function(_0x4bc8ff){logger[_0x7f41('0x5')](_0x7f41('0xc'),_0x51b0cb,_0x1775d8[_0x7f41('0xb')]['id']);})[_0x7f41('0xd')](function(_0x637b2d){logger[_0x7f41('0xe')](_0x7f41('0xf'),_0x51b0cb,JSON['stringify'](_0x637b2d));})['finally'](function(){_0x4e37b5[_0x7f41('0x10')]();});}}catch(_0x4f5b74){logger['error'](_0x7f41('0xf'),_0x51b0cb,JSON[_0x7f41('0x11')](_0x4f5b74));_0x4e37b5[_0x7f41('0x10')]();}};};