Built motion from commit 00bf23f6.|2.6.16
[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 _0x377c=['debug','WhatsappQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetWhatsappQueue','findAll','options','attributes','limit','include','model','map','ShowWhatsappQueue','WhatsappQueue','find','where','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./whatsappQueue.socket','register','request','then','info','WhatsappQueue,\x20%s,\x20%s','request\x20sent'];(function(_0xdd2bfa,_0x5bd304){var _0x55397e=function(_0x196f7d){while(--_0x196f7d){_0xdd2bfa['push'](_0xdd2bfa['shift']());}};_0x55397e(++_0x5bd304);}(_0x377c,0x98));var _0xc377=function(_0x471196,_0x4fdcea){_0x471196=_0x471196-0x0;var _0x3971c0=_0x377c[_0x471196];return _0x3971c0;};'use strict';var _=require(_0xc377('0x0'));var util=require(_0xc377('0x1'));var moment=require(_0xc377('0x2'));var BPromise=require(_0xc377('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xc377('0x4'));var db=require(_0xc377('0x5'))['db'];var utils=require(_0xc377('0x6'));var logger=require(_0xc377('0x7'))(_0xc377('0x8'));var config=require(_0xc377('0x9'));var jayson=require(_0xc377('0xa'));var client=jayson[_0xc377('0xb')][_0xc377('0xc')]({'port':0x232a});config[_0xc377('0xd')]=_[_0xc377('0xe')](config[_0xc377('0xd')],{'host':_0xc377('0xf'),'port':0x18eb});var socket=require(_0xc377('0x10'))(new Redis(config[_0xc377('0xd')]));require(_0xc377('0x11'))[_0xc377('0x12')](socket);function respondWithRpcPromise(_0x3138ee,_0x433bf1,_0x765025){return new BPromise(function(_0xb11faf,_0x324560){return client[_0xc377('0x13')](_0x3138ee,_0x765025)[_0xc377('0x14')](function(_0x3fcbd3){logger[_0xc377('0x15')](_0xc377('0x16'),_0x433bf1,_0xc377('0x17'));logger[_0xc377('0x18')](_0xc377('0x19'),_0x433bf1,_0xc377('0x17'),JSON[_0xc377('0x1a')](_0x3fcbd3));if(_0x3fcbd3[_0xc377('0x1b')]){if(_0x3fcbd3[_0xc377('0x1b')][_0xc377('0x1c')]===0x1f4){logger[_0xc377('0x1b')](_0xc377('0x16'),_0x433bf1,_0x3fcbd3[_0xc377('0x1b')][_0xc377('0x1d')]);return _0x324560(_0x3fcbd3[_0xc377('0x1b')][_0xc377('0x1d')]);}logger['error']('WhatsappQueue,\x20%s,\x20%s',_0x433bf1,_0x3fcbd3['error'][_0xc377('0x1d')]);return _0xb11faf(_0x3fcbd3[_0xc377('0x1b')][_0xc377('0x1d')]);}else{logger[_0xc377('0x15')](_0xc377('0x16'),_0x433bf1,_0xc377('0x17'));_0xb11faf(_0x3fcbd3[_0xc377('0x1e')][_0xc377('0x1d')]);}})[_0xc377('0x1f')](function(_0x48fb36){logger['error']('WhatsappQueue,\x20%s,\x20%s',_0x433bf1,_0x48fb36);_0x324560(_0x48fb36);});});}exports[_0xc377('0x20')]=function(_0x469b18){var _0x4f70b6=this;return new Promise(function(_0x1648ac,_0x28fd29){return db['WhatsappQueue'][_0xc377('0x21')]({'raw':_0x469b18[_0xc377('0x22')]?_0x469b18[_0xc377('0x22')]['raw']===undefined?!![]:![]:!![],'where':_0x469b18[_0xc377('0x22')]?_0x469b18[_0xc377('0x22')]['where']||null:null,'attributes':_0x469b18['options']?_0x469b18[_0xc377('0x22')][_0xc377('0x23')]||null:null,'limit':_0x469b18['options']?_0x469b18[_0xc377('0x22')][_0xc377('0x24')]||null:null,'include':_0x469b18[_0xc377('0x22')]?_0x469b18[_0xc377('0x22')][_0xc377('0x25')]?_['map'](_0x469b18[_0xc377('0x22')][_0xc377('0x25')],function(_0x34dfee){return{'model':db[_0x34dfee[_0xc377('0x26')]],'as':_0x34dfee['as'],'attributes':_0x34dfee['attributes'],'include':_0x34dfee[_0xc377('0x25')]?_[_0xc377('0x27')](_0x34dfee[_0xc377('0x25')],function(_0x2699f4){return{'model':db[_0x2699f4['model']],'as':_0x2699f4['as'],'attributes':_0x2699f4[_0xc377('0x23')],'include':_0x2699f4['include']?_[_0xc377('0x27')](_0x2699f4[_0xc377('0x25')],function(_0x1b9d73){return{'model':db[_0x1b9d73[_0xc377('0x26')]],'as':_0x1b9d73['as'],'attributes':_0x1b9d73[_0xc377('0x23')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x539285){logger[_0xc377('0x15')](_0xc377('0x20'),_0x469b18);logger[_0xc377('0x18')]('GetWhatsappQueue',_0x469b18,JSON[_0xc377('0x1a')](_0x539285));_0x1648ac(_0x539285);})[_0xc377('0x1f')](function(_0xdb997c){logger[_0xc377('0x1b')](_0xc377('0x20'),_0xdb997c[_0xc377('0x1d')],_0x469b18);_0x28fd29(_0x4f70b6[_0xc377('0x1b')](0x1f4,_0xdb997c[_0xc377('0x1d')]));});});};exports[_0xc377('0x28')]=function(_0x43f402){var _0x114d66=this;return new Promise(function(_0x15b7df,_0x228f68){return db[_0xc377('0x29')][_0xc377('0x2a')]({'raw':_0x43f402[_0xc377('0x22')]?_0x43f402[_0xc377('0x22')]['raw']===undefined?!![]:![]:!![],'where':_0x43f402['options']?_0x43f402[_0xc377('0x22')][_0xc377('0x2b')]||null:null,'attributes':_0x43f402['options']?_0x43f402[_0xc377('0x22')][_0xc377('0x23')]||null:null,'include':_0x43f402[_0xc377('0x22')]?_0x43f402[_0xc377('0x22')][_0xc377('0x25')]?_[_0xc377('0x27')](_0x43f402[_0xc377('0x22')][_0xc377('0x25')],function(_0x11329e){return{'model':db[_0x11329e[_0xc377('0x26')]],'as':_0x11329e['as'],'attributes':_0x11329e['attributes'],'include':_0x11329e[_0xc377('0x25')]?_[_0xc377('0x27')](_0x11329e[_0xc377('0x25')],function(_0x1d6060){return{'model':db[_0x1d6060[_0xc377('0x26')]],'as':_0x1d6060['as'],'attributes':_0x1d6060[_0xc377('0x23')],'include':_0x1d6060[_0xc377('0x25')]?_['map'](_0x1d6060['include'],function(_0x371489){return{'model':db[_0x371489[_0xc377('0x26')]],'as':_0x371489['as'],'attributes':_0x371489[_0xc377('0x23')]};}):[]};}):[]};}):[]:[]})['then'](function(_0xf8f1d1){logger[_0xc377('0x15')](_0xc377('0x28'),_0x43f402);logger[_0xc377('0x18')](_0xc377('0x28'),_0x43f402,JSON[_0xc377('0x1a')](_0xf8f1d1));_0x15b7df(_0xf8f1d1);})['catch'](function(_0x3bee49){logger[_0xc377('0x1b')](_0xc377('0x28'),_0x3bee49[_0xc377('0x1d')],_0x43f402);_0x228f68(_0x114d66['error'](0x1f4,_0x3bee49[_0xc377('0x1d')]));});});};