Built motion from commit f3da74b7.|2.5.36
[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 _0x5534=['raw','where','limit','map','include','model','attributes','find','debug','ShowVoiceQueue','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./voiceQueue.socket','request','then','info','VoiceQueue,\x20%s,\x20%s','VoiceQueue,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','message','catch','GetVoiceQueue','options'];(function(_0x33ae6b,_0x504857){var _0x4e1e44=function(_0x308792){while(--_0x308792){_0x33ae6b['push'](_0x33ae6b['shift']());}};_0x4e1e44(++_0x504857);}(_0x5534,0x122));var _0x4553=function(_0x274683,_0x579095){_0x274683=_0x274683-0x0;var _0x5e6b32=_0x5534[_0x274683];return _0x5e6b32;};'use strict';var _=require(_0x4553('0x0'));var util=require('util');var moment=require(_0x4553('0x1'));var BPromise=require(_0x4553('0x2'));var rs=require(_0x4553('0x3'));var fs=require('fs');var Redis=require(_0x4553('0x4'));var db=require(_0x4553('0x5'))['db'];var utils=require(_0x4553('0x6'));var logger=require(_0x4553('0x7'))(_0x4553('0x8'));var config=require(_0x4553('0x9'));var jayson=require(_0x4553('0xa'));var client=jayson[_0x4553('0xb')][_0x4553('0xc')]({'port':0x232a});config[_0x4553('0xd')]=_[_0x4553('0xe')](config[_0x4553('0xd')],{'host':_0x4553('0xf'),'port':0x18eb});var socket=require(_0x4553('0x10'))(new Redis(config[_0x4553('0xd')]));require(_0x4553('0x11'))['register'](socket);function respondWithRpcPromise(_0x29f243,_0x3e92aa,_0x55a2e4){return new BPromise(function(_0x149c29,_0x47560a){return client[_0x4553('0x12')](_0x29f243,_0x55a2e4)[_0x4553('0x13')](function(_0x23110b){logger[_0x4553('0x14')](_0x4553('0x15'),_0x3e92aa,'request\x20sent');logger['debug'](_0x4553('0x16'),_0x3e92aa,_0x4553('0x17'),JSON[_0x4553('0x18')](_0x23110b));if(_0x23110b[_0x4553('0x19')]){if(_0x23110b[_0x4553('0x19')]['code']===0x1f4){logger[_0x4553('0x19')]('VoiceQueue,\x20%s,\x20%s',_0x3e92aa,_0x23110b['error'][_0x4553('0x1a')]);return _0x47560a(_0x23110b[_0x4553('0x19')][_0x4553('0x1a')]);}logger['error'](_0x4553('0x15'),_0x3e92aa,_0x23110b[_0x4553('0x19')]['message']);return _0x149c29(_0x23110b[_0x4553('0x19')][_0x4553('0x1a')]);}else{logger['info'](_0x4553('0x15'),_0x3e92aa,'request\x20sent');_0x149c29(_0x23110b['result'][_0x4553('0x1a')]);}})[_0x4553('0x1b')](function(_0x2d7e98){logger[_0x4553('0x19')](_0x4553('0x15'),_0x3e92aa,_0x2d7e98);_0x47560a(_0x2d7e98);});});}exports[_0x4553('0x1c')]=function(_0x533d07){var _0x762bd5=this;return new Promise(function(_0x2cc16e,_0x106fa1){return db['VoiceQueue']['findAll']({'raw':_0x533d07[_0x4553('0x1d')]?_0x533d07[_0x4553('0x1d')][_0x4553('0x1e')]===undefined?!![]:![]:!![],'where':_0x533d07[_0x4553('0x1d')]?_0x533d07[_0x4553('0x1d')][_0x4553('0x1f')]||null:null,'attributes':_0x533d07['options']?_0x533d07[_0x4553('0x1d')]['attributes']||null:null,'limit':_0x533d07[_0x4553('0x1d')]?_0x533d07['options'][_0x4553('0x20')]||null:null,'include':_0x533d07[_0x4553('0x1d')]?_0x533d07[_0x4553('0x1d')]['include']?_[_0x4553('0x21')](_0x533d07['options'][_0x4553('0x22')],function(_0x1ad517){return{'model':db[_0x1ad517[_0x4553('0x23')]],'as':_0x1ad517['as'],'attributes':_0x1ad517[_0x4553('0x24')],'include':_0x1ad517[_0x4553('0x22')]?_['map'](_0x1ad517[_0x4553('0x22')],function(_0x32c57a){return{'model':db[_0x32c57a[_0x4553('0x23')]],'as':_0x32c57a['as'],'attributes':_0x32c57a[_0x4553('0x24')],'include':_0x32c57a[_0x4553('0x22')]?_[_0x4553('0x21')](_0x32c57a['include'],function(_0x5b30f8){return{'model':db[_0x5b30f8[_0x4553('0x23')]],'as':_0x5b30f8['as'],'attributes':_0x5b30f8['attributes']};}):[]};}):[]};}):[]:[]})[_0x4553('0x13')](function(_0x2f4961){logger[_0x4553('0x14')](_0x4553('0x1c'),_0x533d07);logger['debug'](_0x4553('0x1c'),_0x533d07,JSON[_0x4553('0x18')](_0x2f4961));_0x2cc16e(_0x2f4961);})[_0x4553('0x1b')](function(_0x5cdb7c){logger[_0x4553('0x19')]('GetVoiceQueue',_0x5cdb7c[_0x4553('0x1a')],_0x533d07);_0x106fa1(_0x762bd5[_0x4553('0x19')](0x1f4,_0x5cdb7c[_0x4553('0x1a')]));});});};exports['ShowVoiceQueue']=function(_0x539010){var _0x155564=this;return new Promise(function(_0x56614e,_0x495c34){return db['VoiceQueue'][_0x4553('0x25')]({'raw':_0x539010['options']?_0x539010[_0x4553('0x1d')][_0x4553('0x1e')]===undefined?!![]:![]:!![],'where':_0x539010['options']?_0x539010[_0x4553('0x1d')][_0x4553('0x1f')]||null:null,'attributes':_0x539010[_0x4553('0x1d')]?_0x539010[_0x4553('0x1d')][_0x4553('0x24')]||null:null,'include':_0x539010[_0x4553('0x1d')]?_0x539010['options'][_0x4553('0x22')]?_['map'](_0x539010[_0x4553('0x1d')]['include'],function(_0x1c866d){return{'model':db[_0x1c866d[_0x4553('0x23')]],'as':_0x1c866d['as'],'attributes':_0x1c866d['attributes'],'include':_0x1c866d[_0x4553('0x22')]?_['map'](_0x1c866d['include'],function(_0x423617){return{'model':db[_0x423617['model']],'as':_0x423617['as'],'attributes':_0x423617['attributes'],'include':_0x423617[_0x4553('0x22')]?_['map'](_0x423617[_0x4553('0x22')],function(_0x565f0b){return{'model':db[_0x565f0b['model']],'as':_0x565f0b['as'],'attributes':_0x565f0b[_0x4553('0x24')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x306cea){logger['info']('ShowVoiceQueue',_0x539010);logger[_0x4553('0x26')]('ShowVoiceQueue',_0x539010,JSON[_0x4553('0x18')](_0x306cea));_0x56614e(_0x306cea);})[_0x4553('0x1b')](function(_0x1560a4){logger[_0x4553('0x19')](_0x4553('0x27'),_0x1560a4[_0x4553('0x1a')],_0x539010);_0x495c34(_0x155564[_0x4553('0x19')](0x1f4,_0x1560a4[_0x4553('0x1a')]));});});};