e1b12b0fd733ec84ecd65ba2c5fcffbf1b6494e7
[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 _0xb3f5=['then','info','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','attributes','limit','include','map','model','ShowFaxQueue','find','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','localhost','socket.io-emitter','./faxQueue.socket','request'];(function(_0x52326b,_0x50e99c){var _0x3b695f=function(_0x5cb88e){while(--_0x5cb88e){_0x52326b['push'](_0x52326b['shift']());}};_0x3b695f(++_0x50e99c);}(_0xb3f5,0xeb));var _0x5b3f=function(_0x14add3,_0x13ce8d){_0x14add3=_0x14add3-0x0;var _0x4a174f=_0xb3f5[_0x14add3];return _0x4a174f;};'use strict';var _=require(_0x5b3f('0x0'));var util=require(_0x5b3f('0x1'));var moment=require(_0x5b3f('0x2'));var BPromise=require(_0x5b3f('0x3'));var rs=require(_0x5b3f('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x5b3f('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x5b3f('0x6'))(_0x5b3f('0x7'));var config=require(_0x5b3f('0x8'));var jayson=require(_0x5b3f('0x9'));var client=jayson[_0x5b3f('0xa')][_0x5b3f('0xb')]({'port':0x232a});config[_0x5b3f('0xc')]=_['defaults'](config['redis'],{'host':_0x5b3f('0xd'),'port':0x18eb});var socket=require(_0x5b3f('0xe'))(new Redis(config[_0x5b3f('0xc')]));require(_0x5b3f('0xf'))['register'](socket);function respondWithRpcPromise(_0x3693ab,_0x266b13,_0xab8b47){return new BPromise(function(_0x2fa512,_0x2ce194){return client[_0x5b3f('0x10')](_0x3693ab,_0xab8b47)[_0x5b3f('0x11')](function(_0x2ae328){logger[_0x5b3f('0x12')](_0x5b3f('0x13'),_0x266b13,_0x5b3f('0x14'));logger[_0x5b3f('0x15')](_0x5b3f('0x16'),_0x266b13,'request\x20sent',JSON[_0x5b3f('0x17')](_0x2ae328));if(_0x2ae328[_0x5b3f('0x18')]){if(_0x2ae328['error'][_0x5b3f('0x19')]===0x1f4){logger[_0x5b3f('0x18')](_0x5b3f('0x13'),_0x266b13,_0x2ae328[_0x5b3f('0x18')][_0x5b3f('0x1a')]);return _0x2ce194(_0x2ae328['error'][_0x5b3f('0x1a')]);}logger[_0x5b3f('0x18')](_0x5b3f('0x13'),_0x266b13,_0x2ae328[_0x5b3f('0x18')][_0x5b3f('0x1a')]);return _0x2fa512(_0x2ae328[_0x5b3f('0x18')][_0x5b3f('0x1a')]);}else{logger[_0x5b3f('0x12')](_0x5b3f('0x13'),_0x266b13,'request\x20sent');_0x2fa512(_0x2ae328[_0x5b3f('0x1b')][_0x5b3f('0x1a')]);}})[_0x5b3f('0x1c')](function(_0x5bb8e0){logger[_0x5b3f('0x18')](_0x5b3f('0x13'),_0x266b13,_0x5bb8e0);_0x2ce194(_0x5bb8e0);});});}exports[_0x5b3f('0x1d')]=function(_0x50c07e){var _0x32dbd1=this;return new Promise(function(_0x304bc2,_0x1d44c0){return db[_0x5b3f('0x1e')][_0x5b3f('0x1f')]({'raw':_0x50c07e[_0x5b3f('0x20')]?_0x50c07e['options'][_0x5b3f('0x21')]===undefined?!![]:![]:!![],'where':_0x50c07e['options']?_0x50c07e['options'][_0x5b3f('0x22')]||null:null,'attributes':_0x50c07e[_0x5b3f('0x20')]?_0x50c07e[_0x5b3f('0x20')][_0x5b3f('0x23')]||null:null,'limit':_0x50c07e['options']?_0x50c07e[_0x5b3f('0x20')][_0x5b3f('0x24')]||null:null,'include':_0x50c07e['options']?_0x50c07e['options'][_0x5b3f('0x25')]?_[_0x5b3f('0x26')](_0x50c07e[_0x5b3f('0x20')][_0x5b3f('0x25')],function(_0x436328){return{'model':db[_0x436328[_0x5b3f('0x27')]],'as':_0x436328['as'],'attributes':_0x436328[_0x5b3f('0x23')],'include':_0x436328[_0x5b3f('0x25')]?_['map'](_0x436328[_0x5b3f('0x25')],function(_0x40cafe){return{'model':db[_0x40cafe[_0x5b3f('0x27')]],'as':_0x40cafe['as'],'attributes':_0x40cafe[_0x5b3f('0x23')],'include':_0x40cafe[_0x5b3f('0x25')]?_['map'](_0x40cafe[_0x5b3f('0x25')],function(_0x2a9664){return{'model':db[_0x2a9664[_0x5b3f('0x27')]],'as':_0x2a9664['as'],'attributes':_0x2a9664[_0x5b3f('0x23')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x535e4d){logger[_0x5b3f('0x12')]('GetFaxQueue',_0x50c07e);logger['debug'](_0x5b3f('0x1d'),_0x50c07e,JSON[_0x5b3f('0x17')](_0x535e4d));_0x304bc2(_0x535e4d);})[_0x5b3f('0x1c')](function(_0x13afd2){logger[_0x5b3f('0x18')]('GetFaxQueue',_0x13afd2[_0x5b3f('0x1a')],_0x50c07e);_0x1d44c0(_0x32dbd1['error'](0x1f4,_0x13afd2[_0x5b3f('0x1a')]));});});};exports[_0x5b3f('0x28')]=function(_0x3da258){var _0x26a62b=this;return new Promise(function(_0x313c67,_0x588221){return db[_0x5b3f('0x1e')][_0x5b3f('0x29')]({'raw':_0x3da258[_0x5b3f('0x20')]?_0x3da258[_0x5b3f('0x20')][_0x5b3f('0x21')]===undefined?!![]:![]:!![],'where':_0x3da258[_0x5b3f('0x20')]?_0x3da258[_0x5b3f('0x20')]['where']||null:null,'attributes':_0x3da258['options']?_0x3da258[_0x5b3f('0x20')]['attributes']||null:null,'include':_0x3da258[_0x5b3f('0x20')]?_0x3da258['options'][_0x5b3f('0x25')]?_[_0x5b3f('0x26')](_0x3da258['options'][_0x5b3f('0x25')],function(_0x5ee033){return{'model':db[_0x5ee033[_0x5b3f('0x27')]],'as':_0x5ee033['as'],'attributes':_0x5ee033[_0x5b3f('0x23')],'include':_0x5ee033[_0x5b3f('0x25')]?_[_0x5b3f('0x26')](_0x5ee033[_0x5b3f('0x25')],function(_0x46e72a){return{'model':db[_0x46e72a[_0x5b3f('0x27')]],'as':_0x46e72a['as'],'attributes':_0x46e72a[_0x5b3f('0x23')],'include':_0x46e72a[_0x5b3f('0x25')]?_[_0x5b3f('0x26')](_0x46e72a[_0x5b3f('0x25')],function(_0x42defc){return{'model':db[_0x42defc[_0x5b3f('0x27')]],'as':_0x42defc['as'],'attributes':_0x42defc[_0x5b3f('0x23')]};}):[]};}):[]};}):[]:[]})[_0x5b3f('0x11')](function(_0x17d4b5){logger[_0x5b3f('0x12')](_0x5b3f('0x28'),_0x3da258);logger[_0x5b3f('0x15')](_0x5b3f('0x28'),_0x3da258,JSON[_0x5b3f('0x17')](_0x17d4b5));_0x313c67(_0x17d4b5);})[_0x5b3f('0x1c')](function(_0x678531){logger[_0x5b3f('0x18')](_0x5b3f('0x28'),_0x678531['message'],_0x3da258);_0x588221(_0x26a62b[_0x5b3f('0x18')](0x1f4,_0x678531[_0x5b3f('0x1a')]));});});};