Built motion from commit 616d3211.|2.6.4
[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 _0x699a=['FaxQueue','findAll','options','raw','where','attributes','limit','map','model','include','GetFaxQueue','ShowFaxQueue','find','lodash','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','redis','localhost','socket.io-emitter','register','request','then','info','FaxQueue,\x20%s,\x20%s','debug','request\x20sent','stringify','error','code','message','catch'];(function(_0x481bdf,_0x231538){var _0x281a12=function(_0x264b18){while(--_0x264b18){_0x481bdf['push'](_0x481bdf['shift']());}};_0x281a12(++_0x231538);}(_0x699a,0x1ee));var _0xa699=function(_0x36f243,_0x188505){_0x36f243=_0x36f243-0x0;var _0x426436=_0x699a[_0x36f243];return _0x426436;};'use strict';var _=require(_0xa699('0x0'));var util=require('util');var moment=require(_0xa699('0x1'));var BPromise=require(_0xa699('0x2'));var rs=require(_0xa699('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xa699('0x4'))['db'];var utils=require(_0xa699('0x5'));var logger=require(_0xa699('0x6'))(_0xa699('0x7'));var config=require('../../config/environment');var jayson=require(_0xa699('0x8'));var client=jayson['client']['http']({'port':0x232a});config[_0xa699('0x9')]=_['defaults'](config['redis'],{'host':_0xa699('0xa'),'port':0x18eb});var socket=require(_0xa699('0xb'))(new Redis(config[_0xa699('0x9')]));require('./faxQueue.socket')[_0xa699('0xc')](socket);function respondWithRpcPromise(_0x4c3d1e,_0x43d8d0,_0x5db28a){return new BPromise(function(_0x3bef61,_0x36c6f9){return client[_0xa699('0xd')](_0x4c3d1e,_0x5db28a)[_0xa699('0xe')](function(_0x3e4a95){logger[_0xa699('0xf')](_0xa699('0x10'),_0x43d8d0,'request\x20sent');logger[_0xa699('0x11')]('FaxQueue,\x20%s,\x20%s,\x20%s',_0x43d8d0,_0xa699('0x12'),JSON[_0xa699('0x13')](_0x3e4a95));if(_0x3e4a95['error']){if(_0x3e4a95[_0xa699('0x14')][_0xa699('0x15')]===0x1f4){logger[_0xa699('0x14')](_0xa699('0x10'),_0x43d8d0,_0x3e4a95['error'][_0xa699('0x16')]);return _0x36c6f9(_0x3e4a95[_0xa699('0x14')][_0xa699('0x16')]);}logger[_0xa699('0x14')](_0xa699('0x10'),_0x43d8d0,_0x3e4a95[_0xa699('0x14')]['message']);return _0x3bef61(_0x3e4a95['error'][_0xa699('0x16')]);}else{logger[_0xa699('0xf')](_0xa699('0x10'),_0x43d8d0,_0xa699('0x12'));_0x3bef61(_0x3e4a95['result'][_0xa699('0x16')]);}})[_0xa699('0x17')](function(_0x43f664){logger[_0xa699('0x14')](_0xa699('0x10'),_0x43d8d0,_0x43f664);_0x36c6f9(_0x43f664);});});}exports['GetFaxQueue']=function(_0x13ac48){var _0x505030=this;return new Promise(function(_0x586aae,_0x380349){return db[_0xa699('0x18')][_0xa699('0x19')]({'raw':_0x13ac48[_0xa699('0x1a')]?_0x13ac48['options'][_0xa699('0x1b')]===undefined?!![]:![]:!![],'where':_0x13ac48[_0xa699('0x1a')]?_0x13ac48['options'][_0xa699('0x1c')]||null:null,'attributes':_0x13ac48[_0xa699('0x1a')]?_0x13ac48[_0xa699('0x1a')][_0xa699('0x1d')]||null:null,'limit':_0x13ac48[_0xa699('0x1a')]?_0x13ac48['options'][_0xa699('0x1e')]||null:null,'include':_0x13ac48[_0xa699('0x1a')]?_0x13ac48['options']['include']?_[_0xa699('0x1f')](_0x13ac48[_0xa699('0x1a')]['include'],function(_0x4867d1){return{'model':db[_0x4867d1[_0xa699('0x20')]],'as':_0x4867d1['as'],'attributes':_0x4867d1[_0xa699('0x1d')],'include':_0x4867d1[_0xa699('0x21')]?_['map'](_0x4867d1['include'],function(_0x16c926){return{'model':db[_0x16c926[_0xa699('0x20')]],'as':_0x16c926['as'],'attributes':_0x16c926[_0xa699('0x1d')],'include':_0x16c926['include']?_[_0xa699('0x1f')](_0x16c926[_0xa699('0x21')],function(_0x107635){return{'model':db[_0x107635['model']],'as':_0x107635['as'],'attributes':_0x107635[_0xa699('0x1d')]};}):[]};}):[]};}):[]:[]})[_0xa699('0xe')](function(_0xe100f5){logger[_0xa699('0xf')]('GetFaxQueue',_0x13ac48);logger[_0xa699('0x11')](_0xa699('0x22'),_0x13ac48,JSON['stringify'](_0xe100f5));_0x586aae(_0xe100f5);})[_0xa699('0x17')](function(_0x490d05){logger['error'](_0xa699('0x22'),_0x490d05['message'],_0x13ac48);_0x380349(_0x505030[_0xa699('0x14')](0x1f4,_0x490d05[_0xa699('0x16')]));});});};exports[_0xa699('0x23')]=function(_0x15f8a3){var _0x543f79=this;return new Promise(function(_0x459391,_0x3b9563){return db[_0xa699('0x18')][_0xa699('0x24')]({'raw':_0x15f8a3[_0xa699('0x1a')]?_0x15f8a3[_0xa699('0x1a')][_0xa699('0x1b')]===undefined?!![]:![]:!![],'where':_0x15f8a3[_0xa699('0x1a')]?_0x15f8a3[_0xa699('0x1a')][_0xa699('0x1c')]||null:null,'attributes':_0x15f8a3[_0xa699('0x1a')]?_0x15f8a3[_0xa699('0x1a')][_0xa699('0x1d')]||null:null,'include':_0x15f8a3[_0xa699('0x1a')]?_0x15f8a3['options'][_0xa699('0x21')]?_['map'](_0x15f8a3['options'][_0xa699('0x21')],function(_0x532417){return{'model':db[_0x532417[_0xa699('0x20')]],'as':_0x532417['as'],'attributes':_0x532417['attributes'],'include':_0x532417['include']?_[_0xa699('0x1f')](_0x532417[_0xa699('0x21')],function(_0x4ad189){return{'model':db[_0x4ad189[_0xa699('0x20')]],'as':_0x4ad189['as'],'attributes':_0x4ad189[_0xa699('0x1d')],'include':_0x4ad189[_0xa699('0x21')]?_[_0xa699('0x1f')](_0x4ad189[_0xa699('0x21')],function(_0x19bd04){return{'model':db[_0x19bd04[_0xa699('0x20')]],'as':_0x19bd04['as'],'attributes':_0x19bd04[_0xa699('0x1d')]};}):[]};}):[]};}):[]:[]})[_0xa699('0xe')](function(_0x5bd60a){logger['info']('ShowFaxQueue',_0x15f8a3);logger[_0xa699('0x11')](_0xa699('0x23'),_0x15f8a3,JSON[_0xa699('0x13')](_0x5bd60a));_0x459391(_0x5bd60a);})[_0xa699('0x17')](function(_0x181280){logger[_0xa699('0x14')](_0xa699('0x23'),_0x181280[_0xa699('0x16')],_0x15f8a3);_0x3b9563(_0x543f79[_0xa699('0x14')](0x1f4,_0x181280['message']));});});};