Built motion from commit (unavailable).|2.5.22
[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 _0x1c42=['stringify','error','message','info','result','catch','CreateWhatsappMessage','WhatsappMessage','create','body','options','raw','then','lodash','util','moment','bluebird','ioredis','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','defaults','redis','localhost','socket.io-emitter','register','WhatsappMessage,\x20%s,\x20%s','request\x20sent','debug'];(function(_0x409f2f,_0x2db552){var _0x46ba7a=function(_0x18a206){while(--_0x18a206){_0x409f2f['push'](_0x409f2f['shift']());}};_0x46ba7a(++_0x2db552);}(_0x1c42,0xad));var _0x21c4=function(_0x2ea791,_0x22b18a){_0x2ea791=_0x2ea791-0x0;var _0x1be678=_0x1c42[_0x2ea791];return _0x1be678;};'use strict';var _=require(_0x21c4('0x0'));var util=require(_0x21c4('0x1'));var moment=require(_0x21c4('0x2'));var BPromise=require(_0x21c4('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x21c4('0x4'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x21c4('0x5'))(_0x21c4('0x6'));var config=require(_0x21c4('0x7'));var jayson=require(_0x21c4('0x8'));var client=jayson[_0x21c4('0x9')][_0x21c4('0xa')]({'port':0x232a});config['redis']=_[_0x21c4('0xb')](config[_0x21c4('0xc')],{'host':_0x21c4('0xd'),'port':0x18eb});var socket=require(_0x21c4('0xe'))(new Redis(config[_0x21c4('0xc')]));require('./whatsappMessage.socket')[_0x21c4('0xf')](socket);function respondWithRpcPromise(_0x17231f,_0x53e97e,_0x193cf8){return new BPromise(function(_0x50ae17,_0x148dbe){return client['request'](_0x17231f,_0x193cf8)['then'](function(_0x2adc6c){logger['info'](_0x21c4('0x10'),_0x53e97e,_0x21c4('0x11'));logger[_0x21c4('0x12')]('WhatsappMessage,\x20%s,\x20%s,\x20%s',_0x53e97e,_0x21c4('0x11'),JSON[_0x21c4('0x13')](_0x2adc6c));if(_0x2adc6c[_0x21c4('0x14')]){if(_0x2adc6c[_0x21c4('0x14')]['code']===0x1f4){logger[_0x21c4('0x14')](_0x21c4('0x10'),_0x53e97e,_0x2adc6c[_0x21c4('0x14')][_0x21c4('0x15')]);return _0x148dbe(_0x2adc6c['error'][_0x21c4('0x15')]);}logger[_0x21c4('0x14')](_0x21c4('0x10'),_0x53e97e,_0x2adc6c['error'][_0x21c4('0x15')]);return _0x50ae17(_0x2adc6c['error'][_0x21c4('0x15')]);}else{logger[_0x21c4('0x16')](_0x21c4('0x10'),_0x53e97e,_0x21c4('0x11'));_0x50ae17(_0x2adc6c[_0x21c4('0x17')]['message']);}})[_0x21c4('0x18')](function(_0x2799b7){logger[_0x21c4('0x14')](_0x21c4('0x10'),_0x53e97e,_0x2799b7);_0x148dbe(_0x2799b7);});});}exports[_0x21c4('0x19')]=function(_0x87205d){var _0x22cfe7=this;return new Promise(function(_0x1de534,_0x180223){return db[_0x21c4('0x1a')][_0x21c4('0x1b')](_0x87205d[_0x21c4('0x1c')],{'raw':_0x87205d[_0x21c4('0x1d')]?_0x87205d[_0x21c4('0x1d')][_0x21c4('0x1e')]===undefined?!![]:![]:!![]})[_0x21c4('0x1f')](function(_0x67ccad){logger[_0x21c4('0x16')]('CreateWhatsappMessage',_0x87205d);logger['debug'](_0x21c4('0x19'),_0x87205d,JSON[_0x21c4('0x13')](_0x67ccad));_0x1de534(_0x67ccad);})['catch'](function(_0x3dd597){logger[_0x21c4('0x14')](_0x21c4('0x19'),_0x3dd597[_0x21c4('0x15')],_0x87205d);_0x180223(_0x22cfe7['error'](0x1f4,_0x3dd597[_0x21c4('0x15')]));});});};