384cdda75d1083e405864d19d3168e60a938d401
[motion2.git] / server / api / whatsappMessage / whatsappMessage.rpc.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 _0x597b=['lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','rpc','../../config/environment','jayson/promise','client','redis','localhost','socket.io-emitter','./whatsappMessage.socket','then','info','request\x20sent','debug','WhatsappMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','WhatsappMessage,\x20%s,\x20%s','message','result','catch','CreateWhatsappMessage','create','body','options','raw'];(function(_0x524cd2,_0x4086be){var _0x2df158=function(_0x1f36e0){while(--_0x1f36e0){_0x524cd2['push'](_0x524cd2['shift']());}};_0x2df158(++_0x4086be);}(_0x597b,0xe0));var _0xb597=function(_0x27ce3c,_0x8e48e){_0x27ce3c=_0x27ce3c-0x0;var _0x40560c=_0x597b[_0x27ce3c];return _0x40560c;};'use strict';var _=require(_0xb597('0x0'));var util=require(_0xb597('0x1'));var moment=require(_0xb597('0x2'));var BPromise=require(_0xb597('0x3'));var rs=require(_0xb597('0x4'));var fs=require('fs');var Redis=require(_0xb597('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0xb597('0x6'));var logger=require('../../config/logger')(_0xb597('0x7'));var config=require(_0xb597('0x8'));var jayson=require(_0xb597('0x9'));var client=jayson[_0xb597('0xa')]['http']({'port':0x232a});config['redis']=_['defaults'](config[_0xb597('0xb')],{'host':_0xb597('0xc'),'port':0x18eb});var socket=require(_0xb597('0xd'))(new Redis(config[_0xb597('0xb')]));require(_0xb597('0xe'))['register'](socket);function respondWithRpcPromise(_0x1a30a3,_0x2f2599,_0x3eb585){return new BPromise(function(_0x4eef70,_0x4c1ed8){return client['request'](_0x1a30a3,_0x3eb585)[_0xb597('0xf')](function(_0x387669){logger[_0xb597('0x10')]('WhatsappMessage,\x20%s,\x20%s',_0x2f2599,_0xb597('0x11'));logger[_0xb597('0x12')](_0xb597('0x13'),_0x2f2599,_0xb597('0x11'),JSON[_0xb597('0x14')](_0x387669));if(_0x387669[_0xb597('0x15')]){if(_0x387669[_0xb597('0x15')][_0xb597('0x16')]===0x1f4){logger[_0xb597('0x15')](_0xb597('0x17'),_0x2f2599,_0x387669[_0xb597('0x15')][_0xb597('0x18')]);return _0x4c1ed8(_0x387669[_0xb597('0x15')][_0xb597('0x18')]);}logger[_0xb597('0x15')](_0xb597('0x17'),_0x2f2599,_0x387669[_0xb597('0x15')][_0xb597('0x18')]);return _0x4eef70(_0x387669[_0xb597('0x15')][_0xb597('0x18')]);}else{logger[_0xb597('0x10')](_0xb597('0x17'),_0x2f2599,'request\x20sent');_0x4eef70(_0x387669[_0xb597('0x19')][_0xb597('0x18')]);}})[_0xb597('0x1a')](function(_0x28bdf8){logger['error'](_0xb597('0x17'),_0x2f2599,_0x28bdf8);_0x4c1ed8(_0x28bdf8);});});}exports[_0xb597('0x1b')]=function(_0x46fed5){var _0x369db2=this;return new Promise(function(_0x467c16,_0x2ffe98){return db['WhatsappMessage'][_0xb597('0x1c')](_0x46fed5[_0xb597('0x1d')],{'raw':_0x46fed5['options']?_0x46fed5[_0xb597('0x1e')][_0xb597('0x1f')]===undefined?!![]:![]:!![]})['then'](function(_0x55c155){logger['info'](_0xb597('0x1b'),_0x46fed5);logger[_0xb597('0x12')](_0xb597('0x1b'),_0x46fed5,JSON['stringify'](_0x55c155));_0x467c16(_0x55c155);})['catch'](function(_0x509fe1){logger[_0xb597('0x15')](_0xb597('0x1b'),_0x509fe1['message'],_0x46fed5);_0x2ffe98(_0x369db2[_0xb597('0x15')](0x1f4,_0x509fe1[_0xb597('0x18')]));});});};