Built motion from commit 4ca75f1b.|2.6.28
[motion2.git] / server / api / faxQueue / faxQueue.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 _0x64f6=['debug','stringify','error','code','message','result','catch','findAll','options','raw','where','attributes','limit','map','include','model','then','GetFaxQueue','ShowFaxQueue','lodash','moment','randomstring','../../config/utils','../../config/logger','rpc','client','http','redis','defaults','socket.io-emitter','register','request','info','FaxQueue,\x20%s,\x20%s','request\x20sent'];(function(_0x322dac,_0xa46f61){var _0x561bf1=function(_0x4bd1c4){while(--_0x4bd1c4){_0x322dac['push'](_0x322dac['shift']());}};_0x561bf1(++_0xa46f61);}(_0x64f6,0x7c));var _0x664f=function(_0x336ba7,_0x3fb69b){_0x336ba7=_0x336ba7-0x0;var _0x43a5bb=_0x64f6[_0x336ba7];return _0x43a5bb;};'use strict';var _=require(_0x664f('0x0'));var util=require('util');var moment=require(_0x664f('0x1'));var BPromise=require('bluebird');var rs=require(_0x664f('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x664f('0x3'));var logger=require(_0x664f('0x4'))(_0x664f('0x5'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x664f('0x6')][_0x664f('0x7')]({'port':0x232a});config[_0x664f('0x8')]=_[_0x664f('0x9')](config[_0x664f('0x8')],{'host':'localhost','port':0x18eb});var socket=require(_0x664f('0xa'))(new Redis(config[_0x664f('0x8')]));require('./faxQueue.socket')[_0x664f('0xb')](socket);function respondWithRpcPromise(_0x1e9ac0,_0x50550a,_0x129d1b){return new BPromise(function(_0x16cd55,_0x5d5e64){return client[_0x664f('0xc')](_0x1e9ac0,_0x129d1b)['then'](function(_0x5bdf87){logger[_0x664f('0xd')](_0x664f('0xe'),_0x50550a,_0x664f('0xf'));logger[_0x664f('0x10')]('FaxQueue,\x20%s,\x20%s,\x20%s',_0x50550a,_0x664f('0xf'),JSON[_0x664f('0x11')](_0x5bdf87));if(_0x5bdf87[_0x664f('0x12')]){if(_0x5bdf87[_0x664f('0x12')][_0x664f('0x13')]===0x1f4){logger[_0x664f('0x12')]('FaxQueue,\x20%s,\x20%s',_0x50550a,_0x5bdf87[_0x664f('0x12')][_0x664f('0x14')]);return _0x5d5e64(_0x5bdf87[_0x664f('0x12')][_0x664f('0x14')]);}logger['error'](_0x664f('0xe'),_0x50550a,_0x5bdf87['error']['message']);return _0x16cd55(_0x5bdf87[_0x664f('0x12')][_0x664f('0x14')]);}else{logger[_0x664f('0xd')](_0x664f('0xe'),_0x50550a,_0x664f('0xf'));_0x16cd55(_0x5bdf87[_0x664f('0x15')][_0x664f('0x14')]);}})[_0x664f('0x16')](function(_0x2317a5){logger['error']('FaxQueue,\x20%s,\x20%s',_0x50550a,_0x2317a5);_0x5d5e64(_0x2317a5);});});}exports['GetFaxQueue']=function(_0x2174fa){var _0x552644=this;return new Promise(function(_0x112109,_0x1be0fd){return db['FaxQueue'][_0x664f('0x17')]({'raw':_0x2174fa[_0x664f('0x18')]?_0x2174fa[_0x664f('0x18')][_0x664f('0x19')]===undefined?!![]:![]:!![],'where':_0x2174fa[_0x664f('0x18')]?_0x2174fa[_0x664f('0x18')][_0x664f('0x1a')]||null:null,'attributes':_0x2174fa[_0x664f('0x18')]?_0x2174fa['options'][_0x664f('0x1b')]||null:null,'limit':_0x2174fa[_0x664f('0x18')]?_0x2174fa['options'][_0x664f('0x1c')]||null:null,'include':_0x2174fa[_0x664f('0x18')]?_0x2174fa[_0x664f('0x18')]['include']?_[_0x664f('0x1d')](_0x2174fa[_0x664f('0x18')][_0x664f('0x1e')],function(_0x317b0d){return{'model':db[_0x317b0d[_0x664f('0x1f')]],'as':_0x317b0d['as'],'attributes':_0x317b0d[_0x664f('0x1b')],'include':_0x317b0d[_0x664f('0x1e')]?_[_0x664f('0x1d')](_0x317b0d[_0x664f('0x1e')],function(_0x357b5e){return{'model':db[_0x357b5e[_0x664f('0x1f')]],'as':_0x357b5e['as'],'attributes':_0x357b5e[_0x664f('0x1b')],'include':_0x357b5e[_0x664f('0x1e')]?_['map'](_0x357b5e[_0x664f('0x1e')],function(_0x12d732){return{'model':db[_0x12d732['model']],'as':_0x12d732['as'],'attributes':_0x12d732[_0x664f('0x1b')]};}):[]};}):[]};}):[]:[]})[_0x664f('0x20')](function(_0xb2bea5){logger[_0x664f('0xd')](_0x664f('0x21'),_0x2174fa);logger[_0x664f('0x10')](_0x664f('0x21'),_0x2174fa,JSON[_0x664f('0x11')](_0xb2bea5));_0x112109(_0xb2bea5);})[_0x664f('0x16')](function(_0x167699){logger['error']('GetFaxQueue',_0x167699[_0x664f('0x14')],_0x2174fa);_0x1be0fd(_0x552644[_0x664f('0x12')](0x1f4,_0x167699[_0x664f('0x14')]));});});};exports[_0x664f('0x22')]=function(_0x502b82){var _0x3f92d3=this;return new Promise(function(_0x54845c,_0x19ed0f){return db['FaxQueue']['find']({'raw':_0x502b82[_0x664f('0x18')]?_0x502b82['options'][_0x664f('0x19')]===undefined?!![]:![]:!![],'where':_0x502b82[_0x664f('0x18')]?_0x502b82[_0x664f('0x18')][_0x664f('0x1a')]||null:null,'attributes':_0x502b82[_0x664f('0x18')]?_0x502b82['options'][_0x664f('0x1b')]||null:null,'include':_0x502b82['options']?_0x502b82[_0x664f('0x18')]['include']?_[_0x664f('0x1d')](_0x502b82[_0x664f('0x18')][_0x664f('0x1e')],function(_0x10d6e5){return{'model':db[_0x10d6e5[_0x664f('0x1f')]],'as':_0x10d6e5['as'],'attributes':_0x10d6e5[_0x664f('0x1b')],'include':_0x10d6e5[_0x664f('0x1e')]?_[_0x664f('0x1d')](_0x10d6e5[_0x664f('0x1e')],function(_0x569aa7){return{'model':db[_0x569aa7['model']],'as':_0x569aa7['as'],'attributes':_0x569aa7[_0x664f('0x1b')],'include':_0x569aa7['include']?_[_0x664f('0x1d')](_0x569aa7[_0x664f('0x1e')],function(_0x3caec7){return{'model':db[_0x3caec7[_0x664f('0x1f')]],'as':_0x3caec7['as'],'attributes':_0x3caec7[_0x664f('0x1b')]};}):[]};}):[]};}):[]:[]})[_0x664f('0x20')](function(_0x2d6718){logger[_0x664f('0xd')](_0x664f('0x22'),_0x502b82);logger[_0x664f('0x10')](_0x664f('0x22'),_0x502b82,JSON[_0x664f('0x11')](_0x2d6718));_0x54845c(_0x2d6718);})['catch'](function(_0x14c6e9){logger[_0x664f('0x12')](_0x664f('0x22'),_0x14c6e9[_0x664f('0x14')],_0x502b82);_0x19ed0f(_0x3f92d3['error'](0x1f4,_0x14c6e9[_0x664f('0x14')]));});});};