174e11349ebe631548dd66b25fc7af18a6f18a1b
[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 _0x3e57=['error','stringify','stop','lodash','./utils','routing','../../rpc/mailMessage','../../rpc/smsMessage','../../rpc/faxMessage','consequence','getMustacheRender','contact','channel','chat','ChatWebsiteId','upperFirst','AccountId','InteractionId','info','[%s][MESSAGE]\x20%s','body','next'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x3e57,0x1d1));var _0x73e5=function(_0xae7c2f,_0xf31e04){_0xae7c2f=_0xae7c2f-0x0;var _0x5d7001=_0x3e57[_0xae7c2f];return _0x5d7001;};'use strict';var _=require(_0x73e5('0x0'));var utils=require(_0x73e5('0x1'));var logger=require('../../../../config/logger')(_0x73e5('0x2'));var rpc={'chatMessage':require('../../rpc/chatMessage'),'openchannelMessage':require('../../rpc/openchannelMessage'),'mailMessage':require(_0x73e5('0x3')),'smsMessage':require(_0x73e5('0x4')),'faxMessage':require(_0x73e5('0x5')),'whatsappMessage':require('../../rpc/whatsappMessage')};exports[_0x73e5('0x6')]=function(_0x3e3811,_0x591faa){return function(_0x36f626){try{var _0x1a80dc={'body':utils[_0x73e5('0x7')](_0x591faa[0x0],this),'ContactId':this[_0x73e5('0x8')]['id']};if(this[_0x73e5('0x9')]===_0x73e5('0xa')){_0x1a80dc[_0x73e5('0xb')]=this['account']['id'];}else{_0x1a80dc[_[_0x73e5('0xc')](this['channel'])+_0x73e5('0xd')]=this['account']['id'];}_0x1a80dc[_[_0x73e5('0xc')](this['channel'])+_0x73e5('0xe')]=this['interaction']['id'];if(rpc[this['channel']+'Message']){return rpc[this[_0x73e5('0x9')]+'Message']['create'](_0x1a80dc)['then'](function(_0x52079c){logger[_0x73e5('0xf')](_0x73e5('0x10'),_0x3e3811,_0x1a80dc[_0x73e5('0x11')]);_0x36f626[_0x73e5('0x12')]();})['catch'](function(_0x404eae){logger[_0x73e5('0x13')]('[%s][MESSAGE]\x20%s',_0x3e3811,JSON[_0x73e5('0x14')](_0x404eae));_0x36f626['stop']();});}}catch(_0x1835db){logger[_0x73e5('0x13')](_0x73e5('0x10'),_0x3e3811,JSON[_0x73e5('0x14')](_0x1835db));_0x36f626[_0x73e5('0x15')]();}};};