dcdff14e583bb059689080f1b0acfae2972bc4c5
[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 _0x1589=['then','info','WhatsappQueue,\x20%s,\x20%s','debug','WhatsappQueue,\x20%s,\x20%s,\x20%s','request\x20sent','error','message','options','raw','attributes','limit','map','include','model','GetWhatsappQueue','WhatsappQueue','find','ShowWhatsappQueue','stringify','catch','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','redis','defaults','localhost','socket.io-emitter','./whatsappQueue.socket','register','request'];(function(_0x4824db,_0x2b934f){var _0x467e8f=function(_0x36b4ea){while(--_0x36b4ea){_0x4824db['push'](_0x4824db['shift']());}};_0x467e8f(++_0x2b934f);}(_0x1589,0xdd));var _0x9158=function(_0xc8a931,_0x260690){_0xc8a931=_0xc8a931-0x0;var _0x28bd27=_0x1589[_0xc8a931];return _0x28bd27;};'use strict';var _=require(_0x9158('0x0'));var util=require('util');var moment=require(_0x9158('0x1'));var BPromise=require(_0x9158('0x2'));var rs=require(_0x9158('0x3'));var fs=require('fs');var Redis=require(_0x9158('0x4'));var db=require(_0x9158('0x5'))['db'];var utils=require(_0x9158('0x6'));var logger=require(_0x9158('0x7'))(_0x9158('0x8'));var config=require(_0x9158('0x9'));var jayson=require(_0x9158('0xa'));var client=jayson[_0x9158('0xb')]['http']({'port':0x232a});config[_0x9158('0xc')]=_[_0x9158('0xd')](config[_0x9158('0xc')],{'host':_0x9158('0xe'),'port':0x18eb});var socket=require(_0x9158('0xf'))(new Redis(config[_0x9158('0xc')]));require(_0x9158('0x10'))[_0x9158('0x11')](socket);function respondWithRpcPromise(_0x13a8cf,_0x53e855,_0x147d40){return new BPromise(function(_0x4ebff0,_0x4c533f){return client[_0x9158('0x12')](_0x13a8cf,_0x147d40)[_0x9158('0x13')](function(_0x12804a){logger[_0x9158('0x14')](_0x9158('0x15'),_0x53e855,'request\x20sent');logger[_0x9158('0x16')](_0x9158('0x17'),_0x53e855,_0x9158('0x18'),JSON['stringify'](_0x12804a));if(_0x12804a[_0x9158('0x19')]){if(_0x12804a[_0x9158('0x19')]['code']===0x1f4){logger[_0x9158('0x19')](_0x9158('0x15'),_0x53e855,_0x12804a[_0x9158('0x19')][_0x9158('0x1a')]);return _0x4c533f(_0x12804a[_0x9158('0x19')][_0x9158('0x1a')]);}logger['error'](_0x9158('0x15'),_0x53e855,_0x12804a[_0x9158('0x19')][_0x9158('0x1a')]);return _0x4ebff0(_0x12804a[_0x9158('0x19')]['message']);}else{logger['info'](_0x9158('0x15'),_0x53e855,_0x9158('0x18'));_0x4ebff0(_0x12804a['result'][_0x9158('0x1a')]);}})['catch'](function(_0x1d2df3){logger[_0x9158('0x19')]('WhatsappQueue,\x20%s,\x20%s',_0x53e855,_0x1d2df3);_0x4c533f(_0x1d2df3);});});}exports['GetWhatsappQueue']=function(_0xc9b6d2){var _0x2952d8=this;return new Promise(function(_0x5046a8,_0x22e437){return db['WhatsappQueue']['findAll']({'raw':_0xc9b6d2[_0x9158('0x1b')]?_0xc9b6d2[_0x9158('0x1b')][_0x9158('0x1c')]===undefined?!![]:![]:!![],'where':_0xc9b6d2['options']?_0xc9b6d2[_0x9158('0x1b')]['where']||null:null,'attributes':_0xc9b6d2[_0x9158('0x1b')]?_0xc9b6d2[_0x9158('0x1b')][_0x9158('0x1d')]||null:null,'limit':_0xc9b6d2[_0x9158('0x1b')]?_0xc9b6d2['options'][_0x9158('0x1e')]||null:null,'include':_0xc9b6d2[_0x9158('0x1b')]?_0xc9b6d2[_0x9158('0x1b')]['include']?_[_0x9158('0x1f')](_0xc9b6d2[_0x9158('0x1b')][_0x9158('0x20')],function(_0x1ebf7f){return{'model':db[_0x1ebf7f['model']],'as':_0x1ebf7f['as'],'attributes':_0x1ebf7f[_0x9158('0x1d')],'include':_0x1ebf7f[_0x9158('0x20')]?_[_0x9158('0x1f')](_0x1ebf7f[_0x9158('0x20')],function(_0xb1a1e3){return{'model':db[_0xb1a1e3[_0x9158('0x21')]],'as':_0xb1a1e3['as'],'attributes':_0xb1a1e3[_0x9158('0x1d')],'include':_0xb1a1e3[_0x9158('0x20')]?_[_0x9158('0x1f')](_0xb1a1e3[_0x9158('0x20')],function(_0x34d66d){return{'model':db[_0x34d66d[_0x9158('0x21')]],'as':_0x34d66d['as'],'attributes':_0x34d66d['attributes']};}):[]};}):[]};}):[]:[]})[_0x9158('0x13')](function(_0xc752d1){logger[_0x9158('0x14')](_0x9158('0x22'),_0xc9b6d2);logger[_0x9158('0x16')](_0x9158('0x22'),_0xc9b6d2,JSON['stringify'](_0xc752d1));_0x5046a8(_0xc752d1);})['catch'](function(_0x197bb7){logger['error']('GetWhatsappQueue',_0x197bb7[_0x9158('0x1a')],_0xc9b6d2);_0x22e437(_0x2952d8[_0x9158('0x19')](0x1f4,_0x197bb7[_0x9158('0x1a')]));});});};exports['ShowWhatsappQueue']=function(_0x52be35){var _0x484067=this;return new Promise(function(_0x5913cb,_0x448c79){return db[_0x9158('0x23')][_0x9158('0x24')]({'raw':_0x52be35['options']?_0x52be35[_0x9158('0x1b')]['raw']===undefined?!![]:![]:!![],'where':_0x52be35['options']?_0x52be35['options']['where']||null:null,'attributes':_0x52be35[_0x9158('0x1b')]?_0x52be35[_0x9158('0x1b')][_0x9158('0x1d')]||null:null,'include':_0x52be35[_0x9158('0x1b')]?_0x52be35[_0x9158('0x1b')]['include']?_[_0x9158('0x1f')](_0x52be35[_0x9158('0x1b')][_0x9158('0x20')],function(_0x3faba9){return{'model':db[_0x3faba9[_0x9158('0x21')]],'as':_0x3faba9['as'],'attributes':_0x3faba9[_0x9158('0x1d')],'include':_0x3faba9[_0x9158('0x20')]?_[_0x9158('0x1f')](_0x3faba9[_0x9158('0x20')],function(_0x5af6f9){return{'model':db[_0x5af6f9['model']],'as':_0x5af6f9['as'],'attributes':_0x5af6f9[_0x9158('0x1d')],'include':_0x5af6f9['include']?_[_0x9158('0x1f')](_0x5af6f9['include'],function(_0x81faeb){return{'model':db[_0x81faeb[_0x9158('0x21')]],'as':_0x81faeb['as'],'attributes':_0x81faeb['attributes']};}):[]};}):[]};}):[]:[]})[_0x9158('0x13')](function(_0x5f0213){logger[_0x9158('0x14')](_0x9158('0x25'),_0x52be35);logger[_0x9158('0x16')]('ShowWhatsappQueue',_0x52be35,JSON[_0x9158('0x26')](_0x5f0213));_0x5913cb(_0x5f0213);})[_0x9158('0x27')](function(_0x4adc78){logger[_0x9158('0x19')](_0x9158('0x25'),_0x4adc78[_0x9158('0x1a')],_0x52be35);_0x448c79(_0x484067['error'](0x1f4,_0x4adc78['message']));});});};