c3683be662a76d1feb24d2e9bf86cbe26867a669
[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 _0x24b6=['debug','stringify','error','message','result','GetFaxQueue','FaxQueue','findAll','options','raw','where','limit','include','map','model','attributes','catch','ShowFaxQueue','find','info','lodash','util','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','./faxQueue.socket','register','request','then','FaxQueue,\x20%s,\x20%s','request\x20sent'];(function(_0x405362,_0x9f3d26){var _0x2fbf6e=function(_0x19529a){while(--_0x19529a){_0x405362['push'](_0x405362['shift']());}};_0x2fbf6e(++_0x9f3d26);}(_0x24b6,0x10a));var _0x624b=function(_0xacb183,_0x4aa875){_0xacb183=_0xacb183-0x0;var _0x1b4a89=_0x24b6[_0xacb183];return _0x1b4a89;};'use strict';var _=require(_0x624b('0x0'));var util=require(_0x624b('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x624b('0x2'));var fs=require('fs');var Redis=require(_0x624b('0x3'));var db=require(_0x624b('0x4'))['db'];var utils=require(_0x624b('0x5'));var logger=require(_0x624b('0x6'))(_0x624b('0x7'));var config=require(_0x624b('0x8'));var jayson=require(_0x624b('0x9'));var client=jayson[_0x624b('0xa')][_0x624b('0xb')]({'port':0x232a});config[_0x624b('0xc')]=_[_0x624b('0xd')](config['redis'],{'host':_0x624b('0xe'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x624b('0xf'))[_0x624b('0x10')](socket);function respondWithRpcPromise(_0x51ce90,_0x58fa37,_0x1aea89){return new BPromise(function(_0x60b6e9,_0x5a85ea){return client[_0x624b('0x11')](_0x51ce90,_0x1aea89)[_0x624b('0x12')](function(_0x5cf6ad){logger['info'](_0x624b('0x13'),_0x58fa37,_0x624b('0x14'));logger[_0x624b('0x15')]('FaxQueue,\x20%s,\x20%s,\x20%s',_0x58fa37,_0x624b('0x14'),JSON[_0x624b('0x16')](_0x5cf6ad));if(_0x5cf6ad[_0x624b('0x17')]){if(_0x5cf6ad[_0x624b('0x17')]['code']===0x1f4){logger[_0x624b('0x17')]('FaxQueue,\x20%s,\x20%s',_0x58fa37,_0x5cf6ad[_0x624b('0x17')]['message']);return _0x5a85ea(_0x5cf6ad[_0x624b('0x17')][_0x624b('0x18')]);}logger[_0x624b('0x17')](_0x624b('0x13'),_0x58fa37,_0x5cf6ad['error'][_0x624b('0x18')]);return _0x60b6e9(_0x5cf6ad[_0x624b('0x17')]['message']);}else{logger['info']('FaxQueue,\x20%s,\x20%s',_0x58fa37,'request\x20sent');_0x60b6e9(_0x5cf6ad[_0x624b('0x19')][_0x624b('0x18')]);}})['catch'](function(_0x161156){logger[_0x624b('0x17')](_0x624b('0x13'),_0x58fa37,_0x161156);_0x5a85ea(_0x161156);});});}exports[_0x624b('0x1a')]=function(_0xb31639){var _0x3c4f76=this;return new Promise(function(_0x4f0dcf,_0x50cfe8){return db[_0x624b('0x1b')][_0x624b('0x1c')]({'raw':_0xb31639[_0x624b('0x1d')]?_0xb31639['options'][_0x624b('0x1e')]===undefined?!![]:![]:!![],'where':_0xb31639[_0x624b('0x1d')]?_0xb31639[_0x624b('0x1d')][_0x624b('0x1f')]||null:null,'attributes':_0xb31639[_0x624b('0x1d')]?_0xb31639[_0x624b('0x1d')]['attributes']||null:null,'limit':_0xb31639[_0x624b('0x1d')]?_0xb31639[_0x624b('0x1d')][_0x624b('0x20')]||null:null,'include':_0xb31639['options']?_0xb31639['options'][_0x624b('0x21')]?_[_0x624b('0x22')](_0xb31639['options'][_0x624b('0x21')],function(_0x2295d7){return{'model':db[_0x2295d7[_0x624b('0x23')]],'as':_0x2295d7['as'],'attributes':_0x2295d7['attributes'],'include':_0x2295d7[_0x624b('0x21')]?_[_0x624b('0x22')](_0x2295d7[_0x624b('0x21')],function(_0x1a855a){return{'model':db[_0x1a855a['model']],'as':_0x1a855a['as'],'attributes':_0x1a855a[_0x624b('0x24')],'include':_0x1a855a[_0x624b('0x21')]?_['map'](_0x1a855a[_0x624b('0x21')],function(_0x2871f4){return{'model':db[_0x2871f4[_0x624b('0x23')]],'as':_0x2871f4['as'],'attributes':_0x2871f4['attributes']};}):[]};}):[]};}):[]:[]})[_0x624b('0x12')](function(_0x2d4019){logger['info'](_0x624b('0x1a'),_0xb31639);logger[_0x624b('0x15')](_0x624b('0x1a'),_0xb31639,JSON[_0x624b('0x16')](_0x2d4019));_0x4f0dcf(_0x2d4019);})[_0x624b('0x25')](function(_0x3815e6){logger[_0x624b('0x17')](_0x624b('0x1a'),_0x3815e6['message'],_0xb31639);_0x50cfe8(_0x3c4f76[_0x624b('0x17')](0x1f4,_0x3815e6[_0x624b('0x18')]));});});};exports[_0x624b('0x26')]=function(_0x567770){var _0x6c1282=this;return new Promise(function(_0xc1d860,_0x1177c9){return db[_0x624b('0x1b')][_0x624b('0x27')]({'raw':_0x567770[_0x624b('0x1d')]?_0x567770[_0x624b('0x1d')][_0x624b('0x1e')]===undefined?!![]:![]:!![],'where':_0x567770[_0x624b('0x1d')]?_0x567770['options']['where']||null:null,'attributes':_0x567770[_0x624b('0x1d')]?_0x567770[_0x624b('0x1d')][_0x624b('0x24')]||null:null,'include':_0x567770[_0x624b('0x1d')]?_0x567770['options'][_0x624b('0x21')]?_[_0x624b('0x22')](_0x567770['options'][_0x624b('0x21')],function(_0x522a65){return{'model':db[_0x522a65[_0x624b('0x23')]],'as':_0x522a65['as'],'attributes':_0x522a65['attributes'],'include':_0x522a65[_0x624b('0x21')]?_[_0x624b('0x22')](_0x522a65[_0x624b('0x21')],function(_0xcb6ff){return{'model':db[_0xcb6ff['model']],'as':_0xcb6ff['as'],'attributes':_0xcb6ff['attributes'],'include':_0xcb6ff[_0x624b('0x21')]?_[_0x624b('0x22')](_0xcb6ff[_0x624b('0x21')],function(_0x2843c0){return{'model':db[_0x2843c0[_0x624b('0x23')]],'as':_0x2843c0['as'],'attributes':_0x2843c0[_0x624b('0x24')]};}):[]};}):[]};}):[]:[]})[_0x624b('0x12')](function(_0x361789){logger[_0x624b('0x28')](_0x624b('0x26'),_0x567770);logger['debug'](_0x624b('0x26'),_0x567770,JSON[_0x624b('0x16')](_0x361789));_0xc1d860(_0x361789);})[_0x624b('0x25')](function(_0x59effa){logger[_0x624b('0x17')](_0x624b('0x26'),_0x59effa[_0x624b('0x18')],_0x567770);_0x1177c9(_0x6c1282['error'](0x1f4,_0x59effa[_0x624b('0x18')]));});});};