308b549cb9955b0adfd7dfcd57e80fb8129f21b5
[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 _0xe2fe=['../../rpc/smsInteraction','../../rpc/mailInteraction','../../rpc/faxInteraction','../../rpc/whatsappInteraction','consequence','info','YYYY-MM-DD\x20HH:mm:ss','system','Interaction','channel','catch','error','[%s][CLOSE]\x20%s','stringify','finally','moment','../../rpc/chatInteraction'];(function(_0x4e1ca7,_0x192e6a){var _0x485408=function(_0x4ba42e){while(--_0x4ba42e){_0x4e1ca7['push'](_0x4e1ca7['shift']());}};_0x485408(++_0x192e6a);}(_0xe2fe,0x86));var _0xee2f=function(_0x14add3,_0x13ce8d){_0x14add3=_0x14add3-0x0;var _0x4a174f=_0xe2fe[_0x14add3];return _0x4a174f;};'use strict';var moment=require(_0xee2f('0x0'));var logger=require('../../../../config/logger')('routing');var rpc={'chatInteraction':require(_0xee2f('0x1')),'openchannelInteraction':require('../../rpc/openchannelInteraction'),'smsInteraction':require(_0xee2f('0x2')),'mailInteraction':require(_0xee2f('0x3')),'faxInteraction':require(_0xee2f('0x4')),'whatsappInteraction':require(_0xee2f('0x5'))};exports[_0xee2f('0x6')]=function(_0x4ba89f,_0x311a2f,_0x2b7e7c,_0x49926b){return function(_0x1533a0){try{logger[_0xee2f('0x7')]('[%s][CLOSE]\x20reason\x20%s',_0x4ba89f,_0x311a2f[0x0]);var _0x3c4095={'closed':0x1,'closedAt':moment()['format'](_0xee2f('0x8')),'closeReason':_0xee2f('0x9'),'disposition':_0x311a2f[0x0]};if(rpc[_0x49926b['channel']+_0xee2f('0xa')]){rpc[_0x49926b[_0xee2f('0xb')]+'Interaction']['update'](_0x49926b['interaction']['id'],_0x3c4095)['then'](function(_0x2b8fb1){logger['info']('[%s][CLOSE]\x20interaction\x20%s\x20has\x20been\x20closed!',_0x4ba89f,_0x49926b['interaction']['id']);})[_0xee2f('0xc')](function(_0x346dbc){logger[_0xee2f('0xd')](_0xee2f('0xe'),_0x4ba89f,JSON[_0xee2f('0xf')](_0x346dbc));})[_0xee2f('0x10')](function(){_0x1533a0['stop']();});}}catch(_0x3861e6){logger['error'](_0xee2f('0xe'),_0x4ba89f,JSON[_0xee2f('0xf')](_0x3861e6));_0x1533a0['stop']();}};};