a7aad9fc2930c74facb4bee6f58dd1bf89fea033
[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 _0x3f4c=['message','info','result','catch','GetWhatsappQueue','WhatsappQueue','findAll','options','raw','where','attributes','limit','include','model','map','ShowWhatsappQueue','find','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','defaults','socket.io-emitter','redis','./whatsappQueue.socket','register','request','then','WhatsappQueue,\x20%s,\x20%s','request\x20sent','debug','WhatsappQueue,\x20%s,\x20%s,\x20%s','stringify','error','code'];(function(_0x538a45,_0x4b577f){var _0x5e81b0=function(_0x1b8db2){while(--_0x1b8db2){_0x538a45['push'](_0x538a45['shift']());}};_0x5e81b0(++_0x4b577f);}(_0x3f4c,0xe8));var _0xc3f4=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x3f4c[_0x3dd15e];return _0x231fd0;};'use strict';var _=require('lodash');var util=require(_0xc3f4('0x0'));var moment=require(_0xc3f4('0x1'));var BPromise=require(_0xc3f4('0x2'));var rs=require(_0xc3f4('0x3'));var fs=require('fs');var Redis=require(_0xc3f4('0x4'));var db=require(_0xc3f4('0x5'))['db'];var utils=require(_0xc3f4('0x6'));var logger=require(_0xc3f4('0x7'))(_0xc3f4('0x8'));var config=require('../../config/environment');var jayson=require(_0xc3f4('0x9'));var client=jayson[_0xc3f4('0xa')][_0xc3f4('0xb')]({'port':0x232a});config['redis']=_[_0xc3f4('0xc')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0xc3f4('0xd'))(new Redis(config[_0xc3f4('0xe')]));require(_0xc3f4('0xf'))[_0xc3f4('0x10')](socket);function respondWithRpcPromise(_0x1f69ae,_0x2147f8,_0x21a643){return new BPromise(function(_0x8b139d,_0x5f393b){return client[_0xc3f4('0x11')](_0x1f69ae,_0x21a643)[_0xc3f4('0x12')](function(_0x545fd7){logger['info'](_0xc3f4('0x13'),_0x2147f8,_0xc3f4('0x14'));logger[_0xc3f4('0x15')](_0xc3f4('0x16'),_0x2147f8,_0xc3f4('0x14'),JSON[_0xc3f4('0x17')](_0x545fd7));if(_0x545fd7[_0xc3f4('0x18')]){if(_0x545fd7['error'][_0xc3f4('0x19')]===0x1f4){logger['error'](_0xc3f4('0x13'),_0x2147f8,_0x545fd7['error']['message']);return _0x5f393b(_0x545fd7[_0xc3f4('0x18')][_0xc3f4('0x1a')]);}logger[_0xc3f4('0x18')](_0xc3f4('0x13'),_0x2147f8,_0x545fd7[_0xc3f4('0x18')][_0xc3f4('0x1a')]);return _0x8b139d(_0x545fd7[_0xc3f4('0x18')][_0xc3f4('0x1a')]);}else{logger[_0xc3f4('0x1b')]('WhatsappQueue,\x20%s,\x20%s',_0x2147f8,_0xc3f4('0x14'));_0x8b139d(_0x545fd7[_0xc3f4('0x1c')][_0xc3f4('0x1a')]);}})[_0xc3f4('0x1d')](function(_0x2c6bb1){logger[_0xc3f4('0x18')]('WhatsappQueue,\x20%s,\x20%s',_0x2147f8,_0x2c6bb1);_0x5f393b(_0x2c6bb1);});});}exports[_0xc3f4('0x1e')]=function(_0x220a02){var _0x27c69f=this;return new Promise(function(_0x5c59c5,_0x5be264){return db[_0xc3f4('0x1f')][_0xc3f4('0x20')]({'raw':_0x220a02[_0xc3f4('0x21')]?_0x220a02[_0xc3f4('0x21')][_0xc3f4('0x22')]===undefined?!![]:![]:!![],'where':_0x220a02['options']?_0x220a02[_0xc3f4('0x21')][_0xc3f4('0x23')]||null:null,'attributes':_0x220a02[_0xc3f4('0x21')]?_0x220a02[_0xc3f4('0x21')][_0xc3f4('0x24')]||null:null,'limit':_0x220a02[_0xc3f4('0x21')]?_0x220a02[_0xc3f4('0x21')][_0xc3f4('0x25')]||null:null,'include':_0x220a02[_0xc3f4('0x21')]?_0x220a02['options']['include']?_['map'](_0x220a02[_0xc3f4('0x21')][_0xc3f4('0x26')],function(_0x36de8a){return{'model':db[_0x36de8a[_0xc3f4('0x27')]],'as':_0x36de8a['as'],'attributes':_0x36de8a[_0xc3f4('0x24')],'include':_0x36de8a[_0xc3f4('0x26')]?_[_0xc3f4('0x28')](_0x36de8a['include'],function(_0x15335e){return{'model':db[_0x15335e[_0xc3f4('0x27')]],'as':_0x15335e['as'],'attributes':_0x15335e['attributes'],'include':_0x15335e[_0xc3f4('0x26')]?_[_0xc3f4('0x28')](_0x15335e[_0xc3f4('0x26')],function(_0x19cf37){return{'model':db[_0x19cf37[_0xc3f4('0x27')]],'as':_0x19cf37['as'],'attributes':_0x19cf37['attributes']};}):[]};}):[]};}):[]:[]})[_0xc3f4('0x12')](function(_0x4a620b){logger['info'](_0xc3f4('0x1e'),_0x220a02);logger[_0xc3f4('0x15')](_0xc3f4('0x1e'),_0x220a02,JSON[_0xc3f4('0x17')](_0x4a620b));_0x5c59c5(_0x4a620b);})[_0xc3f4('0x1d')](function(_0x126bd1){logger['error'](_0xc3f4('0x1e'),_0x126bd1['message'],_0x220a02);_0x5be264(_0x27c69f[_0xc3f4('0x18')](0x1f4,_0x126bd1[_0xc3f4('0x1a')]));});});};exports[_0xc3f4('0x29')]=function(_0x30ec34){var _0x199375=this;return new Promise(function(_0x2f0aff,_0x2770a0){return db[_0xc3f4('0x1f')][_0xc3f4('0x2a')]({'raw':_0x30ec34[_0xc3f4('0x21')]?_0x30ec34[_0xc3f4('0x21')]['raw']===undefined?!![]:![]:!![],'where':_0x30ec34['options']?_0x30ec34[_0xc3f4('0x21')][_0xc3f4('0x23')]||null:null,'attributes':_0x30ec34['options']?_0x30ec34['options'][_0xc3f4('0x24')]||null:null,'include':_0x30ec34[_0xc3f4('0x21')]?_0x30ec34[_0xc3f4('0x21')][_0xc3f4('0x26')]?_[_0xc3f4('0x28')](_0x30ec34['options'][_0xc3f4('0x26')],function(_0x135ae7){return{'model':db[_0x135ae7[_0xc3f4('0x27')]],'as':_0x135ae7['as'],'attributes':_0x135ae7['attributes'],'include':_0x135ae7[_0xc3f4('0x26')]?_[_0xc3f4('0x28')](_0x135ae7[_0xc3f4('0x26')],function(_0x33c7e5){return{'model':db[_0x33c7e5['model']],'as':_0x33c7e5['as'],'attributes':_0x33c7e5[_0xc3f4('0x24')],'include':_0x33c7e5[_0xc3f4('0x26')]?_['map'](_0x33c7e5[_0xc3f4('0x26')],function(_0x134662){return{'model':db[_0x134662[_0xc3f4('0x27')]],'as':_0x134662['as'],'attributes':_0x134662[_0xc3f4('0x24')]};}):[]};}):[]};}):[]:[]})[_0xc3f4('0x12')](function(_0x176310){logger[_0xc3f4('0x1b')](_0xc3f4('0x29'),_0x30ec34);logger[_0xc3f4('0x15')]('ShowWhatsappQueue',_0x30ec34,JSON[_0xc3f4('0x17')](_0x176310));_0x2f0aff(_0x176310);})[_0xc3f4('0x1d')](function(_0xf77a3d){logger[_0xc3f4('0x18')](_0xc3f4('0x29'),_0xf77a3d[_0xc3f4('0x1a')],_0x30ec34);_0x2770a0(_0x199375['error'](0x1f4,_0xf77a3d[_0xc3f4('0x1a')]));});});};