6e718332a96b1ac10a9fae7cb8cdaa11df240c18
[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 _0xdcb3=['next','catch','error','[%s][MESSAGE]\x20%s','stop','stringify','lodash','./utils','../../../../config/logger','routing','../../rpc/chatMessage','../../rpc/openchannelMessage','../../rpc/mailMessage','../../rpc/whatsappMessage','consequence','getMustacheRender','contact','chat','account','upperFirst','channel','Message','create','info','body'];(function(_0x45c981,_0x2ad2d4){var _0x4f62c8=function(_0x55209b){while(--_0x55209b){_0x45c981['push'](_0x45c981['shift']());}};_0x4f62c8(++_0x2ad2d4);}(_0xdcb3,0x6a));var _0x3dcb=function(_0x10a622,_0x1804be){_0x10a622=_0x10a622-0x0;var _0x707210=_0xdcb3[_0x10a622];return _0x707210;};'use strict';var _=require(_0x3dcb('0x0'));var utils=require(_0x3dcb('0x1'));var logger=require(_0x3dcb('0x2'))(_0x3dcb('0x3'));var rpc={'chatMessage':require(_0x3dcb('0x4')),'openchannelMessage':require(_0x3dcb('0x5')),'mailMessage':require(_0x3dcb('0x6')),'smsMessage':require('../../rpc/smsMessage'),'faxMessage':require('../../rpc/faxMessage'),'whatsappMessage':require(_0x3dcb('0x7'))};exports[_0x3dcb('0x8')]=function(_0x4e2b4e,_0xea9d6a){return function(_0x588ec9){try{var _0x410a13={'body':utils[_0x3dcb('0x9')](_0xea9d6a[0x0],this),'ContactId':this[_0x3dcb('0xa')]['id']};if(this['channel']===_0x3dcb('0xb')){_0x410a13['ChatWebsiteId']=this[_0x3dcb('0xc')]['id'];}else{_0x410a13[_[_0x3dcb('0xd')](this['channel'])+'AccountId']=this[_0x3dcb('0xc')]['id'];}_0x410a13[_['upperFirst'](this[_0x3dcb('0xe')])+'InteractionId']=this['interaction']['id'];if(rpc[this[_0x3dcb('0xe')]+'Message']){return rpc[this['channel']+_0x3dcb('0xf')][_0x3dcb('0x10')](_0x410a13)['then'](function(_0x295093){logger[_0x3dcb('0x11')]('[%s][MESSAGE]\x20%s',_0x4e2b4e,_0x410a13[_0x3dcb('0x12')]);_0x588ec9[_0x3dcb('0x13')]();})[_0x3dcb('0x14')](function(_0xdd3bdd){logger[_0x3dcb('0x15')](_0x3dcb('0x16'),_0x4e2b4e,JSON['stringify'](_0xdd3bdd));_0x588ec9[_0x3dcb('0x17')]();});}}catch(_0x221eb8){logger[_0x3dcb('0x15')]('[%s][MESSAGE]\x20%s',_0x4e2b4e,JSON[_0x3dcb('0x18')](_0x221eb8));_0x588ec9['stop']();}};};