c9cb3733ed50dd782c7203ecaf9e134257c8d821
[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 _0x6602=['then','FaxQueue,\x20%s,\x20%s','request\x20sent','debug','FaxQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetFaxQueue','FaxQueue','findAll','options','raw','where','limit','map','include','model','attributes','info','ShowFaxQueue','find','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','defaults','localhost','socket.io-emitter','redis','./faxQueue.socket','request'];(function(_0x551ae9,_0x539204){var _0xb0e09c=function(_0x348c04){while(--_0x348c04){_0x551ae9['push'](_0x551ae9['shift']());}};_0xb0e09c(++_0x539204);}(_0x6602,0xf5));var _0x2660=function(_0x307d86,_0x9264f2){_0x307d86=_0x307d86-0x0;var _0x361745=_0x6602[_0x307d86];return _0x361745;};'use strict';var _=require(_0x2660('0x0'));var util=require(_0x2660('0x1'));var moment=require(_0x2660('0x2'));var BPromise=require(_0x2660('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x2660('0x4'));var db=require(_0x2660('0x5'))['db'];var utils=require(_0x2660('0x6'));var logger=require(_0x2660('0x7'))(_0x2660('0x8'));var config=require(_0x2660('0x9'));var jayson=require(_0x2660('0xa'));var client=jayson[_0x2660('0xb')][_0x2660('0xc')]({'port':0x232a});config['redis']=_[_0x2660('0xd')](config['redis'],{'host':_0x2660('0xe'),'port':0x18eb});var socket=require(_0x2660('0xf'))(new Redis(config[_0x2660('0x10')]));require(_0x2660('0x11'))['register'](socket);function respondWithRpcPromise(_0x109cef,_0x52b00d,_0x2f0309){return new BPromise(function(_0x3769b1,_0x19d1f5){return client[_0x2660('0x12')](_0x109cef,_0x2f0309)[_0x2660('0x13')](function(_0x2a5b4a){logger['info'](_0x2660('0x14'),_0x52b00d,_0x2660('0x15'));logger[_0x2660('0x16')](_0x2660('0x17'),_0x52b00d,_0x2660('0x15'),JSON[_0x2660('0x18')](_0x2a5b4a));if(_0x2a5b4a[_0x2660('0x19')]){if(_0x2a5b4a['error'][_0x2660('0x1a')]===0x1f4){logger[_0x2660('0x19')]('FaxQueue,\x20%s,\x20%s',_0x52b00d,_0x2a5b4a[_0x2660('0x19')]['message']);return _0x19d1f5(_0x2a5b4a[_0x2660('0x19')][_0x2660('0x1b')]);}logger['error'](_0x2660('0x14'),_0x52b00d,_0x2a5b4a[_0x2660('0x19')][_0x2660('0x1b')]);return _0x3769b1(_0x2a5b4a['error'][_0x2660('0x1b')]);}else{logger['info'](_0x2660('0x14'),_0x52b00d,'request\x20sent');_0x3769b1(_0x2a5b4a[_0x2660('0x1c')]['message']);}})[_0x2660('0x1d')](function(_0x390f1a){logger['error'](_0x2660('0x14'),_0x52b00d,_0x390f1a);_0x19d1f5(_0x390f1a);});});}exports[_0x2660('0x1e')]=function(_0x302680){var _0x3661ab=this;return new Promise(function(_0x3b362e,_0x7994c6){return db[_0x2660('0x1f')][_0x2660('0x20')]({'raw':_0x302680[_0x2660('0x21')]?_0x302680[_0x2660('0x21')][_0x2660('0x22')]===undefined?!![]:![]:!![],'where':_0x302680['options']?_0x302680[_0x2660('0x21')][_0x2660('0x23')]||null:null,'attributes':_0x302680[_0x2660('0x21')]?_0x302680[_0x2660('0x21')]['attributes']||null:null,'limit':_0x302680[_0x2660('0x21')]?_0x302680['options'][_0x2660('0x24')]||null:null,'include':_0x302680[_0x2660('0x21')]?_0x302680['options']['include']?_[_0x2660('0x25')](_0x302680['options'][_0x2660('0x26')],function(_0x13b35b){return{'model':db[_0x13b35b[_0x2660('0x27')]],'as':_0x13b35b['as'],'attributes':_0x13b35b[_0x2660('0x28')],'include':_0x13b35b[_0x2660('0x26')]?_[_0x2660('0x25')](_0x13b35b[_0x2660('0x26')],function(_0x3e62b5){return{'model':db[_0x3e62b5[_0x2660('0x27')]],'as':_0x3e62b5['as'],'attributes':_0x3e62b5[_0x2660('0x28')],'include':_0x3e62b5['include']?_[_0x2660('0x25')](_0x3e62b5[_0x2660('0x26')],function(_0x1a325e){return{'model':db[_0x1a325e['model']],'as':_0x1a325e['as'],'attributes':_0x1a325e['attributes']};}):[]};}):[]};}):[]:[]})[_0x2660('0x13')](function(_0x37b064){logger[_0x2660('0x29')](_0x2660('0x1e'),_0x302680);logger['debug']('GetFaxQueue',_0x302680,JSON['stringify'](_0x37b064));_0x3b362e(_0x37b064);})[_0x2660('0x1d')](function(_0x479b0c){logger['error'](_0x2660('0x1e'),_0x479b0c[_0x2660('0x1b')],_0x302680);_0x7994c6(_0x3661ab[_0x2660('0x19')](0x1f4,_0x479b0c[_0x2660('0x1b')]));});});};exports[_0x2660('0x2a')]=function(_0x33a9d6){var _0x283ed6=this;return new Promise(function(_0x58ac04,_0x24bf34){return db['FaxQueue'][_0x2660('0x2b')]({'raw':_0x33a9d6[_0x2660('0x21')]?_0x33a9d6[_0x2660('0x21')]['raw']===undefined?!![]:![]:!![],'where':_0x33a9d6[_0x2660('0x21')]?_0x33a9d6[_0x2660('0x21')][_0x2660('0x23')]||null:null,'attributes':_0x33a9d6['options']?_0x33a9d6[_0x2660('0x21')][_0x2660('0x28')]||null:null,'include':_0x33a9d6[_0x2660('0x21')]?_0x33a9d6[_0x2660('0x21')][_0x2660('0x26')]?_[_0x2660('0x25')](_0x33a9d6[_0x2660('0x21')][_0x2660('0x26')],function(_0x13b622){return{'model':db[_0x13b622[_0x2660('0x27')]],'as':_0x13b622['as'],'attributes':_0x13b622['attributes'],'include':_0x13b622[_0x2660('0x26')]?_[_0x2660('0x25')](_0x13b622['include'],function(_0x40da4d){return{'model':db[_0x40da4d[_0x2660('0x27')]],'as':_0x40da4d['as'],'attributes':_0x40da4d[_0x2660('0x28')],'include':_0x40da4d[_0x2660('0x26')]?_['map'](_0x40da4d[_0x2660('0x26')],function(_0x2bf121){return{'model':db[_0x2bf121['model']],'as':_0x2bf121['as'],'attributes':_0x2bf121[_0x2660('0x28')]};}):[]};}):[]};}):[]:[]})[_0x2660('0x13')](function(_0x5630da){logger['info'](_0x2660('0x2a'),_0x33a9d6);logger['debug'](_0x2660('0x2a'),_0x33a9d6,JSON[_0x2660('0x18')](_0x5630da));_0x58ac04(_0x5630da);})[_0x2660('0x1d')](function(_0x19a2a8){logger[_0x2660('0x19')](_0x2660('0x2a'),_0x19a2a8[_0x2660('0x1b')],_0x33a9d6);_0x24bf34(_0x283ed6[_0x2660('0x19')](0x1f4,_0x19a2a8[_0x2660('0x1b')]));});});};