c4ec98d326819b6581d742bd091c5d9bb68786cf
[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 _0x793f=['WhatsappQueue,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','GetWhatsappQueue','WhatsappQueue','options','raw','where','attributes','limit','include','map','model','debug','stringify','find','ShowWhatsappQueue','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','socket.io-emitter','./whatsappQueue.socket','register','request','then','info','WhatsappQueue,\x20%s,\x20%s','request\x20sent'];(function(_0x5e3dd6,_0x57c85f){var _0x51a2a2=function(_0x1fbf8e){while(--_0x1fbf8e){_0x5e3dd6['push'](_0x5e3dd6['shift']());}};_0x51a2a2(++_0x57c85f);}(_0x793f,0xeb));var _0xf793=function(_0x3c00cc,_0x4b0ddb){_0x3c00cc=_0x3c00cc-0x0;var _0x45e86e=_0x793f[_0x3c00cc];return _0x45e86e;};'use strict';var _=require(_0xf793('0x0'));var util=require('util');var moment=require(_0xf793('0x1'));var BPromise=require(_0xf793('0x2'));var rs=require(_0xf793('0x3'));var fs=require('fs');var Redis=require(_0xf793('0x4'));var db=require(_0xf793('0x5'))['db'];var utils=require(_0xf793('0x6'));var logger=require(_0xf793('0x7'))(_0xf793('0x8'));var config=require(_0xf793('0x9'));var jayson=require(_0xf793('0xa'));var client=jayson[_0xf793('0xb')][_0xf793('0xc')]({'port':0x232a});config[_0xf793('0xd')]=_[_0xf793('0xe')](config[_0xf793('0xd')],{'host':'localhost','port':0x18eb});var socket=require(_0xf793('0xf'))(new Redis(config[_0xf793('0xd')]));require(_0xf793('0x10'))[_0xf793('0x11')](socket);function respondWithRpcPromise(_0x4286ad,_0x1c0493,_0x43824c){return new BPromise(function(_0x18b330,_0x349686){return client[_0xf793('0x12')](_0x4286ad,_0x43824c)[_0xf793('0x13')](function(_0xe76899){logger[_0xf793('0x14')](_0xf793('0x15'),_0x1c0493,_0xf793('0x16'));logger['debug'](_0xf793('0x17'),_0x1c0493,_0xf793('0x16'),JSON['stringify'](_0xe76899));if(_0xe76899['error']){if(_0xe76899[_0xf793('0x18')][_0xf793('0x19')]===0x1f4){logger[_0xf793('0x18')]('WhatsappQueue,\x20%s,\x20%s',_0x1c0493,_0xe76899[_0xf793('0x18')][_0xf793('0x1a')]);return _0x349686(_0xe76899[_0xf793('0x18')][_0xf793('0x1a')]);}logger[_0xf793('0x18')](_0xf793('0x15'),_0x1c0493,_0xe76899['error'][_0xf793('0x1a')]);return _0x18b330(_0xe76899['error'][_0xf793('0x1a')]);}else{logger['info'](_0xf793('0x15'),_0x1c0493,_0xf793('0x16'));_0x18b330(_0xe76899[_0xf793('0x1b')][_0xf793('0x1a')]);}})[_0xf793('0x1c')](function(_0x2cb107){logger[_0xf793('0x18')](_0xf793('0x15'),_0x1c0493,_0x2cb107);_0x349686(_0x2cb107);});});}exports[_0xf793('0x1d')]=function(_0x342374){var _0x59fa83=this;return new Promise(function(_0x1ad641,_0x331d74){return db[_0xf793('0x1e')]['findAll']({'raw':_0x342374[_0xf793('0x1f')]?_0x342374[_0xf793('0x1f')][_0xf793('0x20')]===undefined?!![]:![]:!![],'where':_0x342374[_0xf793('0x1f')]?_0x342374[_0xf793('0x1f')][_0xf793('0x21')]||null:null,'attributes':_0x342374[_0xf793('0x1f')]?_0x342374['options'][_0xf793('0x22')]||null:null,'limit':_0x342374[_0xf793('0x1f')]?_0x342374[_0xf793('0x1f')][_0xf793('0x23')]||null:null,'include':_0x342374[_0xf793('0x1f')]?_0x342374[_0xf793('0x1f')][_0xf793('0x24')]?_[_0xf793('0x25')](_0x342374[_0xf793('0x1f')][_0xf793('0x24')],function(_0x23ef10){return{'model':db[_0x23ef10[_0xf793('0x26')]],'as':_0x23ef10['as'],'attributes':_0x23ef10['attributes'],'include':_0x23ef10[_0xf793('0x24')]?_[_0xf793('0x25')](_0x23ef10[_0xf793('0x24')],function(_0x4e4b4a){return{'model':db[_0x4e4b4a[_0xf793('0x26')]],'as':_0x4e4b4a['as'],'attributes':_0x4e4b4a['attributes'],'include':_0x4e4b4a['include']?_[_0xf793('0x25')](_0x4e4b4a[_0xf793('0x24')],function(_0x207ee4){return{'model':db[_0x207ee4[_0xf793('0x26')]],'as':_0x207ee4['as'],'attributes':_0x207ee4[_0xf793('0x22')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x138ba4){logger['info'](_0xf793('0x1d'),_0x342374);logger[_0xf793('0x27')]('GetWhatsappQueue',_0x342374,JSON[_0xf793('0x28')](_0x138ba4));_0x1ad641(_0x138ba4);})[_0xf793('0x1c')](function(_0x3e6e44){logger['error'](_0xf793('0x1d'),_0x3e6e44[_0xf793('0x1a')],_0x342374);_0x331d74(_0x59fa83[_0xf793('0x18')](0x1f4,_0x3e6e44[_0xf793('0x1a')]));});});};exports['ShowWhatsappQueue']=function(_0x2576ac){var _0x5b00d5=this;return new Promise(function(_0x2e4215,_0x5d0ab3){return db[_0xf793('0x1e')][_0xf793('0x29')]({'raw':_0x2576ac[_0xf793('0x1f')]?_0x2576ac[_0xf793('0x1f')][_0xf793('0x20')]===undefined?!![]:![]:!![],'where':_0x2576ac[_0xf793('0x1f')]?_0x2576ac['options'][_0xf793('0x21')]||null:null,'attributes':_0x2576ac['options']?_0x2576ac[_0xf793('0x1f')][_0xf793('0x22')]||null:null,'include':_0x2576ac[_0xf793('0x1f')]?_0x2576ac[_0xf793('0x1f')][_0xf793('0x24')]?_[_0xf793('0x25')](_0x2576ac[_0xf793('0x1f')][_0xf793('0x24')],function(_0x552f03){return{'model':db[_0x552f03[_0xf793('0x26')]],'as':_0x552f03['as'],'attributes':_0x552f03[_0xf793('0x22')],'include':_0x552f03[_0xf793('0x24')]?_[_0xf793('0x25')](_0x552f03[_0xf793('0x24')],function(_0x205cc0){return{'model':db[_0x205cc0[_0xf793('0x26')]],'as':_0x205cc0['as'],'attributes':_0x205cc0[_0xf793('0x22')],'include':_0x205cc0['include']?_[_0xf793('0x25')](_0x205cc0[_0xf793('0x24')],function(_0x45d9fa){return{'model':db[_0x45d9fa[_0xf793('0x26')]],'as':_0x45d9fa['as'],'attributes':_0x45d9fa['attributes']};}):[]};}):[]};}):[]:[]})[_0xf793('0x13')](function(_0x468cae){logger[_0xf793('0x14')](_0xf793('0x2a'),_0x2576ac);logger[_0xf793('0x27')]('ShowWhatsappQueue',_0x2576ac,JSON[_0xf793('0x28')](_0x468cae));_0x2e4215(_0x468cae);})['catch'](function(_0x52de12){logger['error']('ShowWhatsappQueue',_0x52de12[_0xf793('0x1a')],_0x2576ac);_0x5d0ab3(_0x5b00d5['error'](0x1f4,_0x52de12[_0xf793('0x1a')]));});});};