Built motion from commit 092f8824.|2.5.49
[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 _0xab0e=['result','catch','CreateWhatsappMessage','WhatsappMessage','create','options','raw','then','debug','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','redis','localhost','socket.io-emitter','./whatsappMessage.socket','register','request','info','request\x20sent','WhatsappMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','WhatsappMessage,\x20%s,\x20%s','message'];(function(_0x21a9d9,_0x4d5ac8){var _0x46adce=function(_0xfdd336){while(--_0xfdd336){_0x21a9d9['push'](_0x21a9d9['shift']());}};_0x46adce(++_0x4d5ac8);}(_0xab0e,0xb3));var _0xeab0=function(_0x11005e,_0x20c3d2){_0x11005e=_0x11005e-0x0;var _0x29338f=_0xab0e[_0x11005e];return _0x29338f;};'use strict';var _=require('lodash');var util=require(_0xeab0('0x0'));var moment=require('moment');var BPromise=require(_0xeab0('0x1'));var rs=require(_0xeab0('0x2'));var fs=require('fs');var Redis=require(_0xeab0('0x3'));var db=require(_0xeab0('0x4'))['db'];var utils=require(_0xeab0('0x5'));var logger=require('../../config/logger')(_0xeab0('0x6'));var config=require(_0xeab0('0x7'));var jayson=require(_0xeab0('0x8'));var client=jayson[_0xeab0('0x9')][_0xeab0('0xa')]({'port':0x232a});config[_0xeab0('0xb')]=_['defaults'](config[_0xeab0('0xb')],{'host':_0xeab0('0xc'),'port':0x18eb});var socket=require(_0xeab0('0xd'))(new Redis(config[_0xeab0('0xb')]));require(_0xeab0('0xe'))[_0xeab0('0xf')](socket);function respondWithRpcPromise(_0x521ad2,_0x4b17ba,_0x593351){return new BPromise(function(_0x31eb63,_0x584200){return client[_0xeab0('0x10')](_0x521ad2,_0x593351)['then'](function(_0x1ea16f){logger[_0xeab0('0x11')]('WhatsappMessage,\x20%s,\x20%s',_0x4b17ba,_0xeab0('0x12'));logger['debug'](_0xeab0('0x13'),_0x4b17ba,_0xeab0('0x12'),JSON[_0xeab0('0x14')](_0x1ea16f));if(_0x1ea16f[_0xeab0('0x15')]){if(_0x1ea16f[_0xeab0('0x15')][_0xeab0('0x16')]===0x1f4){logger[_0xeab0('0x15')](_0xeab0('0x17'),_0x4b17ba,_0x1ea16f[_0xeab0('0x15')][_0xeab0('0x18')]);return _0x584200(_0x1ea16f[_0xeab0('0x15')][_0xeab0('0x18')]);}logger[_0xeab0('0x15')]('WhatsappMessage,\x20%s,\x20%s',_0x4b17ba,_0x1ea16f['error'][_0xeab0('0x18')]);return _0x31eb63(_0x1ea16f[_0xeab0('0x15')]['message']);}else{logger[_0xeab0('0x11')](_0xeab0('0x17'),_0x4b17ba,_0xeab0('0x12'));_0x31eb63(_0x1ea16f[_0xeab0('0x19')]['message']);}})[_0xeab0('0x1a')](function(_0x1b2f39){logger['error']('WhatsappMessage,\x20%s,\x20%s',_0x4b17ba,_0x1b2f39);_0x584200(_0x1b2f39);});});}exports[_0xeab0('0x1b')]=function(_0x5f10e6){var _0x65abe6=this;return new Promise(function(_0x50a55d,_0x28ed6d){return db[_0xeab0('0x1c')][_0xeab0('0x1d')](_0x5f10e6['body'],{'raw':_0x5f10e6[_0xeab0('0x1e')]?_0x5f10e6[_0xeab0('0x1e')][_0xeab0('0x1f')]===undefined?!![]:![]:!![]})[_0xeab0('0x20')](function(_0x132d31){logger[_0xeab0('0x11')](_0xeab0('0x1b'),_0x5f10e6);logger[_0xeab0('0x21')](_0xeab0('0x1b'),_0x5f10e6,JSON['stringify'](_0x132d31));_0x50a55d(_0x132d31);})[_0xeab0('0x1a')](function(_0x1a493f){logger[_0xeab0('0x15')](_0xeab0('0x1b'),_0x1a493f[_0xeab0('0x18')],_0x5f10e6);_0x28ed6d(_0x65abe6[_0xeab0('0x15')](0x1f4,_0x1a493f[_0xeab0('0x18')]));});});};