12fea04e6c98aaa66313821c839c5b5e27c4da4b
[motion2.git] / server / api / openchannelQueue / openchannelQueue.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 _0x689b=['./openchannelQueue.socket','register','then','info','debug','request\x20sent','error','code','OpenchannelQueue,\x20%s,\x20%s','message','GetOpenchannelQueue','OpenchannelQueue','findAll','options','raw','where','attributes','limit','include','map','model','stringify','catch','find','ShowOpenchannelQueue','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','client','redis','defaults','localhost'];(function(_0x12999b,_0xaf4592){var _0x1f2a8f=function(_0x1cc4ce){while(--_0x1cc4ce){_0x12999b['push'](_0x12999b['shift']());}};_0x1f2a8f(++_0xaf4592);}(_0x689b,0x1bb));var _0xb689=function(_0x507432,_0x4b0dfa){_0x507432=_0x507432-0x0;var _0x3c0f24=_0x689b[_0x507432];return _0x3c0f24;};'use strict';var _=require(_0xb689('0x0'));var util=require(_0xb689('0x1'));var moment=require(_0xb689('0x2'));var BPromise=require('bluebird');var rs=require(_0xb689('0x3'));var fs=require('fs');var Redis=require(_0xb689('0x4'));var db=require(_0xb689('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0xb689('0x6'))(_0xb689('0x7'));var config=require(_0xb689('0x8'));var jayson=require('jayson/promise');var client=jayson[_0xb689('0x9')]['http']({'port':0x232a});config[_0xb689('0xa')]=_[_0xb689('0xb')](config[_0xb689('0xa')],{'host':_0xb689('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xb689('0xa')]));require(_0xb689('0xd'))[_0xb689('0xe')](socket);function respondWithRpcPromise(_0x32c04e,_0x5c8310,_0x128bb4){return new BPromise(function(_0x38e56f,_0x460070){return client['request'](_0x32c04e,_0x128bb4)[_0xb689('0xf')](function(_0x38d8f7){logger[_0xb689('0x10')]('OpenchannelQueue,\x20%s,\x20%s',_0x5c8310,'request\x20sent');logger[_0xb689('0x11')]('OpenchannelQueue,\x20%s,\x20%s,\x20%s',_0x5c8310,_0xb689('0x12'),JSON['stringify'](_0x38d8f7));if(_0x38d8f7[_0xb689('0x13')]){if(_0x38d8f7[_0xb689('0x13')][_0xb689('0x14')]===0x1f4){logger['error'](_0xb689('0x15'),_0x5c8310,_0x38d8f7[_0xb689('0x13')][_0xb689('0x16')]);return _0x460070(_0x38d8f7[_0xb689('0x13')][_0xb689('0x16')]);}logger[_0xb689('0x13')](_0xb689('0x15'),_0x5c8310,_0x38d8f7[_0xb689('0x13')]['message']);return _0x38e56f(_0x38d8f7[_0xb689('0x13')][_0xb689('0x16')]);}else{logger[_0xb689('0x10')]('OpenchannelQueue,\x20%s,\x20%s',_0x5c8310,_0xb689('0x12'));_0x38e56f(_0x38d8f7['result'][_0xb689('0x16')]);}})['catch'](function(_0x155db9){logger[_0xb689('0x13')](_0xb689('0x15'),_0x5c8310,_0x155db9);_0x460070(_0x155db9);});});}exports[_0xb689('0x17')]=function(_0x3961b9){var _0x2ee884=this;return new Promise(function(_0x530123,_0x266a9e){return db[_0xb689('0x18')][_0xb689('0x19')]({'raw':_0x3961b9[_0xb689('0x1a')]?_0x3961b9[_0xb689('0x1a')][_0xb689('0x1b')]===undefined?!![]:![]:!![],'where':_0x3961b9[_0xb689('0x1a')]?_0x3961b9[_0xb689('0x1a')][_0xb689('0x1c')]||null:null,'attributes':_0x3961b9[_0xb689('0x1a')]?_0x3961b9[_0xb689('0x1a')][_0xb689('0x1d')]||null:null,'limit':_0x3961b9['options']?_0x3961b9[_0xb689('0x1a')][_0xb689('0x1e')]||null:null,'include':_0x3961b9[_0xb689('0x1a')]?_0x3961b9['options'][_0xb689('0x1f')]?_[_0xb689('0x20')](_0x3961b9[_0xb689('0x1a')][_0xb689('0x1f')],function(_0x5676e8){return{'model':db[_0x5676e8['model']],'as':_0x5676e8['as'],'attributes':_0x5676e8[_0xb689('0x1d')],'include':_0x5676e8[_0xb689('0x1f')]?_[_0xb689('0x20')](_0x5676e8['include'],function(_0x57dbaf){return{'model':db[_0x57dbaf[_0xb689('0x21')]],'as':_0x57dbaf['as'],'attributes':_0x57dbaf[_0xb689('0x1d')],'include':_0x57dbaf[_0xb689('0x1f')]?_[_0xb689('0x20')](_0x57dbaf[_0xb689('0x1f')],function(_0x2f72b1){return{'model':db[_0x2f72b1[_0xb689('0x21')]],'as':_0x2f72b1['as'],'attributes':_0x2f72b1['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x1e5c04){logger[_0xb689('0x10')](_0xb689('0x17'),_0x3961b9);logger[_0xb689('0x11')]('GetOpenchannelQueue',_0x3961b9,JSON[_0xb689('0x22')](_0x1e5c04));_0x530123(_0x1e5c04);})[_0xb689('0x23')](function(_0x2b09a5){logger[_0xb689('0x13')](_0xb689('0x17'),_0x2b09a5['message'],_0x3961b9);_0x266a9e(_0x2ee884['error'](0x1f4,_0x2b09a5[_0xb689('0x16')]));});});};exports['ShowOpenchannelQueue']=function(_0x4ce274){var _0x5f2413=this;return new Promise(function(_0x56ca24,_0x469ea8){return db[_0xb689('0x18')][_0xb689('0x24')]({'raw':_0x4ce274[_0xb689('0x1a')]?_0x4ce274[_0xb689('0x1a')][_0xb689('0x1b')]===undefined?!![]:![]:!![],'where':_0x4ce274[_0xb689('0x1a')]?_0x4ce274[_0xb689('0x1a')][_0xb689('0x1c')]||null:null,'attributes':_0x4ce274['options']?_0x4ce274[_0xb689('0x1a')]['attributes']||null:null,'include':_0x4ce274[_0xb689('0x1a')]?_0x4ce274[_0xb689('0x1a')][_0xb689('0x1f')]?_['map'](_0x4ce274[_0xb689('0x1a')][_0xb689('0x1f')],function(_0x42c264){return{'model':db[_0x42c264[_0xb689('0x21')]],'as':_0x42c264['as'],'attributes':_0x42c264['attributes'],'include':_0x42c264[_0xb689('0x1f')]?_[_0xb689('0x20')](_0x42c264['include'],function(_0x29079d){return{'model':db[_0x29079d[_0xb689('0x21')]],'as':_0x29079d['as'],'attributes':_0x29079d['attributes'],'include':_0x29079d['include']?_[_0xb689('0x20')](_0x29079d[_0xb689('0x1f')],function(_0x4499a0){return{'model':db[_0x4499a0[_0xb689('0x21')]],'as':_0x4499a0['as'],'attributes':_0x4499a0[_0xb689('0x1d')]};}):[]};}):[]};}):[]:[]})[_0xb689('0xf')](function(_0x4295a9){logger[_0xb689('0x10')]('ShowOpenchannelQueue',_0x4ce274);logger[_0xb689('0x11')](_0xb689('0x25'),_0x4ce274,JSON[_0xb689('0x22')](_0x4295a9));_0x56ca24(_0x4295a9);})[_0xb689('0x23')](function(_0x15bb45){logger[_0xb689('0x13')](_0xb689('0x25'),_0x15bb45[_0xb689('0x16')],_0x4ce274);_0x469ea8(_0x5f2413[_0xb689('0x13')](0x1f4,_0x15bb45['message']));});});};