c3fd68d5c8a6d2d44d0e1f0e794a1633b0d56e91
[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 _0xf833=['http','redis','defaults','localhost','./faxQueue.socket','register','request','then','info','request\x20sent','debug','FaxQueue,\x20%s,\x20%s,\x20%s','stringify','error','message','FaxQueue,\x20%s,\x20%s','result','catch','GetFaxQueue','FaxQueue','options','raw','where','attributes','include','map','model','ShowFaxQueue','find','util','bluebird','randomstring','../../mysqldb','rpc','../../config/environment','jayson/promise','client'];(function(_0x38af12,_0x81905e){var _0x37d48e=function(_0x2a25c8){while(--_0x2a25c8){_0x38af12['push'](_0x38af12['shift']());}};_0x37d48e(++_0x81905e);}(_0xf833,0x1b4));var _0x3f83=function(_0x253454,_0x262b56){_0x253454=_0x253454-0x0;var _0x1aff02=_0xf833[_0x253454];return _0x1aff02;};'use strict';var _=require('lodash');var util=require(_0x3f83('0x0'));var moment=require('moment');var BPromise=require(_0x3f83('0x1'));var rs=require(_0x3f83('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x3f83('0x3'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x3f83('0x4'));var config=require(_0x3f83('0x5'));var jayson=require(_0x3f83('0x6'));var client=jayson[_0x3f83('0x7')][_0x3f83('0x8')]({'port':0x232a});config[_0x3f83('0x9')]=_[_0x3f83('0xa')](config[_0x3f83('0x9')],{'host':_0x3f83('0xb'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x3f83('0xc'))[_0x3f83('0xd')](socket);function respondWithRpcPromise(_0x3a811e,_0x1f5c2d,_0x5d1df9){return new BPromise(function(_0x40cf02,_0x4e381a){return client[_0x3f83('0xe')](_0x3a811e,_0x5d1df9)[_0x3f83('0xf')](function(_0x215773){logger[_0x3f83('0x10')]('FaxQueue,\x20%s,\x20%s',_0x1f5c2d,_0x3f83('0x11'));logger[_0x3f83('0x12')](_0x3f83('0x13'),_0x1f5c2d,_0x3f83('0x11'),JSON[_0x3f83('0x14')](_0x215773));if(_0x215773[_0x3f83('0x15')]){if(_0x215773[_0x3f83('0x15')]['code']===0x1f4){logger[_0x3f83('0x15')]('FaxQueue,\x20%s,\x20%s',_0x1f5c2d,_0x215773[_0x3f83('0x15')][_0x3f83('0x16')]);return _0x4e381a(_0x215773[_0x3f83('0x15')][_0x3f83('0x16')]);}logger[_0x3f83('0x15')]('FaxQueue,\x20%s,\x20%s',_0x1f5c2d,_0x215773[_0x3f83('0x15')]['message']);return _0x40cf02(_0x215773[_0x3f83('0x15')]['message']);}else{logger['info'](_0x3f83('0x17'),_0x1f5c2d,_0x3f83('0x11'));_0x40cf02(_0x215773[_0x3f83('0x18')][_0x3f83('0x16')]);}})[_0x3f83('0x19')](function(_0x2b2649){logger[_0x3f83('0x15')](_0x3f83('0x17'),_0x1f5c2d,_0x2b2649);_0x4e381a(_0x2b2649);});});}exports[_0x3f83('0x1a')]=function(_0x10701c){var _0x14bdb9=this;return new Promise(function(_0x3a13c5,_0x2063e0){return db[_0x3f83('0x1b')]['findAll']({'raw':_0x10701c['options']?_0x10701c[_0x3f83('0x1c')][_0x3f83('0x1d')]===undefined?!![]:![]:!![],'where':_0x10701c[_0x3f83('0x1c')]?_0x10701c[_0x3f83('0x1c')][_0x3f83('0x1e')]||null:null,'attributes':_0x10701c[_0x3f83('0x1c')]?_0x10701c['options'][_0x3f83('0x1f')]||null:null,'limit':_0x10701c['options']?_0x10701c[_0x3f83('0x1c')]['limit']||null:null,'include':_0x10701c[_0x3f83('0x1c')]?_0x10701c[_0x3f83('0x1c')][_0x3f83('0x20')]?_[_0x3f83('0x21')](_0x10701c[_0x3f83('0x1c')][_0x3f83('0x20')],function(_0x305d45){return{'model':db[_0x305d45[_0x3f83('0x22')]],'as':_0x305d45['as'],'attributes':_0x305d45['attributes'],'include':_0x305d45['include']?_[_0x3f83('0x21')](_0x305d45[_0x3f83('0x20')],function(_0x115b5b){return{'model':db[_0x115b5b[_0x3f83('0x22')]],'as':_0x115b5b['as'],'attributes':_0x115b5b[_0x3f83('0x1f')],'include':_0x115b5b[_0x3f83('0x20')]?_[_0x3f83('0x21')](_0x115b5b[_0x3f83('0x20')],function(_0x40dcc4){return{'model':db[_0x40dcc4[_0x3f83('0x22')]],'as':_0x40dcc4['as'],'attributes':_0x40dcc4[_0x3f83('0x1f')]};}):[]};}):[]};}):[]:[]})[_0x3f83('0xf')](function(_0x1fa63f){logger['info'](_0x3f83('0x1a'),_0x10701c);logger['debug'](_0x3f83('0x1a'),_0x10701c,JSON['stringify'](_0x1fa63f));_0x3a13c5(_0x1fa63f);})[_0x3f83('0x19')](function(_0x335066){logger[_0x3f83('0x15')](_0x3f83('0x1a'),_0x335066[_0x3f83('0x16')],_0x10701c);_0x2063e0(_0x14bdb9[_0x3f83('0x15')](0x1f4,_0x335066[_0x3f83('0x16')]));});});};exports[_0x3f83('0x23')]=function(_0xb3b6be){var _0x2feb03=this;return new Promise(function(_0x5483d7,_0x515c77){return db[_0x3f83('0x1b')][_0x3f83('0x24')]({'raw':_0xb3b6be['options']?_0xb3b6be[_0x3f83('0x1c')][_0x3f83('0x1d')]===undefined?!![]:![]:!![],'where':_0xb3b6be[_0x3f83('0x1c')]?_0xb3b6be[_0x3f83('0x1c')]['where']||null:null,'attributes':_0xb3b6be[_0x3f83('0x1c')]?_0xb3b6be[_0x3f83('0x1c')][_0x3f83('0x1f')]||null:null,'include':_0xb3b6be['options']?_0xb3b6be[_0x3f83('0x1c')][_0x3f83('0x20')]?_[_0x3f83('0x21')](_0xb3b6be['options']['include'],function(_0x526827){return{'model':db[_0x526827[_0x3f83('0x22')]],'as':_0x526827['as'],'attributes':_0x526827[_0x3f83('0x1f')],'include':_0x526827[_0x3f83('0x20')]?_[_0x3f83('0x21')](_0x526827[_0x3f83('0x20')],function(_0x215343){return{'model':db[_0x215343[_0x3f83('0x22')]],'as':_0x215343['as'],'attributes':_0x215343[_0x3f83('0x1f')],'include':_0x215343[_0x3f83('0x20')]?_[_0x3f83('0x21')](_0x215343[_0x3f83('0x20')],function(_0x19175c){return{'model':db[_0x19175c[_0x3f83('0x22')]],'as':_0x19175c['as'],'attributes':_0x19175c['attributes']};}):[]};}):[]};}):[]:[]})[_0x3f83('0xf')](function(_0xd1545a){logger['info']('ShowFaxQueue',_0xb3b6be);logger[_0x3f83('0x12')](_0x3f83('0x23'),_0xb3b6be,JSON[_0x3f83('0x14')](_0xd1545a));_0x5483d7(_0xd1545a);})[_0x3f83('0x19')](function(_0x511258){logger[_0x3f83('0x15')](_0x3f83('0x23'),_0x511258[_0x3f83('0x16')],_0xb3b6be);_0x515c77(_0x2feb03['error'](0x1f4,_0x511258[_0x3f83('0x16')]));});});};