863dcc2e8e112f58a5f6c7e668ecd2b0926bf58e
[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 _0xa393=['[%s][MESSAGE]\x20%s','stop','stringify','lodash','./utils','routing','../../rpc/chatMessage','../../rpc/mailMessage','../../rpc/smsMessage','../../rpc/faxMessage','../../rpc/whatsappMessage','contact','channel','ChatWebsiteId','upperFirst','AccountId','InteractionId','interaction','Message','create','info','body','next','catch','error'];(function(_0x27ff35,_0x43abb8){var _0x18138f=function(_0x4ea812){while(--_0x4ea812){_0x27ff35['push'](_0x27ff35['shift']());}};_0x18138f(++_0x43abb8);}(_0xa393,0x12f));var _0x3a39=function(_0x231e16,_0x67347b){_0x231e16=_0x231e16-0x0;var _0x570a7c=_0xa393[_0x231e16];return _0x570a7c;};'use strict';var _=require(_0x3a39('0x0'));var utils=require(_0x3a39('0x1'));var logger=require('../../../../config/logger')(_0x3a39('0x2'));var rpc={'chatMessage':require(_0x3a39('0x3')),'openchannelMessage':require('../../rpc/openchannelMessage'),'mailMessage':require(_0x3a39('0x4')),'smsMessage':require(_0x3a39('0x5')),'faxMessage':require(_0x3a39('0x6')),'whatsappMessage':require(_0x3a39('0x7'))};exports['consequence']=function(_0x1134e9,_0x388c58){return function(_0x3815a4){try{var _0x1fa116={'body':utils['getMustacheRender'](_0x388c58[0x0],this),'ContactId':this[_0x3a39('0x8')]['id']};if(this[_0x3a39('0x9')]==='chat'){_0x1fa116[_0x3a39('0xa')]=this['account']['id'];}else{_0x1fa116[_[_0x3a39('0xb')](this[_0x3a39('0x9')])+_0x3a39('0xc')]=this['account']['id'];}_0x1fa116[_[_0x3a39('0xb')](this[_0x3a39('0x9')])+_0x3a39('0xd')]=this[_0x3a39('0xe')]['id'];if(rpc[this[_0x3a39('0x9')]+_0x3a39('0xf')]){return rpc[this[_0x3a39('0x9')]+_0x3a39('0xf')][_0x3a39('0x10')](_0x1fa116)['then'](function(_0x48f378){logger[_0x3a39('0x11')]('[%s][MESSAGE]\x20%s',_0x1134e9,_0x1fa116[_0x3a39('0x12')]);_0x3815a4[_0x3a39('0x13')]();})[_0x3a39('0x14')](function(_0x5d5fc7){logger[_0x3a39('0x15')](_0x3a39('0x16'),_0x1134e9,JSON['stringify'](_0x5d5fc7));_0x3815a4[_0x3a39('0x17')]();});}}catch(_0x2950b7){logger[_0x3a39('0x15')](_0x3a39('0x16'),_0x1134e9,JSON[_0x3a39('0x18')](_0x2950b7));_0x3815a4[_0x3a39('0x17')]();}};};