3a86c43ea49f22810c306d99ee1a9451b4bc1af7
[motion2.git] / server / api / voiceQueue / voiceQueue.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 _0x72cb=['catch','GetVoiceQueue','options','raw','where','attributes','limit','include','map','model','then','ShowVoiceQueue','VoiceQueue','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','redis','defaults','socket.io-emitter','./voiceQueue.socket','register','info','VoiceQueue,\x20%s,\x20%s','request\x20sent','debug','VoiceQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message'];(function(_0x36ae06,_0x57da2d){var _0x25ffc7=function(_0x38be3a){while(--_0x38be3a){_0x36ae06['push'](_0x36ae06['shift']());}};_0x25ffc7(++_0x57da2d);}(_0x72cb,0x11e));var _0xb72c=function(_0x29c2f7,_0x1ffb8b){_0x29c2f7=_0x29c2f7-0x0;var _0x3582e6=_0x72cb[_0x29c2f7];return _0x3582e6;};'use strict';var _=require(_0xb72c('0x0'));var util=require(_0xb72c('0x1'));var moment=require(_0xb72c('0x2'));var BPromise=require(_0xb72c('0x3'));var rs=require(_0xb72c('0x4'));var fs=require('fs');var Redis=require(_0xb72c('0x5'));var db=require(_0xb72c('0x6'))['db'];var utils=require(_0xb72c('0x7'));var logger=require('../../config/logger')(_0xb72c('0x8'));var config=require(_0xb72c('0x9'));var jayson=require(_0xb72c('0xa'));var client=jayson[_0xb72c('0xb')]['http']({'port':0x232a});config[_0xb72c('0xc')]=_[_0xb72c('0xd')](config[_0xb72c('0xc')],{'host':'localhost','port':0x18eb});var socket=require(_0xb72c('0xe'))(new Redis(config['redis']));require(_0xb72c('0xf'))[_0xb72c('0x10')](socket);function respondWithRpcPromise(_0x1c2bf0,_0xdd8786,_0x2a7da5){return new BPromise(function(_0x111b3c,_0x243568){return client['request'](_0x1c2bf0,_0x2a7da5)['then'](function(_0x4f83ad){logger[_0xb72c('0x11')](_0xb72c('0x12'),_0xdd8786,_0xb72c('0x13'));logger[_0xb72c('0x14')](_0xb72c('0x15'),_0xdd8786,_0xb72c('0x13'),JSON[_0xb72c('0x16')](_0x4f83ad));if(_0x4f83ad[_0xb72c('0x17')]){if(_0x4f83ad['error'][_0xb72c('0x18')]===0x1f4){logger['error'](_0xb72c('0x12'),_0xdd8786,_0x4f83ad[_0xb72c('0x17')][_0xb72c('0x19')]);return _0x243568(_0x4f83ad[_0xb72c('0x17')][_0xb72c('0x19')]);}logger[_0xb72c('0x17')](_0xb72c('0x12'),_0xdd8786,_0x4f83ad[_0xb72c('0x17')][_0xb72c('0x19')]);return _0x111b3c(_0x4f83ad[_0xb72c('0x17')][_0xb72c('0x19')]);}else{logger[_0xb72c('0x11')](_0xb72c('0x12'),_0xdd8786,'request\x20sent');_0x111b3c(_0x4f83ad['result'][_0xb72c('0x19')]);}})[_0xb72c('0x1a')](function(_0x3347f3){logger[_0xb72c('0x17')]('VoiceQueue,\x20%s,\x20%s',_0xdd8786,_0x3347f3);_0x243568(_0x3347f3);});});}exports[_0xb72c('0x1b')]=function(_0x545aab){var _0x5e268f=this;return new Promise(function(_0x49c146,_0x2d79fa){return db['VoiceQueue']['findAll']({'raw':_0x545aab[_0xb72c('0x1c')]?_0x545aab[_0xb72c('0x1c')][_0xb72c('0x1d')]===undefined?!![]:![]:!![],'where':_0x545aab[_0xb72c('0x1c')]?_0x545aab[_0xb72c('0x1c')][_0xb72c('0x1e')]||null:null,'attributes':_0x545aab[_0xb72c('0x1c')]?_0x545aab[_0xb72c('0x1c')][_0xb72c('0x1f')]||null:null,'limit':_0x545aab[_0xb72c('0x1c')]?_0x545aab[_0xb72c('0x1c')][_0xb72c('0x20')]||null:null,'include':_0x545aab[_0xb72c('0x1c')]?_0x545aab[_0xb72c('0x1c')][_0xb72c('0x21')]?_[_0xb72c('0x22')](_0x545aab[_0xb72c('0x1c')][_0xb72c('0x21')],function(_0x4175ec){return{'model':db[_0x4175ec['model']],'as':_0x4175ec['as'],'attributes':_0x4175ec[_0xb72c('0x1f')],'include':_0x4175ec['include']?_[_0xb72c('0x22')](_0x4175ec[_0xb72c('0x21')],function(_0x3fb23c){return{'model':db[_0x3fb23c[_0xb72c('0x23')]],'as':_0x3fb23c['as'],'attributes':_0x3fb23c[_0xb72c('0x1f')],'include':_0x3fb23c[_0xb72c('0x21')]?_[_0xb72c('0x22')](_0x3fb23c[_0xb72c('0x21')],function(_0x1adaa2){return{'model':db[_0x1adaa2[_0xb72c('0x23')]],'as':_0x1adaa2['as'],'attributes':_0x1adaa2[_0xb72c('0x1f')]};}):[]};}):[]};}):[]:[]})[_0xb72c('0x24')](function(_0x390158){logger[_0xb72c('0x11')](_0xb72c('0x1b'),_0x545aab);logger['debug'](_0xb72c('0x1b'),_0x545aab,JSON[_0xb72c('0x16')](_0x390158));_0x49c146(_0x390158);})[_0xb72c('0x1a')](function(_0x4a83ec){logger[_0xb72c('0x17')](_0xb72c('0x1b'),_0x4a83ec[_0xb72c('0x19')],_0x545aab);_0x2d79fa(_0x5e268f[_0xb72c('0x17')](0x1f4,_0x4a83ec[_0xb72c('0x19')]));});});};exports[_0xb72c('0x25')]=function(_0x5443b1){var _0x3d056a=this;return new Promise(function(_0x2f1fbb,_0xdaec4){return db[_0xb72c('0x26')]['find']({'raw':_0x5443b1[_0xb72c('0x1c')]?_0x5443b1['options'][_0xb72c('0x1d')]===undefined?!![]:![]:!![],'where':_0x5443b1['options']?_0x5443b1['options'][_0xb72c('0x1e')]||null:null,'attributes':_0x5443b1[_0xb72c('0x1c')]?_0x5443b1[_0xb72c('0x1c')]['attributes']||null:null,'include':_0x5443b1[_0xb72c('0x1c')]?_0x5443b1[_0xb72c('0x1c')][_0xb72c('0x21')]?_[_0xb72c('0x22')](_0x5443b1[_0xb72c('0x1c')][_0xb72c('0x21')],function(_0x3d676b){return{'model':db[_0x3d676b[_0xb72c('0x23')]],'as':_0x3d676b['as'],'attributes':_0x3d676b[_0xb72c('0x1f')],'include':_0x3d676b['include']?_[_0xb72c('0x22')](_0x3d676b[_0xb72c('0x21')],function(_0x3b63b0){return{'model':db[_0x3b63b0['model']],'as':_0x3b63b0['as'],'attributes':_0x3b63b0[_0xb72c('0x1f')],'include':_0x3b63b0['include']?_[_0xb72c('0x22')](_0x3b63b0[_0xb72c('0x21')],function(_0x35ad37){return{'model':db[_0x35ad37[_0xb72c('0x23')]],'as':_0x35ad37['as'],'attributes':_0x35ad37['attributes']};}):[]};}):[]};}):[]:[]})[_0xb72c('0x24')](function(_0x2183c7){logger['info'](_0xb72c('0x25'),_0x5443b1);logger[_0xb72c('0x14')](_0xb72c('0x25'),_0x5443b1,JSON[_0xb72c('0x16')](_0x2183c7));_0x2f1fbb(_0x2183c7);})[_0xb72c('0x1a')](function(_0x3f3f09){logger[_0xb72c('0x17')]('ShowVoiceQueue',_0x3f3f09['message'],_0x5443b1);_0xdaec4(_0x3d056a[_0xb72c('0x17')](0x1f4,_0x3f3f09[_0xb72c('0x19')]));});});};