Built motion from commit eddce310.|2.6.12
[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 _0x105f=['Message','create','[%s][MESSAGE]\x20%s','body','next','stringify','stop','error','./utils','../../rpc/openchannelMessage','../../rpc/smsMessage','../../rpc/faxMessage','../../rpc/whatsappMessage','consequence','getMustacheRender','channel','chat','ChatWebsiteId','account','upperFirst','interaction'];(function(_0xd9acb4,_0x153a82){var _0x479cc2=function(_0x30fcbe){while(--_0x30fcbe){_0xd9acb4['push'](_0xd9acb4['shift']());}};_0x479cc2(++_0x153a82);}(_0x105f,0x71));var _0xf105=function(_0x1ea185,_0x27e48d){_0x1ea185=_0x1ea185-0x0;var _0x4ac9e3=_0x105f[_0x1ea185];return _0x4ac9e3;};'use strict';var _=require('lodash');var utils=require(_0xf105('0x0'));var logger=require('../../../../config/logger')('routing');var rpc={'chatMessage':require('../../rpc/chatMessage'),'openchannelMessage':require(_0xf105('0x1')),'mailMessage':require('../../rpc/mailMessage'),'smsMessage':require(_0xf105('0x2')),'faxMessage':require(_0xf105('0x3')),'whatsappMessage':require(_0xf105('0x4'))};exports[_0xf105('0x5')]=function(_0x58224e,_0x374059){return function(_0x100675){try{var _0x5f4946={'body':utils[_0xf105('0x6')](_0x374059[0x0],this),'ContactId':this['contact']['id']};if(this[_0xf105('0x7')]===_0xf105('0x8')){_0x5f4946[_0xf105('0x9')]=this[_0xf105('0xa')]['id'];}else{_0x5f4946[_['upperFirst'](this['channel'])+'AccountId']=this['account']['id'];}_0x5f4946[_[_0xf105('0xb')](this[_0xf105('0x7')])+'InteractionId']=this[_0xf105('0xc')]['id'];if(rpc[this[_0xf105('0x7')]+_0xf105('0xd')]){return rpc[this[_0xf105('0x7')]+_0xf105('0xd')][_0xf105('0xe')](_0x5f4946)['then'](function(_0x2f2dd5){logger['info'](_0xf105('0xf'),_0x58224e,_0x5f4946[_0xf105('0x10')]);_0x100675[_0xf105('0x11')]();})['catch'](function(_0x26b7b6){logger['error']('[%s][MESSAGE]\x20%s',_0x58224e,JSON[_0xf105('0x12')](_0x26b7b6));_0x100675[_0xf105('0x13')]();});}}catch(_0x24dd40){logger[_0xf105('0x14')](_0xf105('0xf'),_0x58224e,JSON['stringify'](_0x24dd40));_0x100675[_0xf105('0x13')]();}};};