d410377cfe268673716a652b8be96ad7d0509c26
[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 _0xfff0=['stop','./utils','../../../../config/logger','routing','../../rpc/openchannelMessage','../../rpc/mailMessage','../../rpc/smsMessage','../../rpc/whatsappMessage','consequence','contact','chat','account','upperFirst','AccountId','channel','InteractionId','interaction','Message','create','[%s][MESSAGE]\x20%s','body','next','catch','error'];(function(_0xca2f17,_0x2f3cc7){var _0x24811d=function(_0x269da4){while(--_0x269da4){_0xca2f17['push'](_0xca2f17['shift']());}};_0x24811d(++_0x2f3cc7);}(_0xfff0,0x139));var _0x0fff=function(_0x1db788,_0x4e0465){_0x1db788=_0x1db788-0x0;var _0x51b4b2=_0xfff0[_0x1db788];return _0x51b4b2;};'use strict';var _=require('lodash');var utils=require(_0x0fff('0x0'));var logger=require(_0x0fff('0x1'))(_0x0fff('0x2'));var rpc={'chatMessage':require('../../rpc/chatMessage'),'openchannelMessage':require(_0x0fff('0x3')),'mailMessage':require(_0x0fff('0x4')),'smsMessage':require(_0x0fff('0x5')),'faxMessage':require('../../rpc/faxMessage'),'whatsappMessage':require(_0x0fff('0x6'))};exports[_0x0fff('0x7')]=function(_0x53c517,_0x33c813){return function(_0x4c2221){try{var _0x2f1d2b={'body':utils['getMustacheRender'](_0x33c813[0x0],this),'ContactId':this[_0x0fff('0x8')]['id']};if(this['channel']===_0x0fff('0x9')){_0x2f1d2b['ChatWebsiteId']=this[_0x0fff('0xa')]['id'];}else{_0x2f1d2b[_[_0x0fff('0xb')](this['channel'])+_0x0fff('0xc')]=this[_0x0fff('0xa')]['id'];}_0x2f1d2b[_[_0x0fff('0xb')](this[_0x0fff('0xd')])+_0x0fff('0xe')]=this[_0x0fff('0xf')]['id'];if(rpc[this[_0x0fff('0xd')]+_0x0fff('0x10')]){return rpc[this[_0x0fff('0xd')]+_0x0fff('0x10')][_0x0fff('0x11')](_0x2f1d2b)['then'](function(_0x1fb243){logger['info'](_0x0fff('0x12'),_0x53c517,_0x2f1d2b[_0x0fff('0x13')]);_0x4c2221[_0x0fff('0x14')]();})[_0x0fff('0x15')](function(_0x55e5fa){logger['error'](_0x0fff('0x12'),_0x53c517,JSON['stringify'](_0x55e5fa));_0x4c2221['stop']();});}}catch(_0x51ceea){logger[_0x0fff('0x16')](_0x0fff('0x12'),_0x53c517,JSON['stringify'](_0x51ceea));_0x4c2221[_0x0fff('0x17')]();}};};