Built motion from commit e6806ed6.|2.6.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 _0x6ebc=['redis','defaults','localhost','socket.io-emitter','./voiceQueue.socket','info','request\x20sent','VoiceQueue,\x20%s,\x20%s,\x20%s','stringify','error','VoiceQueue,\x20%s,\x20%s','message','result','GetVoiceQueue','findAll','options','raw','where','attributes','limit','include','map','model','then','debug','catch','ShowVoiceQueue','find','lodash','util','moment','randomstring','ioredis','../../config/utils','rpc','../../config/environment','jayson/promise','http'];(function(_0x588b77,_0x373138){var _0x128f7c=function(_0x53a367){while(--_0x53a367){_0x588b77['push'](_0x588b77['shift']());}};_0x128f7c(++_0x373138);}(_0x6ebc,0x8e));var _0xc6eb=function(_0x47a40b,_0x443ecf){_0x47a40b=_0x47a40b-0x0;var _0x19610c=_0x6ebc[_0x47a40b];return _0x19610c;};'use strict';var _=require(_0xc6eb('0x0'));var util=require(_0xc6eb('0x1'));var moment=require(_0xc6eb('0x2'));var BPromise=require('bluebird');var rs=require(_0xc6eb('0x3'));var fs=require('fs');var Redis=require(_0xc6eb('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0xc6eb('0x5'));var logger=require('../../config/logger')(_0xc6eb('0x6'));var config=require(_0xc6eb('0x7'));var jayson=require(_0xc6eb('0x8'));var client=jayson['client'][_0xc6eb('0x9')]({'port':0x232a});config[_0xc6eb('0xa')]=_[_0xc6eb('0xb')](config[_0xc6eb('0xa')],{'host':_0xc6eb('0xc'),'port':0x18eb});var socket=require(_0xc6eb('0xd'))(new Redis(config['redis']));require(_0xc6eb('0xe'))['register'](socket);function respondWithRpcPromise(_0x16aaab,_0x156948,_0xf4a55e){return new BPromise(function(_0x5afc45,_0x63a5ba){return client['request'](_0x16aaab,_0xf4a55e)['then'](function(_0x47e003){logger[_0xc6eb('0xf')]('VoiceQueue,\x20%s,\x20%s',_0x156948,_0xc6eb('0x10'));logger['debug'](_0xc6eb('0x11'),_0x156948,_0xc6eb('0x10'),JSON[_0xc6eb('0x12')](_0x47e003));if(_0x47e003[_0xc6eb('0x13')]){if(_0x47e003['error']['code']===0x1f4){logger[_0xc6eb('0x13')](_0xc6eb('0x14'),_0x156948,_0x47e003['error'][_0xc6eb('0x15')]);return _0x63a5ba(_0x47e003['error'][_0xc6eb('0x15')]);}logger['error'](_0xc6eb('0x14'),_0x156948,_0x47e003[_0xc6eb('0x13')][_0xc6eb('0x15')]);return _0x5afc45(_0x47e003['error'][_0xc6eb('0x15')]);}else{logger[_0xc6eb('0xf')]('VoiceQueue,\x20%s,\x20%s',_0x156948,_0xc6eb('0x10'));_0x5afc45(_0x47e003[_0xc6eb('0x16')][_0xc6eb('0x15')]);}})['catch'](function(_0x266201){logger[_0xc6eb('0x13')](_0xc6eb('0x14'),_0x156948,_0x266201);_0x63a5ba(_0x266201);});});}exports[_0xc6eb('0x17')]=function(_0x2c9159){var _0x5e6eba=this;return new Promise(function(_0x3637a0,_0x44fa5a){return db['VoiceQueue'][_0xc6eb('0x18')]({'raw':_0x2c9159[_0xc6eb('0x19')]?_0x2c9159['options'][_0xc6eb('0x1a')]===undefined?!![]:![]:!![],'where':_0x2c9159[_0xc6eb('0x19')]?_0x2c9159[_0xc6eb('0x19')][_0xc6eb('0x1b')]||null:null,'attributes':_0x2c9159['options']?_0x2c9159[_0xc6eb('0x19')][_0xc6eb('0x1c')]||null:null,'limit':_0x2c9159[_0xc6eb('0x19')]?_0x2c9159[_0xc6eb('0x19')][_0xc6eb('0x1d')]||null:null,'include':_0x2c9159[_0xc6eb('0x19')]?_0x2c9159[_0xc6eb('0x19')][_0xc6eb('0x1e')]?_[_0xc6eb('0x1f')](_0x2c9159[_0xc6eb('0x19')][_0xc6eb('0x1e')],function(_0x2f3047){return{'model':db[_0x2f3047[_0xc6eb('0x20')]],'as':_0x2f3047['as'],'attributes':_0x2f3047[_0xc6eb('0x1c')],'include':_0x2f3047[_0xc6eb('0x1e')]?_[_0xc6eb('0x1f')](_0x2f3047[_0xc6eb('0x1e')],function(_0x3261e2){return{'model':db[_0x3261e2[_0xc6eb('0x20')]],'as':_0x3261e2['as'],'attributes':_0x3261e2['attributes'],'include':_0x3261e2[_0xc6eb('0x1e')]?_[_0xc6eb('0x1f')](_0x3261e2['include'],function(_0x4032ee){return{'model':db[_0x4032ee['model']],'as':_0x4032ee['as'],'attributes':_0x4032ee['attributes']};}):[]};}):[]};}):[]:[]})[_0xc6eb('0x21')](function(_0x3b3572){logger[_0xc6eb('0xf')]('GetVoiceQueue',_0x2c9159);logger[_0xc6eb('0x22')](_0xc6eb('0x17'),_0x2c9159,JSON[_0xc6eb('0x12')](_0x3b3572));_0x3637a0(_0x3b3572);})[_0xc6eb('0x23')](function(_0x5728c6){logger[_0xc6eb('0x13')]('GetVoiceQueue',_0x5728c6['message'],_0x2c9159);_0x44fa5a(_0x5e6eba['error'](0x1f4,_0x5728c6[_0xc6eb('0x15')]));});});};exports[_0xc6eb('0x24')]=function(_0x3c4287){var _0x4e0606=this;return new Promise(function(_0x3925bc,_0x2775f3){return db['VoiceQueue'][_0xc6eb('0x25')]({'raw':_0x3c4287[_0xc6eb('0x19')]?_0x3c4287[_0xc6eb('0x19')][_0xc6eb('0x1a')]===undefined?!![]:![]:!![],'where':_0x3c4287[_0xc6eb('0x19')]?_0x3c4287['options']['where']||null:null,'attributes':_0x3c4287[_0xc6eb('0x19')]?_0x3c4287[_0xc6eb('0x19')]['attributes']||null:null,'include':_0x3c4287['options']?_0x3c4287[_0xc6eb('0x19')][_0xc6eb('0x1e')]?_[_0xc6eb('0x1f')](_0x3c4287['options'][_0xc6eb('0x1e')],function(_0x121fa7){return{'model':db[_0x121fa7['model']],'as':_0x121fa7['as'],'attributes':_0x121fa7[_0xc6eb('0x1c')],'include':_0x121fa7[_0xc6eb('0x1e')]?_[_0xc6eb('0x1f')](_0x121fa7[_0xc6eb('0x1e')],function(_0x2eead2){return{'model':db[_0x2eead2[_0xc6eb('0x20')]],'as':_0x2eead2['as'],'attributes':_0x2eead2[_0xc6eb('0x1c')],'include':_0x2eead2[_0xc6eb('0x1e')]?_[_0xc6eb('0x1f')](_0x2eead2[_0xc6eb('0x1e')],function(_0x3bf686){return{'model':db[_0x3bf686[_0xc6eb('0x20')]],'as':_0x3bf686['as'],'attributes':_0x3bf686[_0xc6eb('0x1c')]};}):[]};}):[]};}):[]:[]})[_0xc6eb('0x21')](function(_0x5a4594){logger['info'](_0xc6eb('0x24'),_0x3c4287);logger[_0xc6eb('0x22')](_0xc6eb('0x24'),_0x3c4287,JSON[_0xc6eb('0x12')](_0x5a4594));_0x3925bc(_0x5a4594);})[_0xc6eb('0x23')](function(_0x22ae9d){logger[_0xc6eb('0x13')](_0xc6eb('0x24'),_0x22ae9d[_0xc6eb('0x15')],_0x3c4287);_0x2775f3(_0x4e0606[_0xc6eb('0x13')](0x1f4,_0x22ae9d['message']));});});};