Built motion from commit 7158bc59.|2.5.42
[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 _0xddaa=['GetFaxQueue','FaxQueue','findAll','options','raw','where','attributes','limit','include','map','model','ShowFaxQueue','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','redis','defaults','localhost','socket.io-emitter','./faxQueue.socket','register','request','then','info','request\x20sent','stringify','error','FaxQueue,\x20%s,\x20%s','message','catch'];(function(_0x13f0f2,_0x2b3566){var _0xe733ed=function(_0x2c64e4){while(--_0x2c64e4){_0x13f0f2['push'](_0x13f0f2['shift']());}};_0xe733ed(++_0x2b3566);}(_0xddaa,0x134));var _0xadda=function(_0x1e14e5,_0x27f63a){_0x1e14e5=_0x1e14e5-0x0;var _0x3dce1b=_0xddaa[_0x1e14e5];return _0x3dce1b;};'use strict';var _=require(_0xadda('0x0'));var util=require(_0xadda('0x1'));var moment=require(_0xadda('0x2'));var BPromise=require(_0xadda('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xadda('0x4'));var db=require(_0xadda('0x5'))['db'];var utils=require(_0xadda('0x6'));var logger=require(_0xadda('0x7'))('rpc');var config=require(_0xadda('0x8'));var jayson=require(_0xadda('0x9'));var client=jayson['client']['http']({'port':0x232a});config[_0xadda('0xa')]=_[_0xadda('0xb')](config[_0xadda('0xa')],{'host':_0xadda('0xc'),'port':0x18eb});var socket=require(_0xadda('0xd'))(new Redis(config[_0xadda('0xa')]));require(_0xadda('0xe'))[_0xadda('0xf')](socket);function respondWithRpcPromise(_0xce3011,_0x57c799,_0x1b1444){return new BPromise(function(_0x56e0b2,_0x3b2d9f){return client[_0xadda('0x10')](_0xce3011,_0x1b1444)[_0xadda('0x11')](function(_0x4be8d2){logger[_0xadda('0x12')]('FaxQueue,\x20%s,\x20%s',_0x57c799,'request\x20sent');logger['debug']('FaxQueue,\x20%s,\x20%s,\x20%s',_0x57c799,_0xadda('0x13'),JSON[_0xadda('0x14')](_0x4be8d2));if(_0x4be8d2[_0xadda('0x15')]){if(_0x4be8d2[_0xadda('0x15')]['code']===0x1f4){logger['error'](_0xadda('0x16'),_0x57c799,_0x4be8d2[_0xadda('0x15')][_0xadda('0x17')]);return _0x3b2d9f(_0x4be8d2[_0xadda('0x15')]['message']);}logger[_0xadda('0x15')](_0xadda('0x16'),_0x57c799,_0x4be8d2[_0xadda('0x15')][_0xadda('0x17')]);return _0x56e0b2(_0x4be8d2[_0xadda('0x15')][_0xadda('0x17')]);}else{logger[_0xadda('0x12')]('FaxQueue,\x20%s,\x20%s',_0x57c799,_0xadda('0x13'));_0x56e0b2(_0x4be8d2['result'][_0xadda('0x17')]);}})[_0xadda('0x18')](function(_0xf7b144){logger['error']('FaxQueue,\x20%s,\x20%s',_0x57c799,_0xf7b144);_0x3b2d9f(_0xf7b144);});});}exports[_0xadda('0x19')]=function(_0xc2135c){var _0x23e77d=this;return new Promise(function(_0x205238,_0x1afcf4){return db[_0xadda('0x1a')][_0xadda('0x1b')]({'raw':_0xc2135c['options']?_0xc2135c[_0xadda('0x1c')][_0xadda('0x1d')]===undefined?!![]:![]:!![],'where':_0xc2135c[_0xadda('0x1c')]?_0xc2135c[_0xadda('0x1c')][_0xadda('0x1e')]||null:null,'attributes':_0xc2135c['options']?_0xc2135c[_0xadda('0x1c')][_0xadda('0x1f')]||null:null,'limit':_0xc2135c[_0xadda('0x1c')]?_0xc2135c[_0xadda('0x1c')][_0xadda('0x20')]||null:null,'include':_0xc2135c[_0xadda('0x1c')]?_0xc2135c[_0xadda('0x1c')][_0xadda('0x21')]?_[_0xadda('0x22')](_0xc2135c[_0xadda('0x1c')]['include'],function(_0x1d7ad2){return{'model':db[_0x1d7ad2[_0xadda('0x23')]],'as':_0x1d7ad2['as'],'attributes':_0x1d7ad2[_0xadda('0x1f')],'include':_0x1d7ad2[_0xadda('0x21')]?_[_0xadda('0x22')](_0x1d7ad2[_0xadda('0x21')],function(_0x40ff7f){return{'model':db[_0x40ff7f[_0xadda('0x23')]],'as':_0x40ff7f['as'],'attributes':_0x40ff7f[_0xadda('0x1f')],'include':_0x40ff7f[_0xadda('0x21')]?_[_0xadda('0x22')](_0x40ff7f['include'],function(_0x3be119){return{'model':db[_0x3be119[_0xadda('0x23')]],'as':_0x3be119['as'],'attributes':_0x3be119[_0xadda('0x1f')]};}):[]};}):[]};}):[]:[]})[_0xadda('0x11')](function(_0x3b5e72){logger[_0xadda('0x12')]('GetFaxQueue',_0xc2135c);logger['debug'](_0xadda('0x19'),_0xc2135c,JSON['stringify'](_0x3b5e72));_0x205238(_0x3b5e72);})[_0xadda('0x18')](function(_0x3dc42c){logger['error'](_0xadda('0x19'),_0x3dc42c[_0xadda('0x17')],_0xc2135c);_0x1afcf4(_0x23e77d[_0xadda('0x15')](0x1f4,_0x3dc42c[_0xadda('0x17')]));});});};exports[_0xadda('0x24')]=function(_0x2ce0c6){var _0x41f3fb=this;return new Promise(function(_0xd195f2,_0x5701f5){return db[_0xadda('0x1a')]['find']({'raw':_0x2ce0c6[_0xadda('0x1c')]?_0x2ce0c6[_0xadda('0x1c')][_0xadda('0x1d')]===undefined?!![]:![]:!![],'where':_0x2ce0c6[_0xadda('0x1c')]?_0x2ce0c6[_0xadda('0x1c')]['where']||null:null,'attributes':_0x2ce0c6[_0xadda('0x1c')]?_0x2ce0c6[_0xadda('0x1c')][_0xadda('0x1f')]||null:null,'include':_0x2ce0c6[_0xadda('0x1c')]?_0x2ce0c6[_0xadda('0x1c')][_0xadda('0x21')]?_[_0xadda('0x22')](_0x2ce0c6[_0xadda('0x1c')][_0xadda('0x21')],function(_0x5c25a2){return{'model':db[_0x5c25a2['model']],'as':_0x5c25a2['as'],'attributes':_0x5c25a2[_0xadda('0x1f')],'include':_0x5c25a2[_0xadda('0x21')]?_[_0xadda('0x22')](_0x5c25a2[_0xadda('0x21')],function(_0x172db5){return{'model':db[_0x172db5['model']],'as':_0x172db5['as'],'attributes':_0x172db5[_0xadda('0x1f')],'include':_0x172db5[_0xadda('0x21')]?_[_0xadda('0x22')](_0x172db5[_0xadda('0x21')],function(_0x896e08){return{'model':db[_0x896e08['model']],'as':_0x896e08['as'],'attributes':_0x896e08[_0xadda('0x1f')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x1f1149){logger[_0xadda('0x12')](_0xadda('0x24'),_0x2ce0c6);logger['debug'](_0xadda('0x24'),_0x2ce0c6,JSON[_0xadda('0x14')](_0x1f1149));_0xd195f2(_0x1f1149);})['catch'](function(_0x3e1d42){logger['error'](_0xadda('0x24'),_0x3e1d42[_0xadda('0x17')],_0x2ce0c6);_0x5701f5(_0x41f3fb['error'](0x1f4,_0x3e1d42['message']));});});};