95ca94d6a5376a6ef60979a27bd138073efc49ce
[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 _0x4ae4=['error','code','message','result','catch','GetFaxQueue','FaxQueue','findAll','options','attributes','limit','include','map','model','stringify','ShowFaxQueue','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','rpc','../../config/environment','jayson/promise','client','redis','defaults','socket.io-emitter','./faxQueue.socket','then','info','FaxQueue,\x20%s,\x20%s','request\x20sent','debug','FaxQueue,\x20%s,\x20%s,\x20%s'];(function(_0x17a18d,_0xd61f41){var _0x3b5cc9=function(_0x463818){while(--_0x463818){_0x17a18d['push'](_0x17a18d['shift']());}};_0x3b5cc9(++_0xd61f41);}(_0x4ae4,0x1cc));var _0x44ae=function(_0x4eec9b,_0x4aea09){_0x4eec9b=_0x4eec9b-0x0;var _0x2e3849=_0x4ae4[_0x4eec9b];return _0x2e3849;};'use strict';var _=require(_0x44ae('0x0'));var util=require(_0x44ae('0x1'));var moment=require(_0x44ae('0x2'));var BPromise=require(_0x44ae('0x3'));var rs=require(_0x44ae('0x4'));var fs=require('fs');var Redis=require(_0x44ae('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0x44ae('0x6'));var logger=require('../../config/logger')(_0x44ae('0x7'));var config=require(_0x44ae('0x8'));var jayson=require(_0x44ae('0x9'));var client=jayson[_0x44ae('0xa')]['http']({'port':0x232a});config[_0x44ae('0xb')]=_[_0x44ae('0xc')](config[_0x44ae('0xb')],{'host':'localhost','port':0x18eb});var socket=require(_0x44ae('0xd'))(new Redis(config[_0x44ae('0xb')]));require(_0x44ae('0xe'))['register'](socket);function respondWithRpcPromise(_0x36a081,_0x207545,_0x3ea837){return new BPromise(function(_0x3a92ce,_0x1effef){return client['request'](_0x36a081,_0x3ea837)[_0x44ae('0xf')](function(_0x447634){logger[_0x44ae('0x10')](_0x44ae('0x11'),_0x207545,_0x44ae('0x12'));logger[_0x44ae('0x13')](_0x44ae('0x14'),_0x207545,_0x44ae('0x12'),JSON['stringify'](_0x447634));if(_0x447634[_0x44ae('0x15')]){if(_0x447634[_0x44ae('0x15')][_0x44ae('0x16')]===0x1f4){logger[_0x44ae('0x15')](_0x44ae('0x11'),_0x207545,_0x447634['error'][_0x44ae('0x17')]);return _0x1effef(_0x447634[_0x44ae('0x15')][_0x44ae('0x17')]);}logger[_0x44ae('0x15')]('FaxQueue,\x20%s,\x20%s',_0x207545,_0x447634[_0x44ae('0x15')][_0x44ae('0x17')]);return _0x3a92ce(_0x447634['error']['message']);}else{logger[_0x44ae('0x10')]('FaxQueue,\x20%s,\x20%s',_0x207545,_0x44ae('0x12'));_0x3a92ce(_0x447634[_0x44ae('0x18')][_0x44ae('0x17')]);}})[_0x44ae('0x19')](function(_0x325509){logger[_0x44ae('0x15')]('FaxQueue,\x20%s,\x20%s',_0x207545,_0x325509);_0x1effef(_0x325509);});});}exports[_0x44ae('0x1a')]=function(_0x772a23){var _0x58dacf=this;return new Promise(function(_0x46892f,_0x2bd995){return db[_0x44ae('0x1b')][_0x44ae('0x1c')]({'raw':_0x772a23['options']?_0x772a23[_0x44ae('0x1d')]['raw']===undefined?!![]:![]:!![],'where':_0x772a23[_0x44ae('0x1d')]?_0x772a23['options']['where']||null:null,'attributes':_0x772a23['options']?_0x772a23['options'][_0x44ae('0x1e')]||null:null,'limit':_0x772a23[_0x44ae('0x1d')]?_0x772a23['options'][_0x44ae('0x1f')]||null:null,'include':_0x772a23['options']?_0x772a23['options'][_0x44ae('0x20')]?_[_0x44ae('0x21')](_0x772a23[_0x44ae('0x1d')][_0x44ae('0x20')],function(_0x57dd4a){return{'model':db[_0x57dd4a['model']],'as':_0x57dd4a['as'],'attributes':_0x57dd4a[_0x44ae('0x1e')],'include':_0x57dd4a['include']?_[_0x44ae('0x21')](_0x57dd4a[_0x44ae('0x20')],function(_0x4b3342){return{'model':db[_0x4b3342['model']],'as':_0x4b3342['as'],'attributes':_0x4b3342[_0x44ae('0x1e')],'include':_0x4b3342[_0x44ae('0x20')]?_[_0x44ae('0x21')](_0x4b3342[_0x44ae('0x20')],function(_0x2f64bf){return{'model':db[_0x2f64bf[_0x44ae('0x22')]],'as':_0x2f64bf['as'],'attributes':_0x2f64bf[_0x44ae('0x1e')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x4faef7){logger[_0x44ae('0x10')](_0x44ae('0x1a'),_0x772a23);logger['debug'](_0x44ae('0x1a'),_0x772a23,JSON[_0x44ae('0x23')](_0x4faef7));_0x46892f(_0x4faef7);})['catch'](function(_0xf5fda4){logger[_0x44ae('0x15')]('GetFaxQueue',_0xf5fda4[_0x44ae('0x17')],_0x772a23);_0x2bd995(_0x58dacf[_0x44ae('0x15')](0x1f4,_0xf5fda4[_0x44ae('0x17')]));});});};exports[_0x44ae('0x24')]=function(_0x52ecdd){var _0x9fad8c=this;return new Promise(function(_0x36f5bb,_0x5160ec){return db[_0x44ae('0x1b')]['find']({'raw':_0x52ecdd[_0x44ae('0x1d')]?_0x52ecdd['options']['raw']===undefined?!![]:![]:!![],'where':_0x52ecdd['options']?_0x52ecdd[_0x44ae('0x1d')]['where']||null:null,'attributes':_0x52ecdd[_0x44ae('0x1d')]?_0x52ecdd['options'][_0x44ae('0x1e')]||null:null,'include':_0x52ecdd['options']?_0x52ecdd[_0x44ae('0x1d')][_0x44ae('0x20')]?_[_0x44ae('0x21')](_0x52ecdd[_0x44ae('0x1d')][_0x44ae('0x20')],function(_0x3e1416){return{'model':db[_0x3e1416[_0x44ae('0x22')]],'as':_0x3e1416['as'],'attributes':_0x3e1416[_0x44ae('0x1e')],'include':_0x3e1416[_0x44ae('0x20')]?_['map'](_0x3e1416[_0x44ae('0x20')],function(_0x3c1537){return{'model':db[_0x3c1537['model']],'as':_0x3c1537['as'],'attributes':_0x3c1537[_0x44ae('0x1e')],'include':_0x3c1537[_0x44ae('0x20')]?_['map'](_0x3c1537[_0x44ae('0x20')],function(_0x39894d){return{'model':db[_0x39894d[_0x44ae('0x22')]],'as':_0x39894d['as'],'attributes':_0x39894d[_0x44ae('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x44ae('0xf')](function(_0x202f7f){logger['info'](_0x44ae('0x24'),_0x52ecdd);logger['debug'](_0x44ae('0x24'),_0x52ecdd,JSON[_0x44ae('0x23')](_0x202f7f));_0x36f5bb(_0x202f7f);})[_0x44ae('0x19')](function(_0x259279){logger[_0x44ae('0x15')](_0x44ae('0x24'),_0x259279['message'],_0x52ecdd);_0x5160ec(_0x9fad8c[_0x44ae('0x15')](0x1f4,_0x259279[_0x44ae('0x17')]));});});};