Built motion from commit 5ad77b03.|2.6.3
[motion2.git] / server / api / whatsappQueue / whatsappQueue.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 _0xffb1=['GetWhatsappQueue','WhatsappQueue','findAll','options','raw','where','attributes','include','map','model','then','debug','stringify','ShowWhatsappQueue','find','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','localhost','socket.io-emitter','./whatsappQueue.socket','register','request','info','WhatsappQueue,\x20%s,\x20%s','request\x20sent','WhatsappQueue,\x20%s,\x20%s,\x20%s','error','code','message','result','catch'];(function(_0x53a0a9,_0x39c3e9){var _0x119dbf=function(_0x332c98){while(--_0x332c98){_0x53a0a9['push'](_0x53a0a9['shift']());}};_0x119dbf(++_0x39c3e9);}(_0xffb1,0x143));var _0x1ffb=function(_0x569caa,_0x5174ce){_0x569caa=_0x569caa-0x0;var _0x44cb5a=_0xffb1[_0x569caa];return _0x44cb5a;};'use strict';var _=require(_0x1ffb('0x0'));var util=require(_0x1ffb('0x1'));var moment=require(_0x1ffb('0x2'));var BPromise=require(_0x1ffb('0x3'));var rs=require(_0x1ffb('0x4'));var fs=require('fs');var Redis=require(_0x1ffb('0x5'));var db=require(_0x1ffb('0x6'))['db'];var utils=require(_0x1ffb('0x7'));var logger=require(_0x1ffb('0x8'))(_0x1ffb('0x9'));var config=require(_0x1ffb('0xa'));var jayson=require(_0x1ffb('0xb'));var client=jayson[_0x1ffb('0xc')][_0x1ffb('0xd')]({'port':0x232a});config[_0x1ffb('0xe')]=_['defaults'](config[_0x1ffb('0xe')],{'host':_0x1ffb('0xf'),'port':0x18eb});var socket=require(_0x1ffb('0x10'))(new Redis(config[_0x1ffb('0xe')]));require(_0x1ffb('0x11'))[_0x1ffb('0x12')](socket);function respondWithRpcPromise(_0x28ecb9,_0x16e2da,_0x551422){return new BPromise(function(_0x1096ab,_0x144957){return client[_0x1ffb('0x13')](_0x28ecb9,_0x551422)['then'](function(_0x44b276){logger[_0x1ffb('0x14')](_0x1ffb('0x15'),_0x16e2da,_0x1ffb('0x16'));logger['debug'](_0x1ffb('0x17'),_0x16e2da,_0x1ffb('0x16'),JSON['stringify'](_0x44b276));if(_0x44b276[_0x1ffb('0x18')]){if(_0x44b276[_0x1ffb('0x18')][_0x1ffb('0x19')]===0x1f4){logger[_0x1ffb('0x18')](_0x1ffb('0x15'),_0x16e2da,_0x44b276['error'][_0x1ffb('0x1a')]);return _0x144957(_0x44b276[_0x1ffb('0x18')]['message']);}logger[_0x1ffb('0x18')]('WhatsappQueue,\x20%s,\x20%s',_0x16e2da,_0x44b276[_0x1ffb('0x18')][_0x1ffb('0x1a')]);return _0x1096ab(_0x44b276['error'][_0x1ffb('0x1a')]);}else{logger[_0x1ffb('0x14')](_0x1ffb('0x15'),_0x16e2da,'request\x20sent');_0x1096ab(_0x44b276[_0x1ffb('0x1b')][_0x1ffb('0x1a')]);}})[_0x1ffb('0x1c')](function(_0x4343e4){logger['error'](_0x1ffb('0x15'),_0x16e2da,_0x4343e4);_0x144957(_0x4343e4);});});}exports[_0x1ffb('0x1d')]=function(_0x5335e6){var _0x3cc7f2=this;return new Promise(function(_0x593be0,_0x2d2f6e){return db[_0x1ffb('0x1e')][_0x1ffb('0x1f')]({'raw':_0x5335e6[_0x1ffb('0x20')]?_0x5335e6[_0x1ffb('0x20')][_0x1ffb('0x21')]===undefined?!![]:![]:!![],'where':_0x5335e6[_0x1ffb('0x20')]?_0x5335e6[_0x1ffb('0x20')][_0x1ffb('0x22')]||null:null,'attributes':_0x5335e6[_0x1ffb('0x20')]?_0x5335e6[_0x1ffb('0x20')][_0x1ffb('0x23')]||null:null,'limit':_0x5335e6['options']?_0x5335e6[_0x1ffb('0x20')]['limit']||null:null,'include':_0x5335e6[_0x1ffb('0x20')]?_0x5335e6[_0x1ffb('0x20')][_0x1ffb('0x24')]?_[_0x1ffb('0x25')](_0x5335e6[_0x1ffb('0x20')][_0x1ffb('0x24')],function(_0x265976){return{'model':db[_0x265976[_0x1ffb('0x26')]],'as':_0x265976['as'],'attributes':_0x265976[_0x1ffb('0x23')],'include':_0x265976['include']?_[_0x1ffb('0x25')](_0x265976[_0x1ffb('0x24')],function(_0x48b8dc){return{'model':db[_0x48b8dc[_0x1ffb('0x26')]],'as':_0x48b8dc['as'],'attributes':_0x48b8dc[_0x1ffb('0x23')],'include':_0x48b8dc[_0x1ffb('0x24')]?_[_0x1ffb('0x25')](_0x48b8dc[_0x1ffb('0x24')],function(_0x5c85f4){return{'model':db[_0x5c85f4[_0x1ffb('0x26')]],'as':_0x5c85f4['as'],'attributes':_0x5c85f4[_0x1ffb('0x23')]};}):[]};}):[]};}):[]:[]})[_0x1ffb('0x27')](function(_0x3e36d2){logger['info'](_0x1ffb('0x1d'),_0x5335e6);logger[_0x1ffb('0x28')](_0x1ffb('0x1d'),_0x5335e6,JSON[_0x1ffb('0x29')](_0x3e36d2));_0x593be0(_0x3e36d2);})[_0x1ffb('0x1c')](function(_0x49622d){logger[_0x1ffb('0x18')](_0x1ffb('0x1d'),_0x49622d[_0x1ffb('0x1a')],_0x5335e6);_0x2d2f6e(_0x3cc7f2[_0x1ffb('0x18')](0x1f4,_0x49622d[_0x1ffb('0x1a')]));});});};exports[_0x1ffb('0x2a')]=function(_0x10ff2c){var _0x2a26c4=this;return new Promise(function(_0x54092d,_0x1f2c3d){return db[_0x1ffb('0x1e')][_0x1ffb('0x2b')]({'raw':_0x10ff2c[_0x1ffb('0x20')]?_0x10ff2c[_0x1ffb('0x20')][_0x1ffb('0x21')]===undefined?!![]:![]:!![],'where':_0x10ff2c[_0x1ffb('0x20')]?_0x10ff2c[_0x1ffb('0x20')][_0x1ffb('0x22')]||null:null,'attributes':_0x10ff2c['options']?_0x10ff2c[_0x1ffb('0x20')][_0x1ffb('0x23')]||null:null,'include':_0x10ff2c[_0x1ffb('0x20')]?_0x10ff2c[_0x1ffb('0x20')]['include']?_[_0x1ffb('0x25')](_0x10ff2c[_0x1ffb('0x20')][_0x1ffb('0x24')],function(_0x20fb21){return{'model':db[_0x20fb21[_0x1ffb('0x26')]],'as':_0x20fb21['as'],'attributes':_0x20fb21['attributes'],'include':_0x20fb21[_0x1ffb('0x24')]?_[_0x1ffb('0x25')](_0x20fb21[_0x1ffb('0x24')],function(_0x32307c){return{'model':db[_0x32307c[_0x1ffb('0x26')]],'as':_0x32307c['as'],'attributes':_0x32307c[_0x1ffb('0x23')],'include':_0x32307c[_0x1ffb('0x24')]?_['map'](_0x32307c['include'],function(_0x3d2ca5){return{'model':db[_0x3d2ca5[_0x1ffb('0x26')]],'as':_0x3d2ca5['as'],'attributes':_0x3d2ca5['attributes']};}):[]};}):[]};}):[]:[]})[_0x1ffb('0x27')](function(_0x5f264a){logger['info'](_0x1ffb('0x2a'),_0x10ff2c);logger[_0x1ffb('0x28')](_0x1ffb('0x2a'),_0x10ff2c,JSON['stringify'](_0x5f264a));_0x54092d(_0x5f264a);})[_0x1ffb('0x1c')](function(_0x462ee0){logger['error']('ShowWhatsappQueue',_0x462ee0[_0x1ffb('0x1a')],_0x10ff2c);_0x1f2c3d(_0x2a26c4[_0x1ffb('0x18')](0x1f4,_0x462ee0[_0x1ffb('0x1a')]));});});};