b89d1ec91f453db8e308af7bf18b04b3d84a61dd
[motion2.git] / server / services / routing / server / applications / message.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 _0x01f6=['../../../../config/logger','routing','../../rpc/openchannelMessage','../../rpc/mailMessage','../../rpc/smsMessage','../../rpc/faxMessage','../../rpc/whatsappMessage','getMustacheRender','channel','chat','ChatWebsiteId','account','upperFirst','InteractionId','interaction','Message','create','then','info','[%s][MESSAGE]\x20%s','body','next','catch','stringify','stop','error'];(function(_0x269094,_0x4701b3){var _0x10344f=function(_0x180a69){while(--_0x180a69){_0x269094['push'](_0x269094['shift']());}};_0x10344f(++_0x4701b3);}(_0x01f6,0xea));var _0x601f=function(_0x2b07a1,_0x25c79a){_0x2b07a1=_0x2b07a1-0x0;var _0x4bb96b=_0x01f6[_0x2b07a1];return _0x4bb96b;};'use strict';var _=require('lodash');var utils=require('./utils');var logger=require(_0x601f('0x0'))(_0x601f('0x1'));var rpc={'chatMessage':require('../../rpc/chatMessage'),'openchannelMessage':require(_0x601f('0x2')),'mailMessage':require(_0x601f('0x3')),'smsMessage':require(_0x601f('0x4')),'faxMessage':require(_0x601f('0x5')),'whatsappMessage':require(_0x601f('0x6'))};exports['consequence']=function(_0x8f542,_0x5724a2){return function(_0x824bec){try{var _0x4822c4={'body':utils[_0x601f('0x7')](_0x5724a2[0x0],this),'ContactId':this['contact']['id']};if(this[_0x601f('0x8')]===_0x601f('0x9')){_0x4822c4[_0x601f('0xa')]=this[_0x601f('0xb')]['id'];}else{_0x4822c4[_[_0x601f('0xc')](this[_0x601f('0x8')])+'AccountId']=this['account']['id'];}_0x4822c4[_['upperFirst'](this['channel'])+_0x601f('0xd')]=this[_0x601f('0xe')]['id'];if(rpc[this['channel']+_0x601f('0xf')]){return rpc[this[_0x601f('0x8')]+_0x601f('0xf')][_0x601f('0x10')](_0x4822c4)[_0x601f('0x11')](function(_0x5ef0da){logger[_0x601f('0x12')](_0x601f('0x13'),_0x8f542,_0x4822c4[_0x601f('0x14')]);_0x824bec[_0x601f('0x15')]();})[_0x601f('0x16')](function(_0x14770b){logger['error']('[%s][MESSAGE]\x20%s',_0x8f542,JSON[_0x601f('0x17')](_0x14770b));_0x824bec[_0x601f('0x18')]();});}}catch(_0x3e008e){logger[_0x601f('0x19')](_0x601f('0x13'),_0x8f542,JSON[_0x601f('0x17')](_0x3e008e));_0x824bec[_0x601f('0x18')]();}};};