Built motion from commit ff78e754.|2.6.29
[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 _0x2673=['moment','randomstring','ioredis','../../mysqldb','../../config/environment','jayson/promise','client','http','redis','localhost','socket.io-emitter','./voiceQueue.socket','then','info','VoiceQueue,\x20%s,\x20%s','debug','VoiceQueue,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','message','result','GetVoiceQueue','findAll','options','raw','where','attributes','limit','map','include','model','catch','ShowVoiceQueue','find','stringify','lodash','util'];(function(_0x208bc9,_0x4f36f6){var _0x2675a8=function(_0x452e72){while(--_0x452e72){_0x208bc9['push'](_0x208bc9['shift']());}};_0x2675a8(++_0x4f36f6);}(_0x2673,0x1ec));var _0x3267=function(_0x34365b,_0x418c5a){_0x34365b=_0x34365b-0x0;var _0x12d73a=_0x2673[_0x34365b];return _0x12d73a;};'use strict';var _=require(_0x3267('0x0'));var util=require(_0x3267('0x1'));var moment=require(_0x3267('0x2'));var BPromise=require('bluebird');var rs=require(_0x3267('0x3'));var fs=require('fs');var Redis=require(_0x3267('0x4'));var db=require(_0x3267('0x5'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')('rpc');var config=require(_0x3267('0x6'));var jayson=require(_0x3267('0x7'));var client=jayson[_0x3267('0x8')][_0x3267('0x9')]({'port':0x232a});config['redis']=_['defaults'](config[_0x3267('0xa')],{'host':_0x3267('0xb'),'port':0x18eb});var socket=require(_0x3267('0xc'))(new Redis(config[_0x3267('0xa')]));require(_0x3267('0xd'))['register'](socket);function respondWithRpcPromise(_0x45f655,_0x2e0cf2,_0x346df9){return new BPromise(function(_0x1bca85,_0x3bc062){return client['request'](_0x45f655,_0x346df9)[_0x3267('0xe')](function(_0x4d6a5f){logger[_0x3267('0xf')](_0x3267('0x10'),_0x2e0cf2,'request\x20sent');logger[_0x3267('0x11')](_0x3267('0x12'),_0x2e0cf2,_0x3267('0x13'),JSON['stringify'](_0x4d6a5f));if(_0x4d6a5f[_0x3267('0x14')]){if(_0x4d6a5f['error'][_0x3267('0x15')]===0x1f4){logger['error'](_0x3267('0x10'),_0x2e0cf2,_0x4d6a5f[_0x3267('0x14')][_0x3267('0x16')]);return _0x3bc062(_0x4d6a5f[_0x3267('0x14')]['message']);}logger[_0x3267('0x14')](_0x3267('0x10'),_0x2e0cf2,_0x4d6a5f['error'][_0x3267('0x16')]);return _0x1bca85(_0x4d6a5f[_0x3267('0x14')]['message']);}else{logger['info'](_0x3267('0x10'),_0x2e0cf2,_0x3267('0x13'));_0x1bca85(_0x4d6a5f[_0x3267('0x17')][_0x3267('0x16')]);}})['catch'](function(_0xe38d08){logger[_0x3267('0x14')](_0x3267('0x10'),_0x2e0cf2,_0xe38d08);_0x3bc062(_0xe38d08);});});}exports[_0x3267('0x18')]=function(_0x6b0aad){var _0x23812e=this;return new Promise(function(_0x5869e1,_0x1e10f9){return db['VoiceQueue'][_0x3267('0x19')]({'raw':_0x6b0aad[_0x3267('0x1a')]?_0x6b0aad[_0x3267('0x1a')][_0x3267('0x1b')]===undefined?!![]:![]:!![],'where':_0x6b0aad[_0x3267('0x1a')]?_0x6b0aad[_0x3267('0x1a')][_0x3267('0x1c')]||null:null,'attributes':_0x6b0aad[_0x3267('0x1a')]?_0x6b0aad[_0x3267('0x1a')][_0x3267('0x1d')]||null:null,'limit':_0x6b0aad[_0x3267('0x1a')]?_0x6b0aad['options'][_0x3267('0x1e')]||null:null,'include':_0x6b0aad['options']?_0x6b0aad[_0x3267('0x1a')]['include']?_[_0x3267('0x1f')](_0x6b0aad[_0x3267('0x1a')][_0x3267('0x20')],function(_0x4f0bad){return{'model':db[_0x4f0bad[_0x3267('0x21')]],'as':_0x4f0bad['as'],'attributes':_0x4f0bad['attributes'],'include':_0x4f0bad[_0x3267('0x20')]?_['map'](_0x4f0bad[_0x3267('0x20')],function(_0x10c970){return{'model':db[_0x10c970[_0x3267('0x21')]],'as':_0x10c970['as'],'attributes':_0x10c970[_0x3267('0x1d')],'include':_0x10c970['include']?_[_0x3267('0x1f')](_0x10c970[_0x3267('0x20')],function(_0x267b5b){return{'model':db[_0x267b5b[_0x3267('0x21')]],'as':_0x267b5b['as'],'attributes':_0x267b5b[_0x3267('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x3267('0xe')](function(_0x5d5c2d){logger['info'](_0x3267('0x18'),_0x6b0aad);logger[_0x3267('0x11')](_0x3267('0x18'),_0x6b0aad,JSON['stringify'](_0x5d5c2d));_0x5869e1(_0x5d5c2d);})[_0x3267('0x22')](function(_0x28c19a){logger['error']('GetVoiceQueue',_0x28c19a[_0x3267('0x16')],_0x6b0aad);_0x1e10f9(_0x23812e['error'](0x1f4,_0x28c19a[_0x3267('0x16')]));});});};exports[_0x3267('0x23')]=function(_0xafbc4d){var _0x451f96=this;return new Promise(function(_0x2ddaee,_0x109865){return db['VoiceQueue'][_0x3267('0x24')]({'raw':_0xafbc4d[_0x3267('0x1a')]?_0xafbc4d[_0x3267('0x1a')][_0x3267('0x1b')]===undefined?!![]:![]:!![],'where':_0xafbc4d[_0x3267('0x1a')]?_0xafbc4d[_0x3267('0x1a')][_0x3267('0x1c')]||null:null,'attributes':_0xafbc4d['options']?_0xafbc4d[_0x3267('0x1a')]['attributes']||null:null,'include':_0xafbc4d[_0x3267('0x1a')]?_0xafbc4d['options'][_0x3267('0x20')]?_[_0x3267('0x1f')](_0xafbc4d[_0x3267('0x1a')]['include'],function(_0x378056){return{'model':db[_0x378056[_0x3267('0x21')]],'as':_0x378056['as'],'attributes':_0x378056['attributes'],'include':_0x378056[_0x3267('0x20')]?_[_0x3267('0x1f')](_0x378056[_0x3267('0x20')],function(_0x3a1271){return{'model':db[_0x3a1271[_0x3267('0x21')]],'as':_0x3a1271['as'],'attributes':_0x3a1271[_0x3267('0x1d')],'include':_0x3a1271['include']?_['map'](_0x3a1271[_0x3267('0x20')],function(_0x5db93b){return{'model':db[_0x5db93b[_0x3267('0x21')]],'as':_0x5db93b['as'],'attributes':_0x5db93b[_0x3267('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x3267('0xe')](function(_0x3b9eae){logger[_0x3267('0xf')](_0x3267('0x23'),_0xafbc4d);logger['debug']('ShowVoiceQueue',_0xafbc4d,JSON[_0x3267('0x25')](_0x3b9eae));_0x2ddaee(_0x3b9eae);})['catch'](function(_0x572dc0){logger[_0x3267('0x14')]('ShowVoiceQueue',_0x572dc0[_0x3267('0x16')],_0xafbc4d);_0x109865(_0x451f96['error'](0x1f4,_0x572dc0[_0x3267('0x16')]));});});};