Built motion from commit 616d3211.|2.6.4
[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 _0xbbdb=['stringify','find','where','ShowWhatsappQueue','lodash','util','bluebird','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','redis','socket.io-emitter','./whatsappQueue.socket','register','request','then','info','WhatsappQueue,\x20%s,\x20%s','debug','WhatsappQueue,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','message','result','catch','WhatsappQueue','options','raw','attributes','limit','include','map','model','GetWhatsappQueue'];(function(_0x531301,_0x3509f2){var _0x46e668=function(_0x272a6c){while(--_0x272a6c){_0x531301['push'](_0x531301['shift']());}};_0x46e668(++_0x3509f2);}(_0xbbdb,0x79));var _0xbbbd=function(_0x5774be,_0x2259d3){_0x5774be=_0x5774be-0x0;var _0x4914b4=_0xbbdb[_0x5774be];return _0x4914b4;};'use strict';var _=require(_0xbbbd('0x0'));var util=require(_0xbbbd('0x1'));var moment=require('moment');var BPromise=require(_0xbbbd('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xbbbd('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0xbbbd('0x4'));var logger=require(_0xbbbd('0x5'))(_0xbbbd('0x6'));var config=require(_0xbbbd('0x7'));var jayson=require(_0xbbbd('0x8'));var client=jayson[_0xbbbd('0x9')]['http']({'port':0x232a});config[_0xbbbd('0xa')]=_['defaults'](config[_0xbbbd('0xa')],{'host':'localhost','port':0x18eb});var socket=require(_0xbbbd('0xb'))(new Redis(config[_0xbbbd('0xa')]));require(_0xbbbd('0xc'))[_0xbbbd('0xd')](socket);function respondWithRpcPromise(_0x4eed51,_0x4a4e78,_0x488465){return new BPromise(function(_0x1b8609,_0x83b449){return client[_0xbbbd('0xe')](_0x4eed51,_0x488465)[_0xbbbd('0xf')](function(_0x4c312f){logger[_0xbbbd('0x10')](_0xbbbd('0x11'),_0x4a4e78,'request\x20sent');logger[_0xbbbd('0x12')](_0xbbbd('0x13'),_0x4a4e78,_0xbbbd('0x14'),JSON['stringify'](_0x4c312f));if(_0x4c312f[_0xbbbd('0x15')]){if(_0x4c312f[_0xbbbd('0x15')][_0xbbbd('0x16')]===0x1f4){logger[_0xbbbd('0x15')]('WhatsappQueue,\x20%s,\x20%s',_0x4a4e78,_0x4c312f[_0xbbbd('0x15')]['message']);return _0x83b449(_0x4c312f[_0xbbbd('0x15')][_0xbbbd('0x17')]);}logger['error']('WhatsappQueue,\x20%s,\x20%s',_0x4a4e78,_0x4c312f['error'][_0xbbbd('0x17')]);return _0x1b8609(_0x4c312f['error'][_0xbbbd('0x17')]);}else{logger[_0xbbbd('0x10')](_0xbbbd('0x11'),_0x4a4e78,_0xbbbd('0x14'));_0x1b8609(_0x4c312f[_0xbbbd('0x18')][_0xbbbd('0x17')]);}})[_0xbbbd('0x19')](function(_0x4a1428){logger[_0xbbbd('0x15')](_0xbbbd('0x11'),_0x4a4e78,_0x4a1428);_0x83b449(_0x4a1428);});});}exports['GetWhatsappQueue']=function(_0x52a3ed){var _0x58a6c8=this;return new Promise(function(_0x48b5a5,_0x60a590){return db[_0xbbbd('0x1a')]['findAll']({'raw':_0x52a3ed[_0xbbbd('0x1b')]?_0x52a3ed[_0xbbbd('0x1b')][_0xbbbd('0x1c')]===undefined?!![]:![]:!![],'where':_0x52a3ed['options']?_0x52a3ed['options']['where']||null:null,'attributes':_0x52a3ed['options']?_0x52a3ed[_0xbbbd('0x1b')][_0xbbbd('0x1d')]||null:null,'limit':_0x52a3ed[_0xbbbd('0x1b')]?_0x52a3ed[_0xbbbd('0x1b')][_0xbbbd('0x1e')]||null:null,'include':_0x52a3ed['options']?_0x52a3ed[_0xbbbd('0x1b')][_0xbbbd('0x1f')]?_[_0xbbbd('0x20')](_0x52a3ed[_0xbbbd('0x1b')][_0xbbbd('0x1f')],function(_0x4bd728){return{'model':db[_0x4bd728[_0xbbbd('0x21')]],'as':_0x4bd728['as'],'attributes':_0x4bd728[_0xbbbd('0x1d')],'include':_0x4bd728['include']?_[_0xbbbd('0x20')](_0x4bd728[_0xbbbd('0x1f')],function(_0x548d46){return{'model':db[_0x548d46[_0xbbbd('0x21')]],'as':_0x548d46['as'],'attributes':_0x548d46[_0xbbbd('0x1d')],'include':_0x548d46['include']?_[_0xbbbd('0x20')](_0x548d46[_0xbbbd('0x1f')],function(_0x5b9066){return{'model':db[_0x5b9066[_0xbbbd('0x21')]],'as':_0x5b9066['as'],'attributes':_0x5b9066[_0xbbbd('0x1d')]};}):[]};}):[]};}):[]:[]})[_0xbbbd('0xf')](function(_0x51f19a){logger[_0xbbbd('0x10')](_0xbbbd('0x22'),_0x52a3ed);logger[_0xbbbd('0x12')](_0xbbbd('0x22'),_0x52a3ed,JSON[_0xbbbd('0x23')](_0x51f19a));_0x48b5a5(_0x51f19a);})[_0xbbbd('0x19')](function(_0x5b9692){logger[_0xbbbd('0x15')](_0xbbbd('0x22'),_0x5b9692[_0xbbbd('0x17')],_0x52a3ed);_0x60a590(_0x58a6c8[_0xbbbd('0x15')](0x1f4,_0x5b9692[_0xbbbd('0x17')]));});});};exports['ShowWhatsappQueue']=function(_0x50cf26){var _0x593e6f=this;return new Promise(function(_0x5d9ebf,_0x92fa5b){return db['WhatsappQueue'][_0xbbbd('0x24')]({'raw':_0x50cf26['options']?_0x50cf26[_0xbbbd('0x1b')][_0xbbbd('0x1c')]===undefined?!![]:![]:!![],'where':_0x50cf26[_0xbbbd('0x1b')]?_0x50cf26[_0xbbbd('0x1b')][_0xbbbd('0x25')]||null:null,'attributes':_0x50cf26['options']?_0x50cf26[_0xbbbd('0x1b')]['attributes']||null:null,'include':_0x50cf26[_0xbbbd('0x1b')]?_0x50cf26[_0xbbbd('0x1b')]['include']?_[_0xbbbd('0x20')](_0x50cf26[_0xbbbd('0x1b')][_0xbbbd('0x1f')],function(_0x1bdea7){return{'model':db[_0x1bdea7[_0xbbbd('0x21')]],'as':_0x1bdea7['as'],'attributes':_0x1bdea7[_0xbbbd('0x1d')],'include':_0x1bdea7['include']?_[_0xbbbd('0x20')](_0x1bdea7[_0xbbbd('0x1f')],function(_0x5cf4af){return{'model':db[_0x5cf4af[_0xbbbd('0x21')]],'as':_0x5cf4af['as'],'attributes':_0x5cf4af[_0xbbbd('0x1d')],'include':_0x5cf4af[_0xbbbd('0x1f')]?_['map'](_0x5cf4af[_0xbbbd('0x1f')],function(_0x5f20f4){return{'model':db[_0x5f20f4[_0xbbbd('0x21')]],'as':_0x5f20f4['as'],'attributes':_0x5f20f4[_0xbbbd('0x1d')]};}):[]};}):[]};}):[]:[]})[_0xbbbd('0xf')](function(_0x5120f1){logger[_0xbbbd('0x10')]('ShowWhatsappQueue',_0x50cf26);logger[_0xbbbd('0x12')]('ShowWhatsappQueue',_0x50cf26,JSON[_0xbbbd('0x23')](_0x5120f1));_0x5d9ebf(_0x5120f1);})[_0xbbbd('0x19')](function(_0x4dd4cc){logger['error'](_0xbbbd('0x26'),_0x4dd4cc['message'],_0x50cf26);_0x92fa5b(_0x593e6f[_0xbbbd('0x15')](0x1f4,_0x4dd4cc[_0xbbbd('0x17')]));});});};