a1c8773be3860e20907e65582b9f2feb1aa0378a
[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 _0x1a1c=['where','limit','include','map','model','attributes','ShowWhatsappQueue','WhatsappQueue','find','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','http','redis','defaults','localhost','socket.io-emitter','./whatsappQueue.socket','register','request','then','info','WhatsappQueue,\x20%s,\x20%s','request\x20sent','debug','WhatsappQueue,\x20%s,\x20%s,\x20%s','stringify','error','message','result','GetWhatsappQueue','findAll','options','raw'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0x1a1c,0xa9));var _0xc1a1=function(_0x17e919,_0xcadd62){_0x17e919=_0x17e919-0x0;var _0x51bf81=_0x1a1c[_0x17e919];return _0x51bf81;};'use strict';var _=require(_0xc1a1('0x0'));var util=require(_0xc1a1('0x1'));var moment=require(_0xc1a1('0x2'));var BPromise=require(_0xc1a1('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xc1a1('0x4'));var db=require(_0xc1a1('0x5'))['db'];var utils=require(_0xc1a1('0x6'));var logger=require(_0xc1a1('0x7'))('rpc');var config=require(_0xc1a1('0x8'));var jayson=require('jayson/promise');var client=jayson['client'][_0xc1a1('0x9')]({'port':0x232a});config[_0xc1a1('0xa')]=_[_0xc1a1('0xb')](config['redis'],{'host':_0xc1a1('0xc'),'port':0x18eb});var socket=require(_0xc1a1('0xd'))(new Redis(config[_0xc1a1('0xa')]));require(_0xc1a1('0xe'))[_0xc1a1('0xf')](socket);function respondWithRpcPromise(_0x53f292,_0x508f46,_0x176066){return new BPromise(function(_0x8676cd,_0x818a07){return client[_0xc1a1('0x10')](_0x53f292,_0x176066)[_0xc1a1('0x11')](function(_0x26ecc7){logger[_0xc1a1('0x12')](_0xc1a1('0x13'),_0x508f46,_0xc1a1('0x14'));logger[_0xc1a1('0x15')](_0xc1a1('0x16'),_0x508f46,_0xc1a1('0x14'),JSON[_0xc1a1('0x17')](_0x26ecc7));if(_0x26ecc7[_0xc1a1('0x18')]){if(_0x26ecc7[_0xc1a1('0x18')]['code']===0x1f4){logger[_0xc1a1('0x18')](_0xc1a1('0x13'),_0x508f46,_0x26ecc7[_0xc1a1('0x18')]['message']);return _0x818a07(_0x26ecc7['error'][_0xc1a1('0x19')]);}logger[_0xc1a1('0x18')]('WhatsappQueue,\x20%s,\x20%s',_0x508f46,_0x26ecc7[_0xc1a1('0x18')]['message']);return _0x8676cd(_0x26ecc7['error'][_0xc1a1('0x19')]);}else{logger['info'](_0xc1a1('0x13'),_0x508f46,_0xc1a1('0x14'));_0x8676cd(_0x26ecc7[_0xc1a1('0x1a')][_0xc1a1('0x19')]);}})['catch'](function(_0x4f53b6){logger[_0xc1a1('0x18')]('WhatsappQueue,\x20%s,\x20%s',_0x508f46,_0x4f53b6);_0x818a07(_0x4f53b6);});});}exports[_0xc1a1('0x1b')]=function(_0x19ec3c){var _0x4b3e6f=this;return new Promise(function(_0x3423ec,_0xb27feb){return db['WhatsappQueue'][_0xc1a1('0x1c')]({'raw':_0x19ec3c['options']?_0x19ec3c[_0xc1a1('0x1d')][_0xc1a1('0x1e')]===undefined?!![]:![]:!![],'where':_0x19ec3c[_0xc1a1('0x1d')]?_0x19ec3c[_0xc1a1('0x1d')][_0xc1a1('0x1f')]||null:null,'attributes':_0x19ec3c[_0xc1a1('0x1d')]?_0x19ec3c[_0xc1a1('0x1d')]['attributes']||null:null,'limit':_0x19ec3c[_0xc1a1('0x1d')]?_0x19ec3c['options'][_0xc1a1('0x20')]||null:null,'include':_0x19ec3c[_0xc1a1('0x1d')]?_0x19ec3c['options'][_0xc1a1('0x21')]?_[_0xc1a1('0x22')](_0x19ec3c[_0xc1a1('0x1d')][_0xc1a1('0x21')],function(_0x28e7f6){return{'model':db[_0x28e7f6[_0xc1a1('0x23')]],'as':_0x28e7f6['as'],'attributes':_0x28e7f6[_0xc1a1('0x24')],'include':_0x28e7f6[_0xc1a1('0x21')]?_['map'](_0x28e7f6[_0xc1a1('0x21')],function(_0x21850b){return{'model':db[_0x21850b[_0xc1a1('0x23')]],'as':_0x21850b['as'],'attributes':_0x21850b['attributes'],'include':_0x21850b['include']?_[_0xc1a1('0x22')](_0x21850b[_0xc1a1('0x21')],function(_0x2643bf){return{'model':db[_0x2643bf[_0xc1a1('0x23')]],'as':_0x2643bf['as'],'attributes':_0x2643bf[_0xc1a1('0x24')]};}):[]};}):[]};}):[]:[]})[_0xc1a1('0x11')](function(_0x36de3d){logger['info']('GetWhatsappQueue',_0x19ec3c);logger[_0xc1a1('0x15')]('GetWhatsappQueue',_0x19ec3c,JSON[_0xc1a1('0x17')](_0x36de3d));_0x3423ec(_0x36de3d);})['catch'](function(_0x69af92){logger['error'](_0xc1a1('0x1b'),_0x69af92[_0xc1a1('0x19')],_0x19ec3c);_0xb27feb(_0x4b3e6f[_0xc1a1('0x18')](0x1f4,_0x69af92[_0xc1a1('0x19')]));});});};exports[_0xc1a1('0x25')]=function(_0x359006){var _0x575147=this;return new Promise(function(_0x45a7dc,_0x2e440d){return db[_0xc1a1('0x26')][_0xc1a1('0x27')]({'raw':_0x359006[_0xc1a1('0x1d')]?_0x359006[_0xc1a1('0x1d')][_0xc1a1('0x1e')]===undefined?!![]:![]:!![],'where':_0x359006[_0xc1a1('0x1d')]?_0x359006[_0xc1a1('0x1d')][_0xc1a1('0x1f')]||null:null,'attributes':_0x359006[_0xc1a1('0x1d')]?_0x359006['options'][_0xc1a1('0x24')]||null:null,'include':_0x359006[_0xc1a1('0x1d')]?_0x359006[_0xc1a1('0x1d')][_0xc1a1('0x21')]?_[_0xc1a1('0x22')](_0x359006[_0xc1a1('0x1d')]['include'],function(_0x1c7889){return{'model':db[_0x1c7889[_0xc1a1('0x23')]],'as':_0x1c7889['as'],'attributes':_0x1c7889['attributes'],'include':_0x1c7889[_0xc1a1('0x21')]?_[_0xc1a1('0x22')](_0x1c7889['include'],function(_0x468ed2){return{'model':db[_0x468ed2['model']],'as':_0x468ed2['as'],'attributes':_0x468ed2[_0xc1a1('0x24')],'include':_0x468ed2[_0xc1a1('0x21')]?_[_0xc1a1('0x22')](_0x468ed2[_0xc1a1('0x21')],function(_0x51b99d){return{'model':db[_0x51b99d['model']],'as':_0x51b99d['as'],'attributes':_0x51b99d[_0xc1a1('0x24')]};}):[]};}):[]};}):[]:[]})[_0xc1a1('0x11')](function(_0x3b86bf){logger[_0xc1a1('0x12')](_0xc1a1('0x25'),_0x359006);logger['debug'](_0xc1a1('0x25'),_0x359006,JSON[_0xc1a1('0x17')](_0x3b86bf));_0x45a7dc(_0x3b86bf);})['catch'](function(_0xc9c12){logger[_0xc1a1('0x18')](_0xc1a1('0x25'),_0xc9c12[_0xc1a1('0x19')],_0x359006);_0x2e440d(_0x575147[_0xc1a1('0x18')](0x1f4,_0xc9c12[_0xc1a1('0x19')]));});});};