fddabf2de784181533b1154d3183879dba714317
[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 _0xb57f=['util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','redis','defaults','localhost','socket.io-emitter','./faxQueue.socket','register','request','then','info','FaxQueue,\x20%s,\x20%s','request\x20sent','FaxQueue,\x20%s,\x20%s,\x20%s','error','code','message','catch','findAll','options','raw','where','attributes','limit','include','model','map','GetFaxQueue','debug','stringify','ShowFaxQueue','FaxQueue','find','lodash'];(function(_0x361db5,_0x4c6909){var _0x4540a9=function(_0x24160c){while(--_0x24160c){_0x361db5['push'](_0x361db5['shift']());}};_0x4540a9(++_0x4c6909);}(_0xb57f,0x147));var _0xfb57=function(_0x1e36db,_0x1143f6){_0x1e36db=_0x1e36db-0x0;var _0x58eb26=_0xb57f[_0x1e36db];return _0x58eb26;};'use strict';var _=require(_0xfb57('0x0'));var util=require(_0xfb57('0x1'));var moment=require(_0xfb57('0x2'));var BPromise=require(_0xfb57('0x3'));var rs=require(_0xfb57('0x4'));var fs=require('fs');var Redis=require(_0xfb57('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0xfb57('0x6'));var logger=require(_0xfb57('0x7'))(_0xfb57('0x8'));var config=require(_0xfb57('0x9'));var jayson=require('jayson/promise');var client=jayson['client']['http']({'port':0x232a});config[_0xfb57('0xa')]=_[_0xfb57('0xb')](config[_0xfb57('0xa')],{'host':_0xfb57('0xc'),'port':0x18eb});var socket=require(_0xfb57('0xd'))(new Redis(config[_0xfb57('0xa')]));require(_0xfb57('0xe'))[_0xfb57('0xf')](socket);function respondWithRpcPromise(_0x1cccfc,_0x10e679,_0x1768bc){return new BPromise(function(_0x5d55db,_0x3a5847){return client[_0xfb57('0x10')](_0x1cccfc,_0x1768bc)[_0xfb57('0x11')](function(_0x11a2cb){logger[_0xfb57('0x12')](_0xfb57('0x13'),_0x10e679,_0xfb57('0x14'));logger['debug'](_0xfb57('0x15'),_0x10e679,_0xfb57('0x14'),JSON['stringify'](_0x11a2cb));if(_0x11a2cb[_0xfb57('0x16')]){if(_0x11a2cb[_0xfb57('0x16')][_0xfb57('0x17')]===0x1f4){logger[_0xfb57('0x16')]('FaxQueue,\x20%s,\x20%s',_0x10e679,_0x11a2cb[_0xfb57('0x16')]['message']);return _0x3a5847(_0x11a2cb[_0xfb57('0x16')][_0xfb57('0x18')]);}logger[_0xfb57('0x16')](_0xfb57('0x13'),_0x10e679,_0x11a2cb['error']['message']);return _0x5d55db(_0x11a2cb[_0xfb57('0x16')][_0xfb57('0x18')]);}else{logger[_0xfb57('0x12')](_0xfb57('0x13'),_0x10e679,_0xfb57('0x14'));_0x5d55db(_0x11a2cb['result'][_0xfb57('0x18')]);}})[_0xfb57('0x19')](function(_0x1fe1b9){logger[_0xfb57('0x16')](_0xfb57('0x13'),_0x10e679,_0x1fe1b9);_0x3a5847(_0x1fe1b9);});});}exports['GetFaxQueue']=function(_0x3169ee){var _0x961242=this;return new Promise(function(_0x18d97f,_0x832362){return db['FaxQueue'][_0xfb57('0x1a')]({'raw':_0x3169ee[_0xfb57('0x1b')]?_0x3169ee[_0xfb57('0x1b')][_0xfb57('0x1c')]===undefined?!![]:![]:!![],'where':_0x3169ee[_0xfb57('0x1b')]?_0x3169ee[_0xfb57('0x1b')][_0xfb57('0x1d')]||null:null,'attributes':_0x3169ee['options']?_0x3169ee['options'][_0xfb57('0x1e')]||null:null,'limit':_0x3169ee['options']?_0x3169ee[_0xfb57('0x1b')][_0xfb57('0x1f')]||null:null,'include':_0x3169ee[_0xfb57('0x1b')]?_0x3169ee[_0xfb57('0x1b')][_0xfb57('0x20')]?_['map'](_0x3169ee[_0xfb57('0x1b')][_0xfb57('0x20')],function(_0x31c745){return{'model':db[_0x31c745[_0xfb57('0x21')]],'as':_0x31c745['as'],'attributes':_0x31c745[_0xfb57('0x1e')],'include':_0x31c745[_0xfb57('0x20')]?_[_0xfb57('0x22')](_0x31c745[_0xfb57('0x20')],function(_0x5024a0){return{'model':db[_0x5024a0[_0xfb57('0x21')]],'as':_0x5024a0['as'],'attributes':_0x5024a0[_0xfb57('0x1e')],'include':_0x5024a0['include']?_['map'](_0x5024a0['include'],function(_0x28ba0c){return{'model':db[_0x28ba0c[_0xfb57('0x21')]],'as':_0x28ba0c['as'],'attributes':_0x28ba0c[_0xfb57('0x1e')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x5996be){logger[_0xfb57('0x12')](_0xfb57('0x23'),_0x3169ee);logger[_0xfb57('0x24')]('GetFaxQueue',_0x3169ee,JSON[_0xfb57('0x25')](_0x5996be));_0x18d97f(_0x5996be);})['catch'](function(_0x6bb246){logger[_0xfb57('0x16')](_0xfb57('0x23'),_0x6bb246[_0xfb57('0x18')],_0x3169ee);_0x832362(_0x961242[_0xfb57('0x16')](0x1f4,_0x6bb246['message']));});});};exports[_0xfb57('0x26')]=function(_0x53bb26){var _0x288362=this;return new Promise(function(_0x3749c1,_0x57ac34){return db[_0xfb57('0x27')][_0xfb57('0x28')]({'raw':_0x53bb26[_0xfb57('0x1b')]?_0x53bb26['options'][_0xfb57('0x1c')]===undefined?!![]:![]:!![],'where':_0x53bb26[_0xfb57('0x1b')]?_0x53bb26[_0xfb57('0x1b')][_0xfb57('0x1d')]||null:null,'attributes':_0x53bb26[_0xfb57('0x1b')]?_0x53bb26[_0xfb57('0x1b')][_0xfb57('0x1e')]||null:null,'include':_0x53bb26[_0xfb57('0x1b')]?_0x53bb26['options'][_0xfb57('0x20')]?_[_0xfb57('0x22')](_0x53bb26[_0xfb57('0x1b')][_0xfb57('0x20')],function(_0x593b73){return{'model':db[_0x593b73[_0xfb57('0x21')]],'as':_0x593b73['as'],'attributes':_0x593b73[_0xfb57('0x1e')],'include':_0x593b73[_0xfb57('0x20')]?_['map'](_0x593b73['include'],function(_0x54172e){return{'model':db[_0x54172e['model']],'as':_0x54172e['as'],'attributes':_0x54172e[_0xfb57('0x1e')],'include':_0x54172e['include']?_[_0xfb57('0x22')](_0x54172e[_0xfb57('0x20')],function(_0x4f6eeb){return{'model':db[_0x4f6eeb[_0xfb57('0x21')]],'as':_0x4f6eeb['as'],'attributes':_0x4f6eeb['attributes']};}):[]};}):[]};}):[]:[]})[_0xfb57('0x11')](function(_0x2daf8b){logger[_0xfb57('0x12')]('ShowFaxQueue',_0x53bb26);logger['debug']('ShowFaxQueue',_0x53bb26,JSON['stringify'](_0x2daf8b));_0x3749c1(_0x2daf8b);})[_0xfb57('0x19')](function(_0x431943){logger['error']('ShowFaxQueue',_0x431943['message'],_0x53bb26);_0x57ac34(_0x288362[_0xfb57('0x16')](0x1f4,_0x431943[_0xfb57('0x18')]));});});};