bf1137e60393aec6c57ef0dacbcf6caa03961505
[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 _0x3352=['result','catch','FaxQueue','findAll','options','raw','where','attributes','include','map','model','GetFaxQueue','debug','ShowFaxQueue','util','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./faxQueue.socket','register','then','FaxQueue,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','FaxQueue,\x20%s,\x20%s','message','info'];(function(_0x19e35c,_0x29cd1e){var _0x3e1fe8=function(_0x17258b){while(--_0x17258b){_0x19e35c['push'](_0x19e35c['shift']());}};_0x3e1fe8(++_0x29cd1e);}(_0x3352,0x1bb));var _0x2335=function(_0x4af23c,_0x50e294){_0x4af23c=_0x4af23c-0x0;var _0x194b63=_0x3352[_0x4af23c];return _0x194b63;};'use strict';var _=require('lodash');var util=require(_0x2335('0x0'));var moment=require('moment');var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x2335('0x1'));var db=require(_0x2335('0x2'))['db'];var utils=require(_0x2335('0x3'));var logger=require(_0x2335('0x4'))(_0x2335('0x5'));var config=require(_0x2335('0x6'));var jayson=require(_0x2335('0x7'));var client=jayson[_0x2335('0x8')][_0x2335('0x9')]({'port':0x232a});config[_0x2335('0xa')]=_[_0x2335('0xb')](config[_0x2335('0xa')],{'host':_0x2335('0xc'),'port':0x18eb});var socket=require(_0x2335('0xd'))(new Redis(config[_0x2335('0xa')]));require(_0x2335('0xe'))[_0x2335('0xf')](socket);function respondWithRpcPromise(_0x24929b,_0x28c848,_0x33d3b6){return new BPromise(function(_0x1d8bcf,_0x1bbef3){return client['request'](_0x24929b,_0x33d3b6)[_0x2335('0x10')](function(_0x4f4f52){logger['info']('FaxQueue,\x20%s,\x20%s',_0x28c848,'request\x20sent');logger['debug'](_0x2335('0x11'),_0x28c848,_0x2335('0x12'),JSON[_0x2335('0x13')](_0x4f4f52));if(_0x4f4f52[_0x2335('0x14')]){if(_0x4f4f52[_0x2335('0x14')][_0x2335('0x15')]===0x1f4){logger['error'](_0x2335('0x16'),_0x28c848,_0x4f4f52[_0x2335('0x14')][_0x2335('0x17')]);return _0x1bbef3(_0x4f4f52[_0x2335('0x14')][_0x2335('0x17')]);}logger[_0x2335('0x14')](_0x2335('0x16'),_0x28c848,_0x4f4f52['error'][_0x2335('0x17')]);return _0x1d8bcf(_0x4f4f52[_0x2335('0x14')][_0x2335('0x17')]);}else{logger[_0x2335('0x18')](_0x2335('0x16'),_0x28c848,_0x2335('0x12'));_0x1d8bcf(_0x4f4f52[_0x2335('0x19')][_0x2335('0x17')]);}})[_0x2335('0x1a')](function(_0x5a7e25){logger['error'](_0x2335('0x16'),_0x28c848,_0x5a7e25);_0x1bbef3(_0x5a7e25);});});}exports['GetFaxQueue']=function(_0x20b7e6){var _0x3f5676=this;return new Promise(function(_0x1601ef,_0x4f49ed){return db[_0x2335('0x1b')][_0x2335('0x1c')]({'raw':_0x20b7e6[_0x2335('0x1d')]?_0x20b7e6[_0x2335('0x1d')][_0x2335('0x1e')]===undefined?!![]:![]:!![],'where':_0x20b7e6[_0x2335('0x1d')]?_0x20b7e6[_0x2335('0x1d')][_0x2335('0x1f')]||null:null,'attributes':_0x20b7e6[_0x2335('0x1d')]?_0x20b7e6[_0x2335('0x1d')][_0x2335('0x20')]||null:null,'limit':_0x20b7e6['options']?_0x20b7e6[_0x2335('0x1d')]['limit']||null:null,'include':_0x20b7e6['options']?_0x20b7e6[_0x2335('0x1d')][_0x2335('0x21')]?_[_0x2335('0x22')](_0x20b7e6[_0x2335('0x1d')][_0x2335('0x21')],function(_0x1999cf){return{'model':db[_0x1999cf['model']],'as':_0x1999cf['as'],'attributes':_0x1999cf['attributes'],'include':_0x1999cf[_0x2335('0x21')]?_[_0x2335('0x22')](_0x1999cf[_0x2335('0x21')],function(_0x585778){return{'model':db[_0x585778[_0x2335('0x23')]],'as':_0x585778['as'],'attributes':_0x585778[_0x2335('0x20')],'include':_0x585778[_0x2335('0x21')]?_[_0x2335('0x22')](_0x585778[_0x2335('0x21')],function(_0x283854){return{'model':db[_0x283854['model']],'as':_0x283854['as'],'attributes':_0x283854[_0x2335('0x20')]};}):[]};}):[]};}):[]:[]})[_0x2335('0x10')](function(_0xa8ee8a){logger['info'](_0x2335('0x24'),_0x20b7e6);logger[_0x2335('0x25')]('GetFaxQueue',_0x20b7e6,JSON[_0x2335('0x13')](_0xa8ee8a));_0x1601ef(_0xa8ee8a);})[_0x2335('0x1a')](function(_0x5016d4){logger[_0x2335('0x14')](_0x2335('0x24'),_0x5016d4[_0x2335('0x17')],_0x20b7e6);_0x4f49ed(_0x3f5676[_0x2335('0x14')](0x1f4,_0x5016d4[_0x2335('0x17')]));});});};exports[_0x2335('0x26')]=function(_0x448f49){var _0x54dd13=this;return new Promise(function(_0x1ceda0,_0x318637){return db[_0x2335('0x1b')]['find']({'raw':_0x448f49[_0x2335('0x1d')]?_0x448f49[_0x2335('0x1d')][_0x2335('0x1e')]===undefined?!![]:![]:!![],'where':_0x448f49[_0x2335('0x1d')]?_0x448f49[_0x2335('0x1d')]['where']||null:null,'attributes':_0x448f49['options']?_0x448f49[_0x2335('0x1d')][_0x2335('0x20')]||null:null,'include':_0x448f49['options']?_0x448f49[_0x2335('0x1d')]['include']?_[_0x2335('0x22')](_0x448f49['options']['include'],function(_0x145928){return{'model':db[_0x145928[_0x2335('0x23')]],'as':_0x145928['as'],'attributes':_0x145928[_0x2335('0x20')],'include':_0x145928[_0x2335('0x21')]?_[_0x2335('0x22')](_0x145928[_0x2335('0x21')],function(_0x2cc000){return{'model':db[_0x2cc000['model']],'as':_0x2cc000['as'],'attributes':_0x2cc000[_0x2335('0x20')],'include':_0x2cc000[_0x2335('0x21')]?_[_0x2335('0x22')](_0x2cc000[_0x2335('0x21')],function(_0x5dc1c7){return{'model':db[_0x5dc1c7[_0x2335('0x23')]],'as':_0x5dc1c7['as'],'attributes':_0x5dc1c7['attributes']};}):[]};}):[]};}):[]:[]})[_0x2335('0x10')](function(_0x33bb7e){logger[_0x2335('0x18')](_0x2335('0x26'),_0x448f49);logger[_0x2335('0x25')](_0x2335('0x26'),_0x448f49,JSON['stringify'](_0x33bb7e));_0x1ceda0(_0x33bb7e);})['catch'](function(_0x3c2ad8){logger[_0x2335('0x14')]('ShowFaxQueue',_0x3c2ad8[_0x2335('0x17')],_0x448f49);_0x318637(_0x54dd13['error'](0x1f4,_0x3c2ad8[_0x2335('0x17')]));});});};