Built motion from commit (unavailable).|2.5.0
[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 _0x5f25=['where','limit','map','include','model','attributes','then','debug','catch','ShowVoiceQueue','raw','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','defaults','redis','localhost','./voiceQueue.socket','request','VoiceQueue,\x20%s,\x20%s','VoiceQueue,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','info','result','GetVoiceQueue','VoiceQueue','findAll','options'];(function(_0x3f8a03,_0x319b9c){var _0x147fb2=function(_0x523c1c){while(--_0x523c1c){_0x3f8a03['push'](_0x3f8a03['shift']());}};_0x147fb2(++_0x319b9c);}(_0x5f25,0xfb));var _0x55f2=function(_0x4d770d,_0x5af4ce){_0x4d770d=_0x4d770d-0x0;var _0x11dc7a=_0x5f25[_0x4d770d];return _0x11dc7a;};'use strict';var _=require('lodash');var util=require(_0x55f2('0x0'));var moment=require(_0x55f2('0x1'));var BPromise=require('bluebird');var rs=require(_0x55f2('0x2'));var fs=require('fs');var Redis=require(_0x55f2('0x3'));var db=require(_0x55f2('0x4'))['db'];var utils=require(_0x55f2('0x5'));var logger=require('../../config/logger')(_0x55f2('0x6'));var config=require(_0x55f2('0x7'));var jayson=require(_0x55f2('0x8'));var client=jayson[_0x55f2('0x9')][_0x55f2('0xa')]({'port':0x232a});config['redis']=_[_0x55f2('0xb')](config[_0x55f2('0xc')],{'host':_0x55f2('0xd'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x55f2('0xc')]));require(_0x55f2('0xe'))['register'](socket);function respondWithRpcPromise(_0x1ba877,_0x3fc420,_0xe135ae){return new BPromise(function(_0x2c7869,_0x1775aa){return client[_0x55f2('0xf')](_0x1ba877,_0xe135ae)['then'](function(_0x39ad96){logger['info'](_0x55f2('0x10'),_0x3fc420,'request\x20sent');logger['debug'](_0x55f2('0x11'),_0x3fc420,_0x55f2('0x12'),JSON[_0x55f2('0x13')](_0x39ad96));if(_0x39ad96['error']){if(_0x39ad96[_0x55f2('0x14')][_0x55f2('0x15')]===0x1f4){logger[_0x55f2('0x14')](_0x55f2('0x10'),_0x3fc420,_0x39ad96['error']['message']);return _0x1775aa(_0x39ad96[_0x55f2('0x14')][_0x55f2('0x16')]);}logger['error'](_0x55f2('0x10'),_0x3fc420,_0x39ad96[_0x55f2('0x14')]['message']);return _0x2c7869(_0x39ad96[_0x55f2('0x14')][_0x55f2('0x16')]);}else{logger[_0x55f2('0x17')]('VoiceQueue,\x20%s,\x20%s',_0x3fc420,_0x55f2('0x12'));_0x2c7869(_0x39ad96[_0x55f2('0x18')][_0x55f2('0x16')]);}})['catch'](function(_0x31b888){logger['error'](_0x55f2('0x10'),_0x3fc420,_0x31b888);_0x1775aa(_0x31b888);});});}exports[_0x55f2('0x19')]=function(_0x26878c){var _0x8d20f9=this;return new Promise(function(_0x1c424b,_0x576a0d){return db[_0x55f2('0x1a')][_0x55f2('0x1b')]({'raw':_0x26878c[_0x55f2('0x1c')]?_0x26878c[_0x55f2('0x1c')]['raw']===undefined?!![]:![]:!![],'where':_0x26878c[_0x55f2('0x1c')]?_0x26878c[_0x55f2('0x1c')][_0x55f2('0x1d')]||null:null,'attributes':_0x26878c[_0x55f2('0x1c')]?_0x26878c[_0x55f2('0x1c')]['attributes']||null:null,'limit':_0x26878c[_0x55f2('0x1c')]?_0x26878c[_0x55f2('0x1c')][_0x55f2('0x1e')]||null:null,'include':_0x26878c[_0x55f2('0x1c')]?_0x26878c['options']['include']?_[_0x55f2('0x1f')](_0x26878c[_0x55f2('0x1c')][_0x55f2('0x20')],function(_0x58d568){return{'model':db[_0x58d568[_0x55f2('0x21')]],'as':_0x58d568['as'],'attributes':_0x58d568[_0x55f2('0x22')],'include':_0x58d568[_0x55f2('0x20')]?_[_0x55f2('0x1f')](_0x58d568['include'],function(_0x11a2b2){return{'model':db[_0x11a2b2[_0x55f2('0x21')]],'as':_0x11a2b2['as'],'attributes':_0x11a2b2[_0x55f2('0x22')],'include':_0x11a2b2['include']?_[_0x55f2('0x1f')](_0x11a2b2[_0x55f2('0x20')],function(_0x435481){return{'model':db[_0x435481['model']],'as':_0x435481['as'],'attributes':_0x435481[_0x55f2('0x22')]};}):[]};}):[]};}):[]:[]})[_0x55f2('0x23')](function(_0x279f58){logger[_0x55f2('0x17')](_0x55f2('0x19'),_0x26878c);logger[_0x55f2('0x24')](_0x55f2('0x19'),_0x26878c,JSON['stringify'](_0x279f58));_0x1c424b(_0x279f58);})[_0x55f2('0x25')](function(_0x88ec35){logger[_0x55f2('0x14')]('GetVoiceQueue',_0x88ec35[_0x55f2('0x16')],_0x26878c);_0x576a0d(_0x8d20f9[_0x55f2('0x14')](0x1f4,_0x88ec35[_0x55f2('0x16')]));});});};exports[_0x55f2('0x26')]=function(_0x1f8b31){var _0x2a333a=this;return new Promise(function(_0x3dd0c4,_0x2746b6){return db['VoiceQueue']['find']({'raw':_0x1f8b31['options']?_0x1f8b31[_0x55f2('0x1c')][_0x55f2('0x27')]===undefined?!![]:![]:!![],'where':_0x1f8b31['options']?_0x1f8b31[_0x55f2('0x1c')][_0x55f2('0x1d')]||null:null,'attributes':_0x1f8b31['options']?_0x1f8b31['options'][_0x55f2('0x22')]||null:null,'include':_0x1f8b31[_0x55f2('0x1c')]?_0x1f8b31[_0x55f2('0x1c')][_0x55f2('0x20')]?_[_0x55f2('0x1f')](_0x1f8b31['options'][_0x55f2('0x20')],function(_0x307195){return{'model':db[_0x307195[_0x55f2('0x21')]],'as':_0x307195['as'],'attributes':_0x307195[_0x55f2('0x22')],'include':_0x307195[_0x55f2('0x20')]?_[_0x55f2('0x1f')](_0x307195[_0x55f2('0x20')],function(_0x78dd11){return{'model':db[_0x78dd11[_0x55f2('0x21')]],'as':_0x78dd11['as'],'attributes':_0x78dd11[_0x55f2('0x22')],'include':_0x78dd11['include']?_[_0x55f2('0x1f')](_0x78dd11[_0x55f2('0x20')],function(_0x41df06){return{'model':db[_0x41df06['model']],'as':_0x41df06['as'],'attributes':_0x41df06[_0x55f2('0x22')]};}):[]};}):[]};}):[]:[]})[_0x55f2('0x23')](function(_0x18ff66){logger[_0x55f2('0x17')](_0x55f2('0x26'),_0x1f8b31);logger['debug'](_0x55f2('0x26'),_0x1f8b31,JSON[_0x55f2('0x13')](_0x18ff66));_0x3dd0c4(_0x18ff66);})[_0x55f2('0x25')](function(_0x2efad6){logger[_0x55f2('0x14')](_0x55f2('0x26'),_0x2efad6[_0x55f2('0x16')],_0x1f8b31);_0x2746b6(_0x2a333a[_0x55f2('0x14')](0x1f4,_0x2efad6[_0x55f2('0x16')]));});});};